Commit 01ff026c authored by Francesc Guasch's avatar Francesc Guasch
Browse files

Merge branch 'master' into develop

parents 9399bd29 a9eabc64
......@@ -3,7 +3,7 @@ package Ravada;
use warnings;
use strict;
our $VERSION = '0.4.0';
our $VERSION = '0.4.0-rc1';
use Carp qw(carp croak);
use Data::Dumper;
......
......@@ -3195,8 +3195,8 @@ sub list_vms($self) {
while (my $id_vm = $sth->fetchrow) {
my $vm;
eval { $vm = Ravada::VM->open($id_vm) };
confess "id_domain: ".$self->id."\n".$@ if $@;
push @vms,($vm);
warn "id_domain: ".$self->id."\n".$@ if $@;
push @vms,($vm) if $vm;
}
my $vm_local = $self->_vm->new( host => 'localhost' );
if ( !grep { $_->name eq $vm_local->name } @vms) {
......
......@@ -704,7 +704,6 @@ sub start {
$self->_vm->enabled(0);
}
die $error;
sleep 1;
} elsif ( $error =~ /libvirt error code: 9, .*already defined with uuid/) {
die "TODO";
} elsif ( $error =~ /libvirt error code: 1,.*smbios/) {
......
......@@ -1007,13 +1007,29 @@ sub list_bases_anonymous {
my $net = Ravada::Network->new(address => $ip);
my $sth = $CONNECTOR->dbh->prepare("SELECT id, name, id_base, is_public FROM domains where is_base=1 AND is_public=1");
my $sth = $CONNECTOR->dbh->prepare(
"SELECT id, name, id_base, is_public, file_screenshot "
."FROM domains where is_base=1 "
."AND is_public=1");
$sth->execute();
my @bases = ();
while ( my $row = $sth->fetchrow_hashref) {
next if !$net->allowed_anonymous($row->{id});
push @bases, ($row);
my ($id, $name, $id_base, $is_public, $screenshot);
$sth->bind_columns(\($id, $name, $id_base, $is_public, $screenshot));
my @bases;
while ( $sth->fetch) {
next if !$net->allowed_anonymous($id);
my %base = ( id => $id, name => $name
, is_public => ($is_public or 0)
, screenshot => ($screenshot or '')
, is_active => 0
, id_clone => undef
, name_clone => undef
, is_locked => undef
, can_hibernate => 0
);
$base{screenshot} =~ s{^/var/www}{};
lock_hash(%base);
push @bases, (\%base);
}
$sth->finish;
......
......@@ -615,7 +615,12 @@
$scope.redirect = function() {
if (!$scope.redirect_done) {
$timeout(function() {
window.location.href="/logout";
if(typeof $_anonymous != "undefined" && $_anonymous){
window.location.href="/anonymous";
}
else {
window.location.href="/logout";
}
}, 60000);
$scope.redirect_done = true;
}
......@@ -710,7 +715,7 @@
$http.get('/unshown_messages.json').then(function(response) {
$scope.alerts= response.data;
},function error(response) {
if ( response.status == 403 ) {
if ( response.status == 403 && (typeof $_anonymous == "undefined" || !$_anonymous)) {
window.location.href="/logout";
}
});
......
......@@ -1146,7 +1146,7 @@ get '/img/screenshots/:file' => sub {
warn"ERROR : no id domain in $path";
return $c->reply->not_found;
}
if (!$USER->is_admin) {
if ($USER && !$USER->is_admin) {
my $domain = $RAVADA->search_domain_by_id($id_domain);
return $c->reply->not_found if !$domain;
unless ($domain->is_base && $domain->is_public) {
......@@ -1355,7 +1355,8 @@ sub render_machines_user {
sub quick_start_domain {
my ($c, $id_base, $name) = @_;
my $anonymous = (shift or 0);
return $c->redirect_to('/login') if !$USER;
confess "Missing id_base" if !defined $id_base;
......@@ -1369,7 +1370,7 @@ sub quick_start_domain {
my $domain = $RAVADA->search_clone(id_base => $base->id, id_owner => $USER->id);
$domain_name = $domain->name if $domain;
return run_request($c,provision_req($c, $id_base, $domain_name));
return run_request($c,provision_req($c, $id_base, $domain_name), $anonymous);
}
......@@ -1591,9 +1592,10 @@ sub _new_domain_name {
}
}
sub run_request($c, $request) {
sub run_request($c, $request, $anonymous = 0) {
return $c->render(template => 'main/run_request', request => $request
, auto_view => ( $CONFIG_FRONT->{auto_view} or $c->session('auto_view') or 0)
, anonymous => $anonymous
);
}
......@@ -1893,7 +1895,7 @@ sub clone_machine($c, $anonymous=0) {
$c->stash( error => "Unknown base ") if !$c->stash('error');
return $c->render(template => 'main/fail');
};
return quick_start_domain($c, $base->id);
return quick_start_domain($c, $base->id, $USER->name, $anonymous);
}
sub shutdown_machine {
......
INSERT INTO iso_images
(name,description,arch,xml,xml_volume,url,file_re,md5_url, min_disk_size)
VALUES('Ubuntu Trusty 32 bits','Ubuntu 14.04 LTS Trusty 32 bits'
,'i386'
,'trusty-i386.xml'
,'trusty-volume.xml'
,'http://releases.ubuntu.com/14.04/'
,'ubuntu-14.04.*-desktop-i386.iso'
,'$url/MD5SUMS'
,'10'
);
INSERT INTO iso_images
(name,description,arch,xml,xml_volume,url, file_re, md5_url, min_disk_size)
VALUES('Ubuntu Trusty 64 bits','Ubuntu 14.04.1 LTS Trusty 64 bits'
,'amd64'
,'trusty-amd64.xml'
,'trusty-amd64-volume.xml'
,'http://releases.ubuntu.com/14.04/'
,'ubuntu-14.04.*-desktop-amd64.iso'
,'http://releases.ubuntu.com/14.04/MD5SUMS'
,'10'
);
INSERT INTO iso_images
(name,description,arch,xml,xml_volume,url, file_re, md5_url, min_disk_size)
VALUES('Ubuntu Xenial Xerus 32 bits','Ubuntu 16.04 LTS Xenial Xerus 32 bits'
......
......@@ -26,6 +26,7 @@ $RVD_BACK = undef;
my @ARG_CREATE_DOM = (
id_owner => $USER->id
,disk => 1024 * 1024
);
$Ravada::CAN_FORK = 0;
......@@ -99,6 +100,7 @@ sub test_req_create_domain_iso {
eval { $req = Ravada::Request->create_domain(
name => $name
,id_iso => search_id_iso('Alpine')
,disk => 1024 * 1024
,@ARG_CREATE_DOM
);
};
......@@ -146,6 +148,7 @@ sub test_req_create_base {
my $req = Ravada::Request->create_domain(
name => $name
,disk => 1024 * 1024
,@ARG_CREATE_DOM
);
ok($req);
......
......@@ -56,7 +56,7 @@ sub test_new_domain {
diag("[$vm_name] Creating domain $name");
$vm->connect();
my $domain = $vm->create_domain(name => $name, @ARG_CREATE_DOM, active => 0);
my $domain = $vm->create_domain(name => $name, @ARG_CREATE_DOM, active => 0, disk => 1024 * 1024);
ok($domain,"Domain not created");
......
......@@ -160,6 +160,7 @@ for my $vm_name ('Void','KVM','LXC') {
my $req = $RVD_FRONT->create_domain( name => $name
, create_args($vm_name)
, vm => $vm_name
, disk => 1024 * 1024
);
ok($req, "Request $name not created");
......
......@@ -51,6 +51,7 @@ sub test_create_domain {
name => $name
,active => 0
,create_args($vm_name)
,disk => 1024 * 1024
);
ok($domain_b);
......
......@@ -47,6 +47,7 @@ sub test_create_domain {
name => $name
,active => 0
,create_args($vm_name)
,disk => 1024 * 1024
);
ok($domain_b);
......
......@@ -33,6 +33,7 @@ sub test_create_domain {
my $domain;
eval { $domain = $vm->create_domain(name => $name
, id_owner => $USER->id
, disk => 1024 * 1024
, arg_create_dom($vm_name))
};
......
......@@ -499,4 +499,3 @@ for my $vm_name ('KVM', 'Void') {
clean();
done_testing();
......@@ -116,6 +116,7 @@ sub test_new_domain_iso {
$domain = $RAVADA->create_domain(name => $name, id_iso => search_id_iso('alpine')
, active => $active
, id_owner => $USER->id , iso_file => $iso->{device}
, disk => 1024 * 1024
, vm => $BACKEND
);
};
......
......@@ -55,6 +55,7 @@ test_remove_domain($name, user_admin());
my $domain = $VMM->create_domain(
name => $name
, disk => 1024 * 1024
, id_iso => search_id_iso('alpine')
, active => 0
, id_owner => $USER->id
......
......@@ -128,6 +128,7 @@ sub test_req_create_domain_iso {
name => $name
,id_iso => search_id_iso('alpine')
,id_owner => $USER->id
, disk => 1024 * 1024
,vm => $BACKEND
,disk => 1024 * 1024
);
......
......@@ -25,6 +25,7 @@ sub test_create_domain {
my $domain;
eval { $domain = $vm->create_domain(name => $name
, id_owner => $USER->id
, disk => 1024 * 1024
, arg_create_dom($vm_name))
};
......
......@@ -27,6 +27,7 @@ sub test_create_domain_xml {
my $device_disk = $vm->create_volume(
name => $name
,size => 1024 * 1024
,xml => "etc/xml/dsl-volume.xml");
ok($device_disk,"Expecting a device disk") or return;
ok(-e $device_disk);
......
......@@ -21,6 +21,7 @@ sub test_create_domain_xml {
my $device_disk = $vm->create_volume(
name => $name
,size => 1024 * 1024
,xml => "etc/xml/dsl-volume.xml");
ok($device_disk,"Expecting a device disk") or return;
ok(-e $device_disk);
......
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