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

Fix #1125 iso (#1126)

fix(backend): test and checks for old ISOs

issue #1125
parent 2c07aa75
......@@ -3,6 +3,12 @@
**Implemented enhancements:**
- Multiple copies of machines [\#1091]
- Pools of virtual machines [\#1115]
**Bugfixes**
- Access option missing in settings machine [\#1098]
- Logout timeout on start machine too quick [\#1119]
- Change current memory fails [\#1123]
- Data too long for column display [\#1107]
......@@ -179,16 +179,6 @@ sub _update_isos {
my $table = 'iso_images';
my $field = 'name';
my %data = (
mate_artful => {
name => 'Ubuntu Mate Artful'
,description => 'Ubuntu Mate 17.10.1 (Artful) 64 bits'
,arch => 'amd64'
,xml => 'yakkety64-amd64.xml'
,xml_volume => 'yakkety64-volume.xml'
,url => 'http://cdimage.ubuntu.com/ubuntu-mate/releases/17.10.*/release/ubuntu-mate-17.10.*-desktop-amd64.iso'
,md5_url => '$url/MD5SUMS'
,min_disk_size => '10'
},
mate_bionic => {
name => 'Ubuntu Mate Bionic 64 bits'
,description => 'Ubuntu Mate 18.04 (Bionic Beaver) 64 bits'
......@@ -287,16 +277,6 @@ sub _update_isos {
,sha256_url => 'http://dl-cdn.alpinelinux.org/alpine/v3.8/releases/x86/alpine-standard-3.8.1-x86.iso.sha256'
,min_disk_size => '1'
}
,fedora_27 => {
name => 'Fedora 27'
,description => 'RedHat Fedora 27 Workstation 64 bits'
,url => 'http://ftp.halifax.rwth-aachen.de/fedora/linux/releases/27/Workstation/x86_64/iso/Fedora-Workstation-netinst-x86_64-27-.*\.iso'
,arch => 'amd64'
,xml => 'xenial64-amd64.xml'
,xml_volume => 'xenial64-volume.xml'
,sha256_url => '$url/Fedora-Workstation-27-.*-x86_64-CHECKSUM'
,min_disk_size => '10'
}
,fedora_28 => {
name => 'Fedora 28'
,description => 'RedHat Fedora 28 Workstation 64 bits'
......@@ -362,18 +342,6 @@ sub _update_isos {
,file_re => 'mini.iso'
,rename_file => 'xubuntu_bionic_32.iso'
}
,xubuntu_artful => {
name => 'Xubuntu Artful Aardvark'
,description => 'Xubuntu 17.10 Artful Aardvark 64 bits'
,arch => 'amd64'
,xml => 'yakkety64-amd64.xml'
,xml_volume => 'yakkety64-volume.xml'
,md5_url => '$url/../MD5SUMS'
,url => 'http://archive.ubuntu.com/ubuntu/dists/artful/main/installer-amd64/current/images/netboot/'
,file_re => 'mini.iso'
,rename_file => 'xubuntu_artful.iso'
,min_disk_size => '10'
}
,xubuntu_xenial => {
name => 'Xubuntu Xenial Xerus'
,description => 'Xubuntu 16.04 Xenial Xerus 64 bits (LTS)'
......@@ -434,7 +402,7 @@ sub _update_isos {
,debian_stretch_32 => {
name =>'Debian Stretch 32 bits'
,description => 'Debian 9 Stretch 32 bits (XFCE desktop)'
,url => 'https://cdimage.debian.org/cdimage/archive/^9\..*/i386/iso-cd/'
,url => 'https://cdimage.debian.org/cdimage/archive/^9\..*\d$/i386/iso-cd/'
,file_re => 'debian-9.[\d\.]+-i386-xfce-CD-1.iso'
,md5_url => '$url/MD5SUMS'
,xml => 'jessie-i386.xml'
......@@ -454,7 +422,7 @@ sub _update_isos {
,debian_buster_64=> {
name =>'Debian Buster 64 bits'
,description => 'Debian 10 Buster 64 bits (XFCE desktop)'
,url => 'https://cdimage.debian.org/debian-cd/^10\..*/amd64/iso-cd/'
,url => 'https://cdimage.debian.org/debian-cd/^10\..*\d$/amd64/iso-cd/'
,file_re => 'debian-10.[\d\.]+-amd64-xfce-CD-1.iso'
,md5_url => '$url/MD5SUMS'
,xml => 'jessie-amd64.xml'
......@@ -464,7 +432,7 @@ sub _update_isos {
,debian_buster_32=> {
name =>'Debian Buster 32 bits'
,description => 'Debian 10 Buster 32 bits (XFCE desktop)'
,url => 'https://cdimage.debian.org/debian-cd/^10\..*/i386/iso-cd/'
,url => 'https://cdimage.debian.org/debian-cd/^10\..*\d$/i386/iso-cd/'
,file_re => 'debian-10.[\d\.]+-i386-xfce-CD-1.iso'
,md5_url => '$url/MD5SUMS'
,xml => 'jessie-i386.xml'
......@@ -2234,6 +2202,8 @@ sub process_priority_requests($self, $debug=0, $dont_fork=0) {
}
sub _kill_stale_process($self) {
my @domains = $self->list_domains_data();
my $sth = $CONNECTOR->dbh->prepare(
"SELECT id,pid,command,start_time "
." FROM requests "
......@@ -2243,7 +2213,7 @@ sub _kill_stale_process($self) {
." AND pid IS NOT NULL "
." AND start_time IS NOT NULL "
);
$sth->execute(time - 60 );
$sth->execute(time - 5*scalar(@domains) + 60 );
while (my ($id, $pid, $command, $start_time) = $sth->fetchrow) {
if ($pid == $$ ) {
warn "HOLY COW! I should kill pid $pid stale for ".(time - $start_time)
......
......@@ -891,6 +891,7 @@ sub list_requests($self, $id_domain_req=undef, $seconds=60) {
|| $command eq 'post_login'
|| $command eq 'list_network_interfaces'
|| $command eq 'list_isos'
|| $command eq 'manage_pools'
;
next if ( $command eq 'force_shutdown'
|| $command eq 'start'
......
......@@ -72,7 +72,7 @@ our %VALID_ARG = (
,dettach => { uid => 1, id_domain => 1 }
,set_driver => {uid => 1, id_domain => 1, id_option => 1}
,hybernate=> {uid => 1, id_domain => 1}
,download => {uid => 2, id_iso => 1, id_vm => 2, verbose => 2, delay => 2}
,download => {uid => 2, id_iso => 1, id_vm => 2, verbose => 2, delay => 2, test => 2}
,refresh_storage => { id_vm => 2 }
,set_base_vm=> {uid => 1, id_vm=> 1, id_domain => 1, value => 2 }
,cleanup => { }
......
......@@ -1062,6 +1062,7 @@ sub _iso_name($self, $iso, $req, $verbose=1) {
." from $iso->{url}. It may take several minutes"
) if $req;
_fill_url($iso);
return if $req && $req->defined_arg('test');
my $url = $self->_download_file_external($iso->{url}, $device, $verbose);
$self->_refresh_storage_pools();
die "Download failed, file $device missing.\n"
......@@ -1262,8 +1263,10 @@ sub _match_url($self,$url) {
my @found;
my $links = $res->dom->find('a')->map( attr => 'href');
for my $link (@$links) {
next if !defined $link || $link !~ qr($match);
my $new_url = "$url1$link$url2";
next if !defined $link;
$link =~ s{/$}{};
next if $link !~ qr($match);
my $new_url = "$url1$link/$url2";
push @found,($self->_match_url($new_url));
}
return @found;
......@@ -1393,7 +1396,7 @@ sub _match_file($self, $url, $file_re) {
confess $@ if $@;
}
confess unless defined $res->code && $res->code == 200 || $res->code == 301;
return unless defined $res->code && $res->code == 200 || $res->code == 301;
my $dom= $res->dom;
......
......@@ -9,20 +9,15 @@ use Test::More;
use lib 't/lib';
use Test::Ravada;
no warnings "experimental::signatures";
use feature qw(signatures);
use_ok('Ravada');
init();
$Ravada::DEBUG=0;
$Ravada::SECONDS_WAIT_CHILDREN = 1;
if (!$ENV{TEST_DOWNLOAD}) {
diag("Set environment variable TEST_DOWNLOAD to run this test.");
done_testing();
exit;
}
sub test_download {
my ($vm, $id_iso) = @_;
sub test_download($vm, $id_iso, $test=0) {
my $iso = $vm->_search_iso($id_iso);
unlink($iso->{device}) or die "$! $iso->{device}"
if $iso->{device} && -e $iso->{device};
......@@ -30,13 +25,32 @@ sub test_download {
id_iso => $id_iso
, id_vm => $vm->id
, delay => 4
, test => $test
);
is($req1->status, 'requested');
rvd_back->_process_all_requests_dont_fork();
is($req1->status, 'done');
is($req1->error,'');
}
sub search_id_isos {
my $vm = shift;
my $sth=connector->dbh->prepare(
"SELECT * FROM iso_images"
# ." where name like 'Xubuntu %'"
." ORDER BY name,arch"
);
$sth->execute;
my @id_iso;
while ( my $row = $sth->fetchrow_hashref ) {
next if !$row->{url};
push @id_iso,($row->{id});
}
return @id_iso;
}
##################################################################
for my $vm_name ('KVM') {
......@@ -54,8 +68,10 @@ for my $vm_name ('KVM') {
################################################
#
# Request for Debian Streth ISO
my $id_iso = search_id_iso('Debian Stretch') or die "I can't find id_iso for Stretch";
test_download($vm, $id_iso);
for my $id_iso (search_id_isos) {
test_download($vm, $id_iso,1);
}
#test_download($vm, $id_iso,0);
}
}
done_testing();
......@@ -27,7 +27,7 @@
% }
</div>
<div class="col mt-3">
<p class="p-1 text-muted"><font size="2">Copyright &copy; 2016 - 2018 RavadaVDI</font></p>
<p class="p-1 text-muted"><font size="2">Copyright &copy; 2016 - 2019 RavadaVDI</font></p>
</div>
</div>
</div>
......
Markdown is supported
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