Commit 022925a3 authored by Francesc Guasch's avatar Francesc Guasch
Browse files

Merge branch 'main' into develop

parents 11cbec40 2bcac046
......@@ -58,3 +58,7 @@ jobs:
run: prove -lr t/40_auth_sql.t t/60_user_sql.t t/65_user_ldap.t t/66_group_ldap.t t/front/60_ldap.t t/front/70_ldap_access.t t/front/80_access.t t/user
- name: Test Templates
run: prove -lr t/17_templates.t
- name: Test mock VM
run: prove -lr t/vm/60_new_args.t t/30_request.t
- name: Test create from ISO
run: prove -lr t/request/25_create_from_iso.t
......@@ -4,7 +4,7 @@ Architecture: all
Section: utils
Priority: optional
Maintainer: Francesc Guasch <frankie@telecos.upc.edu>
Depends: perl (>=5.18),libmojolicious-perl,mysql-common,libauthen-passphrase-perl, libdatetime-perl, libdbd-mysql-perl,libdbi-perl,libdbix-connector-perl,libipc-run3-perl,libio-stringy-perl,libnet-ldap-perl,libproc-pid-file-perl,libvirt-bin,libvirt-daemon-system,libsys-virt-perl,libxml-libxml-perl,libconfig-yaml-perl,libmoose-perl,libjson-xs-perl,qemu-utils,perlmagick,libmoosex-types-netaddr-ip-perl,libio-interface-perl,libnet-dns-perl,wget,liblocale-maketext-lexicon-perl,libmojolicious-plugin-i18n-perl,libdbd-sqlite3-perl, debconf (>= 0.2.26), adduser, libdigest-sha-perl, qemu-kvm, net-tools, libfile-rsync-perl, libnet-openssh-perl, bridge-utils, libencode-locale-perl, libpbkdf2-tiny-perl, libdatetime-format-dateparse-perl, libguestfs-tools, iptstate, libfile-tee-perl
Depends: perl (>=5.18),libmojolicious-perl,mysql-common,libauthen-passphrase-perl, libdatetime-perl, libdbd-mysql-perl,libdbi-perl,libdbix-connector-perl,libipc-run3-perl,libio-stringy-perl,libnet-ldap-perl,libproc-pid-file-perl,libvirt-bin,libvirt-daemon-system,libsys-virt-perl,libxml-libxml-perl,libconfig-yaml-perl,libmoose-perl,libjson-xs-perl,qemu-utils,perlmagick,libmoosex-types-netaddr-ip-perl,libio-interface-perl,libnet-dns-perl,wget,liblocale-maketext-lexicon-perl,libmojolicious-plugin-i18n-perl,libdbd-sqlite3-perl, debconf (>= 0.2.26), adduser, libdigest-sha-perl, qemu-kvm, net-tools, libfile-rsync-perl, libnet-openssh-perl, bridge-utils, libencode-locale-perl, libpbkdf2-tiny-perl, libdatetime-format-dateparse-perl, libguestfs-tools, iptstate, libfile-tee-perl, ovmf
Description: Remote Virtual Desktops Manager
Ravada is a software that allows the user to connect to a
remote virtual desktop.
......@@ -4,7 +4,7 @@ Architecture: all
Section: utils
Priority: optional
Maintainer: Francesc Guasch <frankie@telecos.upc.edu>
Depends: perl (>=5.18),libmojolicious-perl,mysql-common,libauthen-passphrase-perl, libdatetime-perl, libdbd-mysql-perl,libdbi-perl,libdbix-connector-perl,libipc-run3-perl,libio-stringy-perl,libnet-ldap-perl,libproc-pid-file-perl,libvirt-daemon-system,libsys-virt-perl,libxml-libxml-perl,libconfig-yaml-perl,libmoose-perl,libjson-xs-perl,qemu-utils,perlmagick,libmoosex-types-netaddr-ip-perl,libio-interface-perl,libnet-dns-perl,wget,liblocale-maketext-lexicon-perl,libmojolicious-plugin-i18n-perl,libdbd-sqlite3-perl, debconf (>= 0.2.26), adduser, libdigest-sha-perl, qemu-kvm, net-tools, libfile-rsync-perl, libnet-openssh-perl, bridge-utils, libpbkdf2-tiny-perl, libdatetime-format-dateparse-perl, libguestfs-tools, iptstate, libfile-tee-perl
Depends: perl (>=5.18),libmojolicious-perl,mysql-common,libauthen-passphrase-perl, libdatetime-perl, libdbd-mysql-perl,libdbi-perl,libdbix-connector-perl,libipc-run3-perl,libio-stringy-perl,libnet-ldap-perl,libproc-pid-file-perl,libvirt-daemon-system,libsys-virt-perl,libxml-libxml-perl,libconfig-yaml-perl,libmoose-perl,libjson-xs-perl,qemu-utils,perlmagick,libmoosex-types-netaddr-ip-perl,libio-interface-perl,libnet-dns-perl,wget,liblocale-maketext-lexicon-perl,libmojolicious-plugin-i18n-perl,libdbd-sqlite3-perl, debconf (>= 0.2.26), adduser, libdigest-sha-perl, qemu-kvm, net-tools, libfile-rsync-perl, libnet-openssh-perl, bridge-utils, libpbkdf2-tiny-perl, libdatetime-format-dateparse-perl, libguestfs-tools, iptstate, libfile-tee-perl, ovmf
Description: Remote Virtual Desktops Manager
Ravada is a software that allows the user to connect to a
remote virtual desktop.
......@@ -4,7 +4,7 @@ Architecture: all
Section: utils
Priority: optional
Maintainer: Francesc Guasch <frankie@telecos.upc.edu>
Depends: perl (>=5.18),libmojolicious-perl,mysql-common,libauthen-passphrase-perl, libdatetime-perl, libdbd-mysql-perl,libdbi-perl,libdbix-connector-perl,libipc-run3-perl,libio-stringy-perl,libnet-ldap-perl,libproc-pid-file-perl,libvirt-daemon-system,libsys-virt-perl,libxml-libxml-perl,libconfig-yaml-perl,libmoose-perl,libjson-xs-perl,qemu-utils,perlmagick,libmoosex-types-netaddr-ip-perl,libio-interface-perl,libnet-dns-perl,wget,liblocale-maketext-lexicon-perl,libmojolicious-plugin-i18n-perl,libdbd-sqlite3-perl, debconf (>= 0.2.26), adduser, libdigest-sha-perl, qemu-kvm, net-tools, libfile-rsync-perl, libnet-openssh-perl, bridge-utils, libpbkdf2-tiny-perl, libdatetime-format-dateparse-perl, libguestfs-tools, iptstate, libfile-tee-perl
Depends: perl (>=5.18),libmojolicious-perl,mysql-common,libauthen-passphrase-perl, libdatetime-perl, libdbd-mysql-perl,libdbi-perl,libdbix-connector-perl,libipc-run3-perl,libio-stringy-perl,libnet-ldap-perl,libproc-pid-file-perl,libvirt-daemon-system,libsys-virt-perl,libxml-libxml-perl,libconfig-yaml-perl,libmoose-perl,libjson-xs-perl,qemu-utils,perlmagick,libmoosex-types-netaddr-ip-perl,libio-interface-perl,libnet-dns-perl,wget,liblocale-maketext-lexicon-perl,libmojolicious-plugin-i18n-perl,libdbd-sqlite3-perl, debconf (>= 0.2.26), adduser, libdigest-sha-perl, qemu-kvm, net-tools, libfile-rsync-perl, libnet-openssh-perl, bridge-utils, libpbkdf2-tiny-perl, libdatetime-format-dateparse-perl, libguestfs-tools, iptstate, libfile-tee-perl, ovmf
Description: Remote Virtual Desktops Manager
Ravada is a software that allows the user to connect to a
remote virtual desktop.
......@@ -3,7 +3,7 @@ package Ravada;
use warnings;
use strict;
our $VERSION = '1.1.2';
our $VERSION = '1.3.0-beta6';
use Carp qw(carp croak cluck);
use Data::Dumper;
......@@ -282,7 +282,7 @@ sub _update_isos {
androidx86 => {
name => 'Android 8.1 x86'
,description => 'Android-x86 64 bits. Requires an user provided ISO image.'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'android-amd64.xml'
,xml_volume => 'android-volume.xml'
,min_disk_size => '4'
......@@ -290,7 +290,7 @@ sub _update_isos {
arch_1909 => {
name => 'Arch Linux 19.09'
,description => 'Arch Linux 19.09.01 64 bits'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'bionic-amd64.xml'
,xml_volume => 'bionic64-volume.xml'
,url => 'https://archive.archlinux.org/iso/2019.09.01/'
......@@ -301,16 +301,17 @@ sub _update_isos {
mate_focal_fossa => {
name => 'Ubuntu Mate Focal Fossa 64 bits'
,description => 'Ubuntu Mate 20.04 (Focal Fossa) 64 bits'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'focal_fossa-amd64.xml'
,xml_volume => 'focal_fossa64-volume.xml'
,url => 'http://cdimage.ubuntu.com/ubuntu-mate/releases/20.04.*/release/ubuntu-mate-20.04.*-desktop-amd64.iso'
,sha256_url => '$url/SHA256SUMS'
,options => { machine => 'pc-q35', bios => 'UEFI' }
},
mate_bionic => {
name => 'Ubuntu Mate Bionic 64 bits'
,description => 'Ubuntu Mate 18.04 (Bionic Beaver) 64 bits'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'bionic-amd64.xml'
,xml_volume => 'bionic64-volume.xml'
,url => 'http://cdimage.ubuntu.com/ubuntu-mate/releases/18.04.*/release/ubuntu-mate-18.04.*-desktop-amd64.iso'
......@@ -328,7 +329,7 @@ sub _update_isos {
ubuntu_xenial => {
name => 'Ubuntu Xenial Xerus 64 bits'
,description => 'Ubuntu 16.04 LTS Xenial Xerus 64 bits'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'xenial64-amd64.xml'
,xml_volume => 'xenial64-volume.xml'
,url => 'http://releases.ubuntu.com/16.04/ubuntu-16.04.*-desktop-amd64.iso'
......@@ -339,7 +340,7 @@ sub _update_isos {
mate_xenial => {
name => 'Ubuntu Mate Xenial'
,description => 'Ubuntu Mate 16.04.3 (Xenial) 64 bits'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'yakkety64-amd64.xml'
,xml_volume => 'yakkety64-volume.xml'
,url => 'http://cdimage.ubuntu.com/ubuntu-mate/releases/16.04.*/release/ubuntu-mate-16.04.*-desktop-amd64.iso'
......@@ -349,31 +350,34 @@ sub _update_isos {
,focal_fossa=> {
name => 'Ubuntu Focal Fossa'
,description => 'Ubuntu 20.04 Focal Fossa 64 bits'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'focal_fossa-amd64.xml'
,xml_volume => 'focal_fossa64-volume.xml'
,url => 'http://releases.ubuntu.com/20.04/'
,file_re => '^ubuntu-20.04.*-desktop-amd64.iso'
,sha256_url => '$url/SHA256SUMS'
,min_disk_size => '9'
,options => { machine => 'pc-q35', bios => 'UEFI' }
,arch => 'x86_64'
}
,bionic=> {
name => 'Ubuntu Bionic Beaver'
,description => 'Ubuntu 18.04 Bionic Beaver 64 bits'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'bionic-amd64.xml'
,xml_volume => 'bionic64-volume.xml'
,url => 'http://releases.ubuntu.com/18.04/'
,file_re => '^ubuntu-18.04.*desktop-amd64.iso'
,sha256_url => '$url/SHA256SUMS'
,min_disk_size => '9'
,arch => 'x86_64'
}
,serena64 => {
name => 'Mint 18.1 Mate 64 bits'
,description => 'Mint Serena 18.1 with Mate Desktop based on Ubuntu Xenial 64 bits'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'xenial64-amd64.xml'
,xml_volume => 'xenial64-volume.xml'
,url => 'https://mirrors.edge.kernel.org/linuxmint/stable/18.3'
......@@ -386,7 +390,7 @@ sub _update_isos {
,mint20_64 => {
name => 'Mint 20 Mate 64 bits'
,description => 'Mint Ulyana 20 with Mate Desktop 64 bits'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'xenial64-amd64.xml'
,xml_volume => 'xenial64-volume.xml'
,url => 'https://mirrors.edge.kernel.org/linuxmint/stable/20.2'
......@@ -397,21 +401,23 @@ sub _update_isos {
,alpine381_64 => {
name => 'Alpine 3.8 64 bits'
,description => 'Alpine Linux 3.8 64 bits ( Minimal Linux Distribution )'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'alpine-amd64.xml'
,xml_volume => 'alpine381_64-volume.xml'
,url => 'http://dl-cdn.alpinelinux.org/alpine/v3.8/releases/x86_64/'
,file_re => 'alpine-standard-3.8.1-x86_64.iso'
,sha256_url => 'http://dl-cdn.alpinelinux.org/alpine/v3.8/releases/x86_64/alpine-standard-3.8.1-x86_64.iso.sha256'
,min_disk_size => '1'
,min_disk_size => '2'
,options => { machine => 'pc-q35', bios => 'UEFI' }
}
,alpine381_32 => {
name => 'Alpine 3.8 32 bits'
,description => 'Alpine Linux 3.8 32 bits ( Minimal Linux Distribution )'
,arch => 'i386'
,arch => 'i686'
,xml => 'alpine-i386.xml'
,xml_volume => 'alpine381_32-volume.xml'
,url => 'http://dl-cdn.alpinelinux.org/alpine/v3.8/releases/x86/'
,options => { machine => 'pc-i440fx' }
,file_re => 'alpine-standard-3.8.1-x86.iso'
,sha256_url => 'http://dl-cdn.alpinelinux.org/alpine/v3.8/releases/x86/alpine-standard-3.8.1-x86.iso.sha256'
,min_disk_size => '1'
......@@ -420,7 +426,7 @@ sub _update_isos {
name => 'Fedora 28'
,description => 'RedHat Fedora 28 Workstation 64 bits'
,url => 'https://archives.fedoraproject.org/pub/archive/fedora/linux/releases/28/Workstation/x86_64/iso/Fedora-Workstation-netinst-x86_64-28-.*\.iso'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'xenial64-amd64.xml'
,xml_volume => 'xenial64-volume.xml'
,sha256_url => '$url/Fedora-Workstation-28-.*-x86_64-CHECKSUM'
......@@ -429,18 +435,19 @@ sub _update_isos {
,kubuntu_64_focal_fossa => {
name => 'Kubuntu Focal Fossa 64 bits'
,description => 'Kubuntu 20.04 Focal Fossa 64 bits'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'focal_fossa-amd64.xml'
,xml_volume => 'focal_fossa64-volume.xml'
,sha256_url => '$url/SHA256SUMS'
,url => 'http://cdimage.ubuntu.com/kubuntu/releases/20.04.*/release/'
,file_re => 'kubuntu-20.04.*-desktop-amd64.iso'
,rename_file => 'kubuntu_focal_fossa_64.iso'
,options => { machine => 'pc-q35', bios => 'UEFI' }
}
,kubuntu_64 => {
name => 'Kubuntu Bionic Beaver 64 bits'
,description => 'Kubuntu 18.04 Bionic Beaver 64 bits'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'bionic-amd64.xml'
,xml_volume => 'bionic64-volume.xml'
,sha256_url => '$url/SHA256SUMS'
......@@ -462,7 +469,7 @@ sub _update_isos {
,suse_15 => {
name => "openSUSE Leap 15"
,description => "openSUSE Leap 15 64 bits"
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'bionic-amd64.xml'
,xml_volume => 'bionic64-volume.xml'
,url => 'https://download.opensuse.org/distribution/leap/15.0/iso/'
......@@ -473,7 +480,7 @@ sub _update_isos {
,xubuntu_beaver_64 => {
name => 'Xubuntu Bionic Beaver 64 bits'
,description => 'Xubuntu 18.04 Bionic Beaver 64 bits'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'bionic-amd64.xml'
,xml_volume => 'bionic64-volume.xml'
,sha256_url => '$url/../SHA256SUMS'
......@@ -548,6 +555,7 @@ sub _update_isos {
,xml => 'jessie-amd64.xml'
,xml_volume => 'jessie-volume.xml'
,min_disk_size => '10'
,arch => 'x86_64'
}
,debian_stretch_32 => {
name =>'Debian Stretch 32 bits'
......@@ -568,6 +576,7 @@ sub _update_isos {
,xml => 'jessie-amd64.xml'
,xml_volume => 'jessie-volume.xml'
,min_disk_size => '10'
,arch => 'x86_64'
}
,debian_buster_64=> {
name =>'Debian Buster 64 bits'
......@@ -578,6 +587,7 @@ sub _update_isos {
,xml => 'jessie-amd64.xml'
,xml_volume => 'jessie-volume.xml'
,min_disk_size => '10'
,arch => 'x86_64'
}
,debian_buster_32=> {
name =>'Debian Buster 32 bits'
......@@ -591,6 +601,7 @@ sub _update_isos {
}
,debian_bullseye_64=> {
name =>'Debian Bullseye 64 bits'
,arch => 'x86_64'
,description => 'Debian 11 Bullseye 64 bits (netinst)'
,url => 'https://cdimage.debian.org/debian-cd/^11\..*\d$/amd64/iso-cd/'
,file_re => 'debian-11.[\d\.]+-amd64-netinst.iso'
......@@ -598,9 +609,11 @@ sub _update_isos {
,xml => 'jessie-amd64.xml'
,xml_volume => 'jessie-volume.xml'
,min_disk_size => '10'
,options => { machine => 'pc-q35', bios => 'UEFI' }
}
,debian_bullseye_32=> {
name =>'Debian Bullseye 32 bits'
,arch => 'i686'
,description => 'Debian 10 Bullseye 32 bits (netinst)'
,url => 'https://cdimage.debian.org/debian-cd/^11\..*\d$/i386/iso-cd/'
,file_re => 'debian-11.[\d\.]+-i386-netinst.iso'
......@@ -608,11 +621,12 @@ sub _update_isos {
,xml => 'jessie-i386.xml'
,xml_volume => 'jessie-volume.xml'
,min_disk_size => '10'
,options => { machine => 'pc-i440fx' }
}
,devuan_beowulf_amd64=> {
name =>'Devuan Beowulf 64 bits'
,description => 'Devuan Beowulf Desktop Live (amd64)'
,arch => 'amd64'
,arch => 'x86_64'
,url => 'http://tw1.mirror.blendbyte.net/devuan-cd/devuan_beowulf/desktop-live/'
,file_re => 'devuan_beowulf_.*_amd64_desktop-live.iso'
,sha256_url => '$url/SHASUMS.txt'
......@@ -634,7 +648,7 @@ sub _update_isos {
,parrot_xfce_amd64 => {
name => 'Parrot Home Edition XFCE'
,description => 'Parrot Home Edition XFCE 64 Bits'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'jessie-amd64.xml'
,xml_volume => 'jessie-volume.xml'
,url => 'https://download.parrot.sh/parrot/iso/4.11.2/'
......@@ -645,7 +659,7 @@ sub _update_isos {
,parrot_mate_amd64 => {
name => 'Parrot Security Edition MATE'
,description => 'Parrot Security Edition MATE 64 Bits'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'jessie-amd64.xml'
,xml_volume => 'jessie-volume.xml'
,url => 'https://download.parrot.sh/parrot/iso/4.11.2/'
......@@ -656,7 +670,7 @@ sub _update_isos {
,kali_64 => {
name => 'Kali Linux 2020'
,description => 'Kali Linux 2020 64 Bits'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'jessie-amd64.xml'
,xml_volume => 'jessie-volume.xml'
,url => 'https://cdimage.kali.org/kali-2020.\d+/'
......@@ -667,7 +681,7 @@ sub _update_isos {
,kali_64_netinst => {
name => 'Kali Linux 2020 (NetInstaller)'
,description => 'Kali Linux 2020 64 Bits (light NetInstall)'
,arch => 'amd64'
,arch => 'x86_64'
,xml => 'jessie-amd64.xml'
,xml_volume => 'jessie-volume.xml'
,url => 'https://cdimage.kali.org/kali-2020.\d+/'
......@@ -682,6 +696,7 @@ sub _update_isos {
,xml => 'windows_7.xml'
,xml_volume => 'wisuvolume.xml'
,min_disk_size => '21'
,arch => 'x86_64'
}
,windows_10 => {
name => 'Windows 10'
......@@ -690,6 +705,7 @@ sub _update_isos {
,xml => 'windows_10.xml'
,xml_volume => 'windows10-volume.xml'
,min_disk_size => '21'
,arch => 'x86_64'
}
,windows_xp => {
name => 'Windows XP'
......@@ -698,6 +714,7 @@ sub _update_isos {
,xml => 'windows_xp.xml'
,xml_volume => 'wisuvolume.xml'
,min_disk_size => '3'
,arch => 'x86_64'
}
,windows_12 => {
name => 'Windows 2012'
......@@ -706,6 +723,7 @@ sub _update_isos {
,xml => 'windows_12.xml'
,xml_volume => 'wisuvolume.xml'
,min_disk_size => '21'
,arch => 'x86_64'
}
,windows_8 => {
name => 'Windows 8.1'
......@@ -714,6 +732,7 @@ sub _update_isos {
,xml => 'windows_8.xml'
,xml_volume => 'wisuvolume.xml'
,min_disk_size => '21'
,arch => 'x86_64'
}
,empty_32bits => {
name => 'Empty Machine 32 bits'
......@@ -729,6 +748,7 @@ sub _update_isos {
,xml => 'empty-amd64.xml'
,xml_volume => 'jessie-volume.xml'
,min_disk_size => '0'
,arch => 'x86_64'
,has_cd => 0
}
);
......@@ -742,6 +762,13 @@ sub _update_table_isos_url($self, $data) {
my $sth = $CONNECTOR->dbh->prepare("SELECT * FROM iso_images WHERE name=?");
for my $release (sort keys %$data) {
my $entry = $data->{$release};
if (exists $entry->{options} && $entry->{options}
&& ref($entry->{options})
) {
unlock_hash(%$entry);
$entry->{options} = encode_json($entry->{options});
lock_hash(%$entry);
}
$sth->execute($entry->{name});
my $row = $sth->fetchrow_hashref();
for my $field (keys %$entry) {
......@@ -801,7 +828,7 @@ sub _scheduled_fedora_releases($self,$data) {
$data->{$name} = {
name => 'Fedora '.$release
,description => "RedHat Fedora $release Workstation 64 bits"
,arch => 'amd64'
,arch => 'x86_64'
,url => $url_file
,xml => 'xenial64-amd64.xml'
,xml_volume => 'xenial64-volume.xml'
......@@ -1657,9 +1684,7 @@ sub _upgrade_table_fields($self, $table, $fields ) {
}
}
sub _upgrade_table {
my $self = shift;
my ($table, $field, $definition) = @_;
sub _upgrade_table($self, $table, $field, $definition) {
my $dbh = $CONNECTOR->dbh;
my ($new_size) = $definition =~ m{\((\d+)};
......@@ -2339,7 +2364,9 @@ sub _upgrade_tables {
$self->_upgrade_table('iso_images','file_re','char(64)');
$self->_upgrade_table('iso_images','device','varchar(255)');
$self->_upgrade_table('iso_images','min_disk_size','int (11) DEFAULT NULL');
$self->_upgrade_table('iso_images','options','varchar(255)');
$self->_upgrade_table('iso_images','has_cd','int (1) DEFAULT "1"');
$self->_upgrade_table('iso_images','downloading','int (1) DEFAULT "0"');
$self->_upgrade_table('users','language','char(40) DEFAULT NULL');
if ( $self->_upgrade_table('users','is_external','int(11) DEFAULT 0')) {
......@@ -2771,7 +2798,7 @@ sub create_domain {
my $id_base = $args{id_base};
my $data = delete $args{data};
my $id_owner = $args{id_owner} or confess "Error: missing id_owner ".Dumper(\%args);
_check_args(\%args,qw(iso_file id_base id_iso id_owner name active swap memory disk id_template start remote_ip request vm add_to_pool));
_check_args(\%args,qw(iso_file id_base id_iso id_owner name active swap memory disk id_template start remote_ip request vm add_to_pool options));
confess "ERROR: Argument vm required" if !$id_base && !$vm_name;
......@@ -2796,7 +2823,7 @@ sub create_domain {
my $error = $@;
if ( $request ) {
$request->error($error) if $error;
$request->error(''.$error) if $error;
if ($error =~ /has \d+ requests/) {
$request->status('retry');
}
......@@ -3247,6 +3274,13 @@ sub clean_old_requests {
$self->_clean_requests('cleanup');
}
sub _clean_interrupted_downloads($self) {
my $sth = $CONNECTOR->dbh->prepare("UPDATE iso_images "
." SET downloading=0 WHERE downloading=1"
);
$sth->execute();
}
=head2 process_requests
This is run in the ravada backend. It processes the commands requested by the fronted
......@@ -3490,7 +3524,7 @@ sub _kill_dead_process($self) {
"SELECT id,pid,command,start_time "
." FROM requests "
." WHERE start_time<? "
." AND status = 'working' "
." AND ( status like 'working%' OR status like 'downloading%') "
." AND pid IS NOT NULL "
);
$sth->execute(time - 2);
......@@ -4346,6 +4380,9 @@ sub _cmd_download {
my $vm;
$vm = Ravada::VM->open($request->args('id_vm')) if $request->defined_arg('id_vm');
$vm = Ravada::VM->open(type => $request->args('vm'))
if $request->defined_arg('vm');
$vm = $self->search_vm('KVM') if !$vm;
my $delay = $request->defined_arg('delay');
......@@ -4359,7 +4396,7 @@ sub _cmd_download {
return;
}
my $device_cdrom = $vm->_iso_name($iso, $request, $verbose);
Ravada::Request->refresh_storage();
Ravada::Request->refresh_storage(id_vm => $vm->id);
}
sub _cmd_add_hardware {
......@@ -4452,7 +4489,7 @@ sub _cmd_shutdown {
Ravada::Request->refresh_machine(
uid => $uid
,id_domain => $id_domain
,id_domain => $domain->id
,after_request => $request->id
);
my $user = Ravada::Auth::SQL->search_by_id( $uid);
......@@ -4819,6 +4856,18 @@ sub _cmd_list_isos($self, $request){
$request->output(encode_json(\@isos));
}
sub _cmd_list_machine_types($self, $request) {
my $id_vm = $request->defined_arg('id_vm');
my $vm_type = $request->defined_arg('vm_type');
my $vm;
$vm = Ravada::VM->open(type => $vm_type) if $vm_type;
$vm = Ravada::VM->open($id_vm) if $id_vm;
die "Error: No id_vm nor vm_type defined ".Dumper($request->args)
if !$id_vm && ! $vm_type;
my %out = $vm->list_machine_types();
$request->output(encode_json(\%out));
}
sub _cmd_set_time($self, $request) {
my $id_domain = $request->args('id_domain');
my $domain = Ravada::Domain->open($id_domain)
......@@ -5384,6 +5433,7 @@ sub _req_method {
,rename_domain => \&_cmd_rename_domain
,open_iptables => \&_cmd_open_iptables
,list_vm_types => \&_cmd_list_vm_types
,list_machine_types => \&_cmd_list_machine_types
,enforce_limits => \&_cmd_enforce_limits
,force_shutdown => \&_cmd_force_shutdown
,force_reboot => \&_cmd_force_reboot
......
......@@ -707,7 +707,7 @@ sub _around_add_volume {
confess "Error creating volume, out of space $size . Disk free: "
.Ravada::Utils::number_to_size($free_out)
."\n"
if exists $args{size} && $args{size} >= $free;
if exists $args{size} && $args{size} && $args{size} >= $free;
if ($name) {
confess "Error: volume $name already exists"
......@@ -2277,7 +2277,7 @@ sub _redefine_instances($self) {
$@ = '';
eval { $domain = $vm->search_domain($domain_name) } if $vm;
warn $@ if $@;
$domain->copy_config($self);
$domain->copy_config($self) if $domain;
}
}
......@@ -3530,10 +3530,15 @@ sub open_exposed_ports($self) {
return if !@ports;
return if !$self->is_active;
if ( ! $self->ip ) {
my $ip = $self->ip;
if ( ! $ip ) {
die "Error: No ip in domain ".$self->name.". Retry.\n";
}
if (!$self->_vm->_is_ip_nat($ip)) {
die "Error: No NAT ip in domain ".$self->name." found. Retry.\n";
}
$self->display_info(Ravada::Utils::user_daemon);
for my $expose ( @ports ) {
$self->_open_exposed_port($expose->{internal_port}, $expose->{name}
......@@ -4406,6 +4411,10 @@ sub drivers($self, $name=undef, $type=undef, $list=0) {
_init_connector();
my $machine = 'unknown';
$machine = $self->_os_type_machine()
if defined $self && $self->type eq 'KVM';
my $query = "SELECT id from domain_drivers_types ";
my @sql_args = ();
......@@ -4436,6 +4445,9 @@ sub drivers($self, $name=undef, $type=undef, $list=0) {
if ($list) {
my @options;
for my $option ( $cur_driver->get_options ) {
next if $machine =~ /^pc-q35/
&& $name eq 'disk'
&& $option->{name} =~ /^IDE$/i;
push @options,($option->{name});
}
push @drivers, \@options;
......
......@@ -88,8 +88,14 @@ sub get_options {
my $sth = $$CONNECTOR->dbh->prepare($query);
$sth->execute($self->id);
my $machine = 'unknown';
$machine = $self->domain->_os_type_machine()
if defined $self->domain && $self->domain->type eq 'KVM';
my @ret;
while (my $row = $sth->fetchrow_hashref) {
next if $machine =~ /^pc-q35/ && $self->name eq 'disk'
&& $row->{name} =~ /^IDE$/i;
push @ret,($row);
}
return @ret;
......
......@@ -291,7 +291,7 @@ sub remove {
warn $@ if $@;
}
eval { $self->domain->undefine() if $self->domain && !$self->is_removed };
eval { $self->domain->undefine(Sys::Virt::Domain::UNDEFINE_NVRAM) if $self->domain && !$self->is_removed };
confess $@ if $@ && $@ !~ /libvirt error code: 42/;
eval { $self->remove_disks() if $self->is_known };
......@@ -1171,6 +1171,8 @@ sub add_volume {
# confess "Missing vm" if !$args{vm};
$args{vm} = $self->_vm if !$args{vm};
my ($machine_type) = $self->_os_type_machine();
my ($target_dev) = ($args{target} or $self->_new_target_dev());
my $name = delete $args{name};
if (!$args{xml}) {
......@@ -1207,6 +1209,7 @@ sub add_volume {
if ( !defined $bus ) {
if ($device eq 'cdrom') {
$bus = 'ide';
$bus = 'sata' if $machine_type =~ /^pc-q35/;
} else {
$bus = 'virtio'
}
......@@ -1339,7 +1342,7 @@ sub _search_volume_index($self, $file) {
my $index = 0;
for my $device ($doc->findnodes('/domain/devices/disk')) {
my ($source) = $device->findnodes('source');
return $index if $source->getAttribute('file') eq $file;
return $index if $source && $source->getAttribute('file') eq $file;
$index++;
}
confess "I can't find file $file in ".$self->name;
......@@ -1642,13 +1645,20 @@ sub _ip_agent($self) {
return if $@ && $@ =~ /^libvirt error code: (74|86),/;
warn $@ if $@;
my $found;
for my $if (@ip) {
next if $if->{name} =~ /^lo/;
for my $addr ( @{$if->{addrs}} ) {
next unless $addr->{type} == 0 && $addr->{addr} !~ /^127\./;
$found = $addr->{addr} if !$found;
return $addr->{addr}
if $addr->{type} == 0 && $addr->{addr} !~ /^127\./;
if $self->_vm->_is_ip_nat($addr->{addr});
}
}
return $found;
}
#sub _ip_arp($self) {
......@@ -1660,16 +1670,18 @@ sub _ip_agent($self) {
#}
sub