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

New development features (#1191)

* feature(iso): new russian distro Linux Astra

issue #1096

* Fix #1104 mariadb (#1105)

* fix(install): create some tables forcing utf8

fixes issue #1104

* feature(frontend): disable timeout check in login form (#1110)

fixes issue #1102

* feature(backend):Set three first MAC octets as static (#1111)

issue #1103

issue #1102

* 1098 access (#1113)

* fix(access): Add access tab
* fix(access): Improve appearance
* fix(access): Add i18n strings

Issue #1098

* fix(frontend): login with spaces now fails (#1106)

issue #1100

* Fix/1119 timeout (#1120)

* wip(frontend): pass configured timeout when starting

issue #1119

* Feature #1115 pools (#1121)

* feature(frontend): manage pools

issue #1115

* wip(frontend): fallback bt4 upgrade (#958)

* feature(frontend): fallback bt4 upgrade

issue #993 and #949

* 949 fallback (#1122)

feature(frontend): fallback bt4 upgrade

issue #993 and #949

* test(request): change curr and max memory

issue #1123

* fix(request): change current memory

issue #1123

* Fix(i18n): Empty lines transifex errors

* wip(test): improved process waiting

* fixed english duplicates

* fixed when no display info available

* wip(frontend): fixed pool form

* fixed tests when there are no testing nodes

* wip(frontend): bootstrap select picker on fallback

issue #993

* remove old Ubuntu ISOs

* fix(backend): refresh ISOs misplaced file

It only happened if the ISO cache was removed

* 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

* show open ports info only if there is any

* Fix #1125 iso (#1126)

fix(backend): test and checks for old ISOs

issue #1125

* refactor volume management (#1128)

refactor(volumes): volume management

issue #1127

* refactor(frontend): removed warning undefined

* refactor(tests); fix check with local ips

in some environments with no network it may fail

* refactor(backend): remove only if necessary

* Fix #1125 iso (#1129)

* fix(backend): test and checks for old ISOs
* feature(ISO): Arch Linux support
* wip(download): fixed some regexp downloads

issue #1125

* Fix #1131 pool (#1133)

fix(backend): fixed create clone when pooling

* fix(backend): reviewed pool clones management
* refactor(frontend): improved user feedback
* test(backend): pick a machine from pool

issue #1131

* Fix ports expose (#1142)

* test(networking): flush and check FORWARD table
* fix(networking): open forward chain when exposing ports
* fix(frontend): allow ports beyond 99

issue #1134

* Fix prepare base (#1144)

* test(backend): check prepare fails
* fix(backend): prepare base recover when fails

issue #1143

* fixed with ng-cloak (#1139)

issue #1138

* wip(install): download fallback files

* smbios hostname (#1148)

* test(KVM): change smbios on rename
* fix(KVM): change smbios on rename

fiuxes issue #1146

* Update fa.po (#1149)

Some texts from administration section

* fix(networking): properly deny restricted ports (#1147)

issue #1134

* fix(documentation):Review requirements page (#1156)

updated the requierements page to specify the Windows configuration

fixes #1152

* fix(frontend): Improve users management in admin (#1159)

Only show errors when the field loses focus
Added a "Show password" button
"Cancel" button now redirects to the users page (before it redirected to the VMs page)

fixes #1140

* User experience access directly to virtual desktop if only has one machine (#1160)

feat(frontend): direct access if only one machine

Check number of machines
If user only has one clone, redirect to file.vv and open spice client

Issue #1145

* feat(backend): remove user from cli (#1161)

Was proposed by @rogerferre

Issue #1132

* Test #1137 mojo (#1151)

* wip(frontend): return http status when failed login

issue #1137 and it will affect issue #1141 too

* test: allow test to connect to the MySQL DB

issue #1137

* test(frontend): test login and create machine

issue #1137

* wip(test): create base and clone it

issue #1137

* wip(test): show some req messages

* refactor(test): reconnect when timed out

issue #1137

* Feature do not remove CD (#1158)

feature(backend): add option with_cd on create base

* test(volumes): check for CD
* refactor(tests): do not wait for some reqs
* test(backend): check ISO files in bases
* wip(backend): set driver for CD-ROM

issue #1116

* removed debug in test

* wip(frontend): turn LDAP auth object into SQL

this is needed to access auth functions

issue #1154

* fix(networking): properly deny restricted ports (#1181)

issue #1134

* Refactor for ubuntu eoan (#1183)

* test(ldap): add config files for eaon tests
* fix(test): remove user just logged in to refrsh

issue #1177

* fixed test failed when many bridges

* removed debug

* Fix/1185 update cancel hyperlink (#1186)

fix(frontend): Update cancel hyperlink

fixes #1185  and part of #1140

* Feature/1145 directly (#1176)

feat(frontend): direct access if only one machine

Check number of machines
If user only has one clone, redirect to file.vv and open spice client

Issue #1145

* fix(frontend): Improve users management in admin (#1184)

refactor(frontend): Improve users management in admin

    Change button name to "new user"
    Table hides until the "search" button is clicked

fixes #1140

* fix(frontend): Improve new machine page (#1189)

* Disk, Swap and RAM numeric entry
* Enable SWAP volumes by default on new machine
* Minimum disk size entry set by the selected ISO

fixes #1150 & #1154

* Refactor nodes (#1190)

refactor(backend): improved remote nodes response

* feature(CLI): run one request
* improve zombie management
* refactor(backend): check status only if requested
* refactor(backend): cache nodes storage
* install: add dependency for IO::Scalar

issue #1188
parent 79260972
......@@ -5,7 +5,6 @@ Makefile.old
blib
pm_to_blib
t/.db
t/etc/ravada_ldap*.conf
t/etc/remote_vm*.conf
t/etc/front_ldap*.conf
hypnotoad.pid
......
......@@ -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]
......@@ -5,6 +5,7 @@ use ExtUtils::MakeMaker;
WriteMakefile(
VERSION => '0.01',
NAME => 'Ravada',
PREREQ_PM => {
'Mojolicious' => '7.01'
,'DateTime' => 0
......@@ -18,6 +19,7 @@ WriteMakefile(
,'XML::LibXML'=> 0
,'YAML' => 0
,'Image::Magick' => 0
,'IO::Scalar' => 0
,'MooseX::Types::NetAddr::IP' => 0
,'IO::Interface' => 0
,'Sys::Statistics::Linux' => 0
......
......@@ -27,6 +27,7 @@ my $FILE_CONFIG_DEFAULT = "/etc/ravada.conf";
my $FILE_CONFIG;
my $ADD_USER_LDAP;
my $REMOVE_USER;
my $IMPORT_DOMAIN;
my $IMPORT_VBOX;
my $CHANGE_PASSWORD;
......@@ -47,6 +48,7 @@ my $HIBERNATE_DOMAIN;
my $START_DOMAIN;
my $SHUTDOWN_DOMAIN;
my $REBASE;
my $RUN_REQUEST;
my $IMPORT_DOMAIN_OWNER;
......@@ -58,9 +60,11 @@ my $USAGE = "$0 "
." [--test-ldap] "
." [-X] [start|stop|status]"
." [--rebase MACHINE]"
." [--remove-user=name]"
."\n"
." --add-user : adds a new db user\n"
." --add-user-ldap : adds a new LDAP user\n"
." --remove-user : removes a db user\n"
." --change-password : changes the password of an user\n"
." --import-domain : import a domain\n"
." --import-domain-owner : owner of the domain to import\n"
......@@ -103,6 +107,7 @@ GetOptions ( help => \$help
,'shutdown:s'=> \$SHUTDOWN_DOMAIN
,'hibernate:s'=> \$HIBERNATE_DOMAIN
,'disconnected'=> \$DISCONNECTED
,'remove-user=s'=> \$REMOVE_USER
,'make-admin=s' => \$MAKE_ADMIN_USER
,'remove-admin=s' => \$REMOVE_ADMIN_USER
,'change-password'=> \$CHANGE_PASSWORD
......@@ -112,6 +117,7 @@ GetOptions ( help => \$help
,'import-domain-owner=s' => \$IMPORT_DOMAIN_OWNER
,'add-locale-repository=s' => \$ADD_LOCALE_REPOSITORY
,'run-request=s' => \$RUN_REQUEST
) or exit;
$START = 1 if $DEBUG || $FILE_CONFIG || $NOFORK;
......@@ -126,7 +132,7 @@ if ($help) {
exit;
}
die "Only root can do that\n" if $> && ( $ADD_USER || $ADD_USER_LDAP || $IMPORT_DOMAIN);
die "Only root can do that\n" if $> && ( $ADD_USER || $REMOVE_USER || $ADD_USER_LDAP || $IMPORT_DOMAIN);
die "ERROR: Missing file config $FILE_CONFIG\n"
if $FILE_CONFIG && ! -e $FILE_CONFIG;
......@@ -169,10 +175,13 @@ sub do_start {
$ravada->process_long_requests();
$ravada->process_requests();
exit if done_request();
if ( time - $t_refresh > 60 ) {
Ravada::Request->cleanup();
Ravada::Request->refresh_vms() if rand(5)<3;
Ravada::Request->enforce_limits() if rand(5)<2;
Ravada::Request->manage_pools() if rand(5)<2;
$t_refresh = time;
}
sleep 1 if time - $t0 <1;
......@@ -180,6 +189,16 @@ sub do_start {
}
sub done_request {
return 0 if !$RUN_REQUEST;
my $req;
eval { $req = Ravada::Request->open($RUN_REQUEST) };
warn $req->status;
warn $@ if $@;
return 1 if !$req || $req->status eq 'done';
}
sub clean_old_requests {
my $ravada = Ravada->new( %CONFIG );
$ravada->clean_old_requests();
......@@ -199,6 +218,7 @@ sub start {
for (;;) {
eval { do_start() };
warn $@ if $@;
exit if done_request();
}
}
......@@ -236,6 +256,21 @@ sub add_user_ldap {
Ravada::Auth::LDAP::add_user($login, $password);
}
sub remove_user {
my $login = shift;
my $ravada = Ravada->new( %CONFIG);
my $user = Ravada::Auth::SQL->new(name => $login);
die "ERROR: Unknown user '$login'\n" if !$user->id;
print "Are you sure you want remove $login user ? : [y/n] ";
my $remove_it = <STDIN>;
if ( $remove_it =~ /y/i ) {
$user->remove();
print "USER $login was removed\n";
}
}
sub change_password {
print "User login name : ";
my $login = <STDIN>;
......@@ -560,6 +595,7 @@ my $rvd_back = Ravada->new(%CONFIG);
add_user($ADD_USER) if $ADD_USER;
add_user_ldap($ADD_USER_LDAP) if $ADD_USER_LDAP;
remove_user($REMOVE_USER) if $REMOVE_USER;
change_password() if $CHANGE_PASSWORD;
import_domain($IMPORT_DOMAIN) if $IMPORT_DOMAIN;
import_vbox($IMPORT_VBOX) if $IMPORT_VBOX;
......
......@@ -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";
......
......@@ -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,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,libiptables-chainmgr-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-ssh2-perl, bridge-utils
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,libiptables-chainmgr-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-ssh2-perl, bridge-utils
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,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,libiptables-chainmgr-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-ssh2-perl, bridge-utils
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,libiptables-chainmgr-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-ssh2-perl, bridge-utils
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,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,libiptables-chainmgr-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-ssh2-perl, bridge-utils
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,libiptables-chainmgr-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-ssh2-perl, bridge-utils
Description: Remote Virtual Desktops Manager
Ravada is a software that allows the user to connect to a
remote virtual desktop.
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/
morris.js/morris.css https://cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.css
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://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://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://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
#!/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 -oq $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");
}
#############################################################################
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;
name: Astra Linux 2.12.13
description: Astra Linux Orel 2.12.13 64 bits
url: https://mirrors.edge.kernel.org/astra/current/orel/iso/
file_re: orel-2..*.iso
md5_url: $url/orel-2.*md5
arch: amd64
xml: bionic-amd64.xml
xml_volume: bionic64-volume.xml
min_disk_size: 5
This diff is collapsed.
......@@ -51,7 +51,7 @@ Internal OO build
sub BUILD {
my $self = shift;
die "ERROR: Login failed ".$self->name
die "ERROR: Login failed '".$self->name."'"
if !$self->login;
return $self;
}
......@@ -175,6 +175,7 @@ sub search_user {
_init_ldap_admin();
return search_user(
name => $username
,base => $base
,field => $field
,retry => ++$retry
,typesonly => $typesonly
......@@ -186,8 +187,10 @@ sub search_user {
return if !$mesg->count();
my @entries = $mesg->entries;
# warn join ( "\n",map { $_->dn } @entries);
my @entries;
for my $entry ($mesg->entries) {
push @entries,($entry) if $entry->get_value($field) eq $username;
}
return @entries;
}
......@@ -321,15 +324,29 @@ sub add_to_group {
sub login($self) {
my $user_ok;
my $allowed;
if ($$CONFIG->{ldap}->{ravada_posix_group}) {
$allowed = search_user (name => $self->name, field => 'memberUid', base => $$CONFIG->{ldap}->{ravada_posix_group}) || 0;
$self->{_ldap_entry} = $allowed;
} else {
$allowed = 1;
my $posix_group_name = $$CONFIG->{ldap}->{ravada_posix_group};
if ($posix_group_name) {
my ($posix_group) = search_user (
name => $posix_group_name
,field => 'cn'
, base => 'ou=groups,'._dc_base()
);
if (!$posix_group) {
warn "Warning: posix group $posix_group_name not found";
return;
}
my @member = $posix_group->get_value('memberUid');
my $user_name = $self->name;
my ($found) = grep /^$user_name$/,@member;
if (!$found) {
warn "Error: $user_name is not a member of posix group $posix_group_name\n";
warn Dumper(\@member) if $Ravada::DEBUG;
return;
}
$self->{_ldap_entry} = $posix_group;
}
if ($allowed) {
$user_ok = $self->_login_bind()
if !exists $$CONFIG->{ldap}->{auth}
|| !$$CONFIG->{ldap}->{auth}
......@@ -339,9 +356,6 @@ sub login($self) {
$self->_check_user_profile($self->name) if $user_ok;
$LDAP_ADMIN->unbind if $LDAP_ADMIN && exists $self->{_auth} && $self->{_auth} eq 'bind';
return $user_ok;
} else {
return 0;
}
}
sub _login_bind {
......
......@@ -337,6 +337,10 @@ sub _load_allowed {
return if !$refresh && $self->{_load_allowed}++;
if (ref($self) !~ /SQL$/) {
$self = Ravada::Auth::SQL->new(name => $self->name);
}
my $ldap_entry;
$ldap_entry = $self->ldap_entry if $self->external_auth && $self->external_auth eq 'ldap';
......
This diff is collapsed.
......@@ -217,6 +217,8 @@ sub _vol_remove {
my $file = shift;
my $warning = shift;
confess "Error: I won't remove an iso file " if $file =~ /\.iso$/i;
my $name;
($name) = $file =~ m{.*/(.*)} if $file =~ m{/};
......@@ -276,6 +278,7 @@ sub remove {
}
eval { $self->_remove_file_image() };
warn $@ if $@;
confess $@ if $@ && $@ !~ /libvirt error code: 42/;
# warn "WARNING: Problem removing file image for ".$self->name." : $@" if $@ && $0 !~ /\.t$/;
......@@ -290,12 +293,14 @@ sub remove {
sub _remove_file_image {
my $self = shift;
for my $file ( $self->list_files_base ) {
next if $file && $file =~ /\.iso$/i;
next if !$file || ! -e $file;
chmod 0770, $file or die "$! chmodding $file";
chown $<,$(,$file or die "$! chowning $file";
eval { $self->_vol_remove($file,1) };
warn $@ if $@;
if ( -e $file ) {
eval {
......@@ -354,7 +359,7 @@ sub _disk_device($self, $with_info=undef, $attribute=undef, $value=undef) {
push @img,($file) if $file;
next;
}
push @img,$info;
push @img,Ravada::Volume->new(file => $file, info => $info, domain => $self);
}
return @img;
......@@ -421,55 +426,17 @@ sub disk_device {
return $self->_disk_device(@_);
}
sub _create_qcow_base {
confess "Deprecated";
my $self = shift;
my @base_img;
for my $vol_data ( $self->list_volumes_info( device => 'disk')) {
my ($file_img,$target) = ($vol_data->{file}, $vol_data->{target});
my $base_img = $file_img;
my $pool_base = $self->_vm->default_storage_pool_name;
$pool_base = $self->_vm->base_storage_pool() if $self->_vm->base_storage_pool();
$pool_base = $self->_vm->storage_pool() if !$pool_base;
$self->_vm->_check_free_disk($vol_data->{capacity} * 2);
my $dir_base = $self->_vm->_storage_path($pool_base);
my @cmd;
$base_img =~ s{(.*)/(.*)\.\w+$}{$dir_base/$2\.ro.qcow2};
die "ERROR: base image already exists '$base_img'" if -e $base_img;
if ($file_img =~ /\.SWAP\.\w+$/) {
@cmd = _cmd_copy($file_img, $base_img);
} else {
@cmd = _cmd_convert($file_img,$base_img);
}
push @base_img,([$base_img,$target]);
my ($in, $out, $err);
run3(\@cmd,\$in,\$out,\$err);
warn $out if $out;
warn "$?: $err" if $err;
if ($? || ! -e $base_img) {
chomp $err;
chomp $out;
die "ERROR: Output file $base_img not created at "
."\n"
."ERROR $?: '".($err or '')."'\n"
." OUT: '".($out or '')."'\n"
."\n"
.join(" ",@cmd);
}
my $base_img = $vol_data->prepare_base();
push @base_img,([$base_img,$vol_data->info->{target}]);
chmod 0555,$base_img;
unlink $file_img or die "$! $file_img";
$self->_vm->_clone_disk($base_img, $file_img);
}
return @base_img;
......@@ -538,20 +505,17 @@ sub _create_swap_base {
=cut
=head2 prepare_base
=head2 post_prepare_base
Prepares a base virtual machine with this domain disk
Task to run after preparing a base virtual machine
=cut
sub prepare_base {
sub post_prepare_base {
my $self = shift;
# my @img = $self->_create_swap_base();
my @img = $self->_create_qcow_base();
$self->_store_xml();
return @img;
}
sub _store_xml {
......@@ -936,7 +900,7 @@ sub add_volume {
my $self = shift;
my %args = @_;
my $bus = (delete $args{driver} or 'virtio');
my $bus = delete $args{driver};# or 'virtio');
my $boot = (delete $args{boot} or undef);
my $device = (delete $args{device} or 'disk');
my %valid_arg = map { $_ => 1 } ( qw( driver name size vm xml swap target file allocation));
......@@ -958,7 +922,7 @@ sub add_volume {
($name) = $path =~ m{.*/(.*)} if !$name && $path;
$path = $args{vm}->create_volume(
name => ($name or $self->name)
name => $name
,xml => $args{xml}
,swap => ($args{swap} or 0)
,size => ($args{size} or undef)
......@@ -978,6 +942,13 @@ sub add_volume {
$driver_type = 'raw';
}
if ( !defined $bus ) {
if ($device eq 'cdrom') {
$bus = 'ide';
} else {
$bus = 'virtio'
}
}
my $xml_device = $self->_xml_new_device(
bus => $bus
,file => $path
......@@ -1473,6 +1444,11 @@ sub rename {
my $new_name = $args{name};
$self->domain->rename($new_name);
my $doc = XML::LibXML->load_xml(string => $self->domain->get_xml_description);
$self->_vm->_xml_add_sysinfo_entry($doc, hostname => $new_name);
my $new_domain = $self->_vm->vm->define_domain($doc->toString);
$self->domain($new_domain);
}
=head2 disk_size
......@@ -1641,6 +1617,8 @@ sub _hwaddr {
return @hwaddr;
}
=pod