Unverified Commit efc16b53 authored by Francesc Guasch's avatar Francesc Guasch Committed by GitHub
Browse files

Feature #993 fallback (#1124)

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 #993
parent 5e421388
......@@ -5,6 +5,7 @@ use ExtUtils::MakeMaker;
WriteMakefile(
VERSION => '0.01',
NAME => 'Ravada',
PREREQ_PM => {
'Mojolicious' => '7.01'
,'DateTime' => 0
......
......@@ -34,7 +34,6 @@ for ( qw(css fallback fonts img js )) {
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'
......@@ -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`;
......@@ -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;
......@@ -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";
......
morris.js/morris.css https://cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.css
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
introjs/bin/introjs.css https://cdnjs.cloudflare.com/ajax/libs/intro.js/2.7.0/introjs.css
jquery/jquery.min.js https://code.jquery.com/jquery-3.3.1.min.js
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
bootstrap/dist/js/bootstrap.min.js https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js
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
raphael.js/ https://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-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
morris.js/ https://cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.min.js
intro.js/ https://cdnjs.cloudflare.com/ajax/libs/intro.js/2.7.0/intro.js
bootstrap/ https://github.com/twbs/bootstrap/releases/download/v4.3.1/bootstrap-4.3.1-dist.zip
../img/logoUPC.png https://www.upc.edu/"><img src="https://www.upc.edu/content/assets/images/logoUPC.png
../img/version-$version-brightbreen.svg wget https://img.shields.io/badge/version-$version-brightgreen.svg
../img/latest.svg https://readthedocs.org/projects/ravada/badge/?version=latest
../img/License-AGPL%20v3-blue.svg https://img.shields.io/badge/License-AGPL%20v3-blue.svg
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/
#!/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;
......@@ -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;
......
......@@ -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 \$?");
......
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="108" height="20"><linearGradient id="b" x2="0" y2="100%"><stop offset="0" stop-color="#bbb" stop-opacity=".1"/><stop offset="1" stop-opacity=".1"/></linearGradient><clipPath id="a"><rect width="108" height="20" rx="3" fill="#fff"/></clipPath><g clip-path="url(#a)"><path fill="#555" d="M0 0h51v20H0z"/><path fill="#007ec6" d="M51 0h57v20H51z"/><path fill="url(#b)" d="M0 0h108v20H0z"/></g><g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="110"> <text x="265" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="410">License</text><text x="265" y="140" transform="scale(.1)" textLength="410">License</text><text x="785" y="150" fill="#010101" fill-opacity=".3" transform="scale(.1)" textLength="470">AGPL v3</text><text x="785" y="140" transform="scale(.1)" textLength="470">AGPL v3</text></g> </svg>
\ No newline at end of file
......@@ -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'
......@@ -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."] "
......@@ -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);
......
......@@ -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 {
......
......@@ -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>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment