Commit 6ceea32b authored by Francesc Guasch's avatar Francesc Guasch
Browse files

Merge branch 'master' of https://github.com/frankiejol/ravada

parents c120d293 ab146b67
......@@ -18,6 +18,12 @@ WriteMakefile(
,'YAML' => 0
,'Image::Magick' => 0
,'MooseX::Types::NetAddr::IP' => 0
,'IO::Interface' => 0
,'Sys::Statistics::Linux' => 0
,'Test::Pod::Coverage' => 0
},
TEST_REQUIRES => {
'Test::SQL::Data' => 0
},
test => {TESTS => 't/*.t t/*/*.t'}
......
......@@ -30,6 +30,7 @@ Clone the sources:
##Debian
- libmojolicious-perl
- mysql-server
- libauthen-passphrase-perl
- libdbd-mysql-perl
......
......@@ -133,15 +133,11 @@ sub _create_vm_kvm {
eval { $vm_kvm = Ravada::VM::KVM->new( connector => ( $self->connector or $CONNECTOR )) };
my $err_kvm = $@;
return (undef, $err_kvm) if !$vm_kvm;
return ($vm_kvm,$err_kvm);
my ($internal_vm , $storage);
eval {
$internal_vm = $vm_kvm->vm;
$internal_vm->list_all_domains();
$storage = $vm_kvm->dir_img();
$internal_vm = $vm_kvm->vm;
};
$vm_kvm = undef if $@ || !$internal_vm || !$storage;
$err_kvm .= ($@ or '');
......@@ -212,7 +208,7 @@ sub _create_vm {
$err .= "\n$err_lxc" if $err_lxc;
}
if (!@vms) {
confess "No VMs found: $err\n";
warn "No VMs found: $err\n";
}
return \@vms;
......
......@@ -130,7 +130,7 @@ get '/domain/new.html' => sub {
any '/users' => sub {
my $c = shift;
return access_denied($c) if !_logged_in($c);
return access_denied($c) if !_logged_in($c) || !$USER->is_admin;
return users($c);
};
......
......@@ -92,8 +92,8 @@ sub test_req_create_domain_iso {
wait_request($req);
ok($req->status eq 'done'
,"Status of request is ".$req->status." it should be done") or exit;
ok(!$req->error,"Error ".$req->error." creating domain ".$name) or exit;
,"Status of request is ".$req->status." it should be done") or return ;
ok(!$req->error,"Error ".$req->error." creating domain ".$name) or return ;
test_unread_messages($USER,1, "[$vm_name] create domain $name");
my $req2 = Ravada::Request->open($req->id);
......
......@@ -78,15 +78,29 @@ sub _remove_old_domains_vm {
my $vm_name = shift;
my $domain;
my $vm = rvd_back()->search_vm($vm_name);
my $vm;
eval {
my $rvd_back=rvd_back();
return if !$rvd_back;
$vm = $rvd_back->search_vm($vm_name);
};
return if !$vm;
my $base_name = base_domain_name();
for my $dom_name ( sort { $b cmp $a } $vm->list_domains) {
my @domains;
eval { @domains = $vm->list_domains() };
for my $dom_name ( sort { $b cmp $a } @domains) {
next if $dom_name !~ /^$base_name/i;
my $domain = $vm->search_domain($dom_name);
my $domain;
eval {
$domain = $vm->search_domain($dom_name);
};
next if !$domain;
eval { $domain->shutdown_now($USER_ADMIN); };
......@@ -101,7 +115,9 @@ sub _remove_old_domains_vm {
for (reverse 0 .. 20 ) {
my $dom_name = base_domain_name()."_$_";
my $domain = $vm->search_domain($dom_name);
my $domain;
eval { $domain = $vm->search_domain($dom_name) };
next if !$domain;
eval { $domain->shutdown_now($USER_ADMIN); };
......@@ -118,8 +134,13 @@ sub _remove_old_domains_vm {
}
sub _remove_old_domains_kvm {
my $vm = rvd_back()->search_vm('KVM');
my $vm;
eval {
$vm = rvd_back()->search_vm('KVM');
};
return if !$vm;
my $base_name = base_domain_name();
for my $domain ( $vm->vm->list_defined_domains ) {
next if $domain->get_name !~ /^$base_name/;
......@@ -148,13 +169,13 @@ sub _remove_old_disks_kvm {
my $rvd_back= rvd_back();
my $vm = rvd_back()->search_vm('kvm');
if (!$vm) {
warn "I can't find a kvm backend";
return;
}
# ok($vm,"I can't find a KVM virtual manager") or return;
my $dir_img = $vm->dir_img();
ok($dir_img," I cant find a dir_img in the KVM virtual manager") or return;
my $dir_img;
eval { $dir_img = $vm->dir_img() };
return if !$dir_img;
eval { $vm->storage_pool->refresh() };
ok(!$@,$@) or return;
......
......@@ -177,7 +177,12 @@ remove_old_domains();
remove_old_disks();
for my $vm_name (@VMS) {
test_vm($vm_name);
my $vm;
eval { $vm = rvd_back->search_vm($vm_name); };
SKIP: {
skip("No $vm_name virtual manager found",3);
test_vm($vm_name);
}
}
remove_old_domains();
remove_old_disks();
......
......@@ -28,8 +28,8 @@
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><i class="fa fa-wrench"></i>&nbsp;Tools<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="/machines">Virtual Machines</a></li>
<li><a href="/users">Users</a></li>
<li><a href="/machines"><i class="fa fa-cubes"></i>&nbsp;Machines List</a></li>
<li><a href="/users"><i class="fa fa-users"></i>&nbsp;Users</a></li>
</ul>
</li>
% }
......@@ -37,7 +37,7 @@
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><i class="fa fa-question"></i>&nbsp;Help<span class="caret"></span></a>
<ul class="dropdown-menu">
<li><a href="/requirements">Requirements</a></li>
<li><a href="/requirements"><i class="fa fa-gears"></i>&nbsp;Requirements</a></li>
<li role="separator" class="divider"></li>
<li><a href="/about"><i class="fa fa-info-circle"></i>&nbsp;About</a></li>
</ul>
......
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