Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/frankiejol/ravada
Browse files Browse the repository at this point in the history
  • Loading branch information
frankiejol committed Nov 24, 2016
2 parents c120d29 + ab146b6 commit 6ceea32
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 21 deletions.
6 changes: 6 additions & 0 deletions Makefile.PL
Original file line number Diff line number Diff line change
Expand Up @@ -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'}
Expand Down
1 change: 1 addition & 0 deletions docs/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ Clone the sources:

##Debian

- libmojolicious-perl
- mysql-server
- libauthen-passphrase-perl
- libdbd-mysql-perl
Expand Down
8 changes: 2 additions & 6 deletions lib/Ravada.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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 '');
Expand Down Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion rvd_front.pl
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@
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);

};
Expand Down
4 changes: 2 additions & 2 deletions t/30_request.t
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
37 changes: 29 additions & 8 deletions t/lib/Test/Ravada.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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); };
Expand All @@ -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); };
Expand All @@ -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/;
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion t/vm/80_network.t
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions templates/bootstrap/navigation.html.ep
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@
<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>
% }
% if ( !$_anonymous ) {
<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>
Expand Down

0 comments on commit 6ceea32

Please sign in to comment.