Skip to content

Commit

Permalink
Feature UPC#993 fallback (UPC#1124)
Browse files Browse the repository at this point in the history
feature(frontend): get all fallback files for the package

* wip(frontend): fallback for raphael fixed
* wip(frontend): get original files for fallback
* Also fix tell user to install agent for remote tests
* wip(frontend); version badge

issue UPC#993
  • Loading branch information
frankiejol authored Aug 30, 2019
1 parent 5e42138 commit efc16b5
Show file tree
Hide file tree
Showing 11 changed files with 121 additions and 28 deletions.
1 change: 1 addition & 0 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use ExtUtils::MakeMaker;

WriteMakefile(
VERSION => '0.01',
NAME => 'Ravada',
PREREQ_PM => {
'Mojolicious' => '7.01'
,'DateTime' => 0
Expand Down
10 changes: 7 additions & 3 deletions deb/debianize.pl
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
my %FILE = (
'etc/rvd_front.conf.example' => 'etc/rvd_front.conf'
,'bin/rvd_back.pl' => 'usr/sbin/rvd_back'
,'bin/rvd_benchmark_create.pl' => 'usr/sbin/rvd_benchmark_create'
,'rvd_front.pl' => 'usr/sbin/rvd_front'
,'CHANGELOG.md' => 'usr/share/doc/ravada/changelog'
,'copyright' => 'usr/share/doc/ravada'
Expand All @@ -61,7 +60,7 @@ sub copy_dirs {
make_path($dst) if ! -e $dst;

my ($in, $out, $err);
my @cmd = ('rsync','-avL',$src,$dst);
my @cmd = ('rsync','-avL','--exclude','*.zip',$src,$dst);
run3(\@cmd, \$in, \$out, \$err);
die $err if $err;
print `chmod go+rx $dst`;
Expand Down Expand Up @@ -242,7 +241,6 @@ sub tar {
my @cmd = ('tar','czvf',"ravada_$VERSION.orig.tar.gz"
,"ravada-$VERSION-$dist"
);
warn "@cmd";
my ($in, $out, $err);
run3(\@cmd, \$in, \$out, \$err);
confess $err if $err;
Expand Down Expand Up @@ -322,8 +320,14 @@ sub set_control_file {
closedir $dir;
}

sub get_fallback {
print `etc/get_fallback.pl`;
}

#########################################################################

get_fallback();

for my $dist (list_dists) {

$DIR_DST = "$DIR_SRC/../ravada-$VERSION-$dist";
Expand Down
19 changes: 19 additions & 0 deletions etc/fallback.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
https://cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.css morris.js/
https://use.fontawesome.com/releases/v5.10.1/fontawesome-free-5.10.1-web.zip
https://cdnjs.cloudflare.com/ajax/libs/intro.js/2.7.0/introjs.css intro.js/bin/
https://code.jquery.com/jquery-3.3.1.min.js jquery/
https://jqueryui.com/resources/download/jquery-ui-1.11.1.zip
https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js
https://code.angularjs.org/1.5.5/angular-1.5.5.zip
https://cdnjs.cloudflare.com/ajax/libs/angular-ui-bootstrap/2.5.0/ui-bootstrap.min.js
https://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js raphael.js/
https://github.com/snapappointments/bootstrap-select/archive/v1.13.9.zip
https://cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.min.js morris.js/
https://cdnjs.cloudflare.com/ajax/libs/intro.js/2.7.0/intro.js intro.js/
https://github.com/twbs/bootstrap/releases/download/v4.3.1/bootstrap-4.3.1-dist.zip
https://www.upc.edu/content/assets/images/logoUPC.png ../img/logoUPC.png
#../img/version-$version-brightbreen.svg wget https://img.shields.io/badge/version-$version-brightgreen.svg
https://readthedocs.org/projects/ravada/badge/?version=latest ../img/latest.svg
https://img.shields.io/badge/License-AGPL%20v3-blue.svg ../img/License-AGPL%20v3-blue.svg
https://download.cksource.com/CKEditor/CKEditor/CKEditor%204.12.1/ckeditor_4.12.1_standard_easyimage.zip
https://ajax.googleapis.com/ajax/libs/angular_material/1.1.0/angular-material.min.js angular-material/
18 changes: 0 additions & 18 deletions etc/fallback.txt

This file was deleted.

78 changes: 78 additions & 0 deletions etc/get_fallback.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/usr/bin/perl

use warnings;
use strict;

use Cwd;
use File::Path qw(make_path);
use Mojo::UserAgent;

use lib './lib';
use Ravada;

my $VERSION = Ravada::version();
no warnings "experimental::signatures";
use feature qw(signatures);

my $ua = Mojo::UserAgent->new;
$ua->max_redirects(4);

my $FILE_CONFIG = 'etc/fallback.conf';
my $DIR_FALLBACK = getcwd.'/public/fallback';

die "Error: missing fallback dir $DIR_FALLBACK"
if ! -e $DIR_FALLBACK;

sub download($url, $dst = $DIR_FALLBACK) {

$dst = "$DIR_FALLBACK/$dst" if $dst !~ m{^/};

my ($path) = $dst =~ m{(.*)/};
make_path($path) if ! -e $path;

if ( -d $dst ) {
my ($filename) = $url =~ m{.*/(.*)};
$dst .= "/" if $dst !~ m{/$};
$dst .= $filename;
}

return $dst if -e $dst;

print "get $url\n";
my $res = $ua->get($url)->result;
if ($res->is_success) {
print "$url downloaded to $dst\n";
$res->content->asset->move_to($dst);
}
elsif ($res->is_error) { print $res->message."\n" }
elsif ($res->code == 301) { print $res->headers->location."\n" }
else { print "Error ".$res->code." ".$res->message
." downloading $url\n"}
return $dst;
}

sub uncompress($file) {
chdir $DIR_FALLBACK or die "$! $DIR_FALLBACK";
print `unzip -o $file`;
}

sub get_version_badge {
return if $VERSION =~/alpha/;
$VERSION =~ s/-/--/;
download("https://img.shields.io/badge/version-$VERSION-brightgreen.svg"
,"../img/version-$VERSION-brightgreen.svg");
exit;
}

#############################################################################

get_version_badge();

open my $in,'<',$FILE_CONFIG or die "$! $FILE_CONFIG";
while (<$in>) {
next if /^#/;
my ($url, $dst) = split;
my $file = download($url, $dst);
uncompress($file) if $file =~ /\.zip$/;
}
close $in;
2 changes: 1 addition & 1 deletion lib/Ravada.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package Ravada;
use warnings;
use strict;

our $VERSION = '0.4.7';
our $VERSION = '0.5.0-beta2';

use Carp qw(carp croak);
use Data::Dumper;
Expand Down
3 changes: 2 additions & 1 deletion lib/Ravada/VM.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1195,7 +1195,8 @@ sub _read_file_local( $self, $file ) {
sub file_exists( $self, $file ) {
return -e $file if $self->is_local;

$self->_connect_ssh(1);
# why should we force disconnect before ?
$self->_connect_ssh();
my ( $out, $err) = $self->run_command("/usr/bin/test",
"-e $file ; echo \$?");

Expand Down
1 change: 1 addition & 0 deletions public/img/License-AGPL%20v3-blue.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 6 additions & 3 deletions t/lib/Test/Ravada.pm
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ sub flush_rules {
sub _domain_node($node) {
my $vm = rvd_back->search_vm('KVM','localhost');
ok($vm) or die Dumper(rvd_back->_create_vm);
my $domain = $vm->search_domain($node->name);
my $domain = $vm->search_domain($node->name, 1);
$domain = rvd_back->import_domain(name => $node->name
,user => user_admin->name
,vm => 'KVM'
Expand Down Expand Up @@ -1039,7 +1039,8 @@ sub start_node($node) {
warn $@ if $@;
last if $connect;
sleep 1;
diag("Waiting for connection to node ".$node->name." $_") if !($_ % 5);
diag("Waiting for connection to node ".$node->type." "
.$node->name." $_") if !($_ % 5);
}
is($connect,1
,"[".$node->type."] "
Expand All @@ -1048,8 +1049,10 @@ sub start_node($node) {
$domain = _domain_node($node);
last if $domain->ip;
sleep 1;
diag("Waiting for connection to node ".$node->name." $_") if !($_ % 5);
diag("Waiting for domain from node ".$node->type." "
.$node->name." $_") if !($_ % 5);
}
ok($domain->ip,"Make sure the virtual machine ".$domain->name." has installed the qemu-guest-agent") or exit;

$node->is_active(1);
$node->is_enabled(1);
Expand Down
6 changes: 5 additions & 1 deletion templates/bootstrap/footer.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
% $version =~ s/-/--/g;
% if ($fallback) {
<a href="https://ravada.upc.edu/"><img src="/img/Website-Ravada-orange.svg"></a>
<a href="https://github.com/UPC/ravada/releases"><img src="/img/version-<%= $version %>-brightgreen.svg"></a>
% if ($version =~/alpha/) {
<a href="https://github.com/UPC/ravada/releases"><%= $version %></a>
% } else {
<a href="https://github.com/UPC/ravada/releases"><img alt="<%= $version %>" src="/img/version-<%= $version %>-brightgreen.svg"></a>
% }
<a href="https://github.com/UPC/ravada/blob/master/LICENSE"><img src="/img/License-AGPL%20v3-blue.svg"></a>
<a href="https://ravada.readthedocs.io"><img src="/img/latest.svg"></a>
% } else {
Expand Down
2 changes: 1 addition & 1 deletion templates/bootstrap/scripts.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@

<script src="/fallback/angular-material/angular-material.min.js"></script>

<script src="/fallback/raphael/raphael-min.js"></script>
<script src="/fallback/raphael.js/raphael-min.js"></script>
<script src="/fallback/morris.js/morris.min.js"></script>

<script src="/fallback/bootstrap-select-1.13.9/dist/js/bootstrap-select.js"></script>
Expand Down

0 comments on commit efc16b5

Please sign in to comment.