Commit 535ecf4f authored by Francesc Guasch's avatar Francesc Guasch
Browse files

Merge branch 'develop' of https://github.com/UPC/ravada into develop

parents 28f3dd49 02082b92
......@@ -1251,6 +1251,7 @@ sub info($self, $user) {
id => $self->id
,name => $self->name
,is_base => $self->is_base
,id_base => $self->id_base
,is_active => $is_active
,spice_password => $self->spice_password
,description => $self->description
......
......@@ -79,7 +79,10 @@ sub display($self, $user) {
}
sub display_info($self, $user) {
return decode_json($self->_data('display'));
my $display = $self->_data('display');
return {} if !$display;
return decode_json($display);
}
sub display_file_tls($self, $user) {
......
......@@ -542,7 +542,7 @@ sub _new_request {
if ($args{command} =~ /^(clone|manage_pools)$/) {
if ( _duplicated_request($args{command}, $args{args})
|| ( $args{command} ne 'clone' && done_recently(undef, 60, $args{command}))) {
warn "Warning: duplicated request for $args{command} $args{args}";
# warn "Warning: duplicated request for $args{command} $args{args}";
return;
}
}
......
......@@ -600,6 +600,7 @@ sub _interface_ip($self, $remote_ip=undef) {
my $netaddr = NetAddr::IP->new($network);
return $ip if $remote_ip_addr->within($netaddr);
$default_ip = $ip if !defined $default_ip && $ip !~ /^127\./;
$default_ip = $ip if defined $default_gw && $default_gw->within($netaddr);
}
}
......
......@@ -1781,7 +1781,7 @@ sub manage_machine {
}
}
if ($c->param("start-clones") ne "") {
if (defined $c->param("start-clones") && $c->param("start-clones") ne "") {
my $req = Ravada::Request->start_clones(
id_domain => $domain->id,
,uid => $USER->id
......
......@@ -85,7 +85,7 @@ sub test_start {
$RAVADA->_process_all_requests_dont_fork(0);
}
wait_request($req);
wait_request( background => $fork, check_error => 0 );
ok($req->status eq 'done', "[$vm_name] Req ".$req->{id}." expecting status done, got ".$req->status);
like($req->error , qr/unknown/i
......@@ -176,7 +176,7 @@ sub test_screenshot {
my $dont_fork = 1;
rvd_back->process_all_requests(0,$dont_fork);
wait_request($req);
wait_request( background=> !$dont_fork );
ok($req->status('done'),"Request should be done, it is ".$req->status);
ok(!$req->error(''),"Error should be '' , it is ".$req->error);
......@@ -209,7 +209,7 @@ sub test_screenshot_file {
my $dont_fork = 1;
rvd_back->process_all_requests(0,$dont_fork);
wait_request($req);
wait_request( background => !$dont_fork );
ok($req->status('done'),"Request should be done, it is ".$req->status);
ok(!$req->error(),"Error should be '' , it is ".($req->error or ''));
......
......@@ -225,6 +225,7 @@ sub test_manage_group {
}
sub test_user_bind {
my $user = shift;
my $file_config = shift;
my $with_posix_group = shift;
......@@ -238,11 +239,11 @@ sub test_user_bind {
Ravada::Auth::LDAP::init();
_add_to_posix_group('jimmy.mcnulty', $with_posix_group);
_add_to_posix_group($user->name, $with_posix_group);
my $mcnulty;
eval { $mcnulty = Ravada::Auth::LDAP->new(name => 'jimmy.mcnulty',password => 'jameson') };
is($@,'');
eval { $mcnulty = Ravada::Auth::LDAP->new(name => $user->name,password => 'jameson') };
is($@,'') or die $file_config_bind;
ok($mcnulty,($@ or "ldap login failed ")) or return;
......@@ -288,6 +289,12 @@ sub _init_config($file_config, $with_admin, $with_posix_group, $with_filter = 0)
delete $config->{ldap}->{filter};
}
if ($with_admin) {
$config->{ldap}->{admin_group} = $ADMIN_GROUP;
} else {
delete $config->{ldap}->{admin_group};
}
$config->{vm}=['KVM','Void'];
delete $config->{ldap}->{ravada_posix_group} if !$with_posix_group;
......@@ -461,13 +468,13 @@ SKIP: {
ok($ldap) and do {
test_user_fail();
test_user( 'pepe.mcnulty', $with_posix_group );
my $user = test_user( 'pepe.mcnulty', $with_posix_group );
test_add_group();
test_manage_group($with_admin, $with_posix_group);
test_posix_group($with_posix_group);
test_user_bind($fly_config, $with_posix_group);
test_user_bind($user, $fly_config, $with_posix_group);
remove_users();
};
......
......@@ -66,7 +66,6 @@ sub test_remove_corrupt_clone {
);
for my $file ( $clone->list_disks ) {
warn $file;
open my $out, '>',$file or die "$! $file";
print $out "bogus\n";
close $out;
......
......@@ -1146,7 +1146,7 @@ SKIP: {
$vm = undef;
} else {
$node = remote_node($vm_name);
$node = test_node($vm_name, $node);
$node = test_node($vm_name, $node) if $node;
$vm = undef if !$node;
}
......
......@@ -126,9 +126,7 @@ sub add_ubuntu_minimal_iso {
,md5 => 'c7b21dea4d2ea037c3d97d5dac19af99'
});
my $device = "/var/lib/libvirt/images/".$info{$distro}->{rename_file};
warn $device;
if ( -e $device ) {
warn $device;
$info{$distro}->{device} = $device;
}
$RVD_BACK->_update_table('iso_images','name',\%info);
......@@ -594,18 +592,25 @@ sub wait_request {
my %args;
if (scalar @_ % 2 == 0 ) {
%args = @_;
$args{process} = 1 if !exists$args{process};
$args{background} = 0 if !exists $args{background};
} else {
$args{request} = [ $_[0] ];
}
my $timeout = delete $args{timeout};
my $request = ( delete $args{request} or [] );
my $process = delete $args{process};
$timeout = 60 if !defined $timeout && !$process;
my $background = delete $args{background};
$background = 1 if !defined $background;
$timeout = 60 if !defined $timeout && $background;
my $debug = ( delete $args{debug} or 0 );
my $skip = ( delete $args{skip} or [] );
$skip = [ $skip ] if !ref($skip);
my %skip = map { $_ => 1 } @$skip;
my $check_error = delete $args{check_error};
$check_error = 1 if !defined $check_error;
die "Error: uknown args ".Dumper(\%args) if keys %args;
my $t0 = time;
my %done;
......@@ -615,7 +620,7 @@ sub wait_request {
my $done_count = scalar keys %done;
$prev = '' if !defined $prev;
my @req = _list_requests();
rvd_back->_process_requests_dont_fork($debug) if $process;
rvd_back->_process_requests_dont_fork($debug) if !$background;
for my $req_id ( @req ) {
my $req = Ravada::Request->open($req_id);
next if $skip{$req->command};
......@@ -623,7 +628,7 @@ sub wait_request {
$done_all = 0;
} elsif (!$done{$req->id}) {
$done{$req->{id}}++;
is($req->error,'');
is($req->error,'') if $check_error;
}
}
my $post = join(".",_list_requests);
......@@ -639,7 +644,7 @@ sub wait_request {
}
return if $done_all && $prev eq $post && scalar(keys %done) == $done_count;;
return if defined $timeout && time - $t0 >= $timeout;
sleep 1 if !$process;
sleep 1 if !$background;
}
}
......
......@@ -67,14 +67,18 @@ for my $vm_name ( 'Void', 'KVM') {
$vm = undef;
}
diag($msg) if !$vm;
skip($msg,10) if !$vm;
diag("Testing remote node in $vm_name");
my ($node1,$node2) = remote_node_2($vm_name);
ok($node2,"Expecting at least 2 nodes configured to test") or next;
if ( !$node2 ) {
$msg = "Expecting at least 2 nodes configured to test";
$vm = undef;
}
diag($msg) if !$vm;
skip($msg,10) if !$vm;
diag("Testing remote node in $vm_name");
clean_remote_node($node1);
clean_remote_node($node2) if $node2;
......
......@@ -92,7 +92,7 @@ sub test_req_create_domain_iso {
my $rvd_back = rvd_back();
# $rvd_back->process_requests(1);
$rvd_back->process_requests();
wait_request($req);
wait_request(background => 1);
ok($req->status eq 'done'
,"Status of request is ".$req->status." it should be done");
......@@ -156,7 +156,7 @@ sub test_req_create_domain {
my $rvd_back = rvd_back();
$rvd_back->process_requests();
wait_request($req);
wait_request(background => 1);
ok($req->status eq 'done'
,"Status of request is ".$req->status." it should be done");
......@@ -200,7 +200,7 @@ sub test_req_prepare_base {
rvd_back->_process_all_requests_dont_fork();
rvd_back->process_long_requests(0,1);
wait_request($req);
wait_request(background => 1);
ok(!$req->error,"Expecting error='', got '".($req->error or '')."'");
my $vm = rvd_front()->search_vm($vm_name);
......@@ -245,7 +245,7 @@ sub test_req_create_from_base {
rvd_back->process_requests();
wait_request($req);
wait_request(background => 1);
ok($req->status eq 'done'
,"Status of request is ".$req->status." it should be done");
......@@ -288,7 +288,7 @@ sub test_req_create_from_base_novm {
rvd_back->process_requests();
wait_request($req);
wait_request(background => 1);
ok($req->status eq 'done'
,"Status of request is ".$req->status." it should be done");
......@@ -420,7 +420,7 @@ sub test_req_remove_base {
my $rvd_back = rvd_back();
rvd_back->process_requests();
rvd_back->process_long_requests(0,1);
wait_request($req);
wait_request(background => 1);
}
ok($req->status eq 'done', "[$vm_name] Expected req->status 'done', got "
."'".$req->status."'");
......
......@@ -72,7 +72,8 @@ sub test_display {
my ($vm_name, $domain) = @_;
my $display;
$domain->start( user_admin ) if !$domain->is_active;
$domain->shutdown_now(user_admin);
$domain->start(user => user_admin, remote_ip => '1.2.3.4' );# if !$domain->is_active;
eval { $display = $domain->display( user_admin )};
is($@,'');
ok($display,"Expecting a display URI, got '".($display or '')."'") or return;
......
......@@ -110,7 +110,7 @@ sub test_req_create_domain{
rvd_back()->process_requests();
wait_request($req);
wait_request(background => 1);
ok($req->status('done'),"Expecting status='done' , got ".$req->status);
ok(!$req->error,"Expecting error '' , got '".($req->error or '')."'");
......@@ -145,7 +145,7 @@ sub test_req_create_fail {
rvd_back->_process_all_requests_dont_fork();
}
wait_request($req);
wait_request( background => $fork, check_error => 0 );
ok($req->status('done'),"Expecting status='done' , got ".$req->status);
ok($req->error,"Expecting error creating $name , got '".($req->error or '')."'"
." with memory: $mem , disk: $disk , fork: ".($fork or 0)) or exit;
......@@ -251,8 +251,7 @@ sub test_small {
#######################################################################
remove_old_domains();
remove_old_disks();
clean();
$Data::Dumper::Sortkeys = 1;
for my $vm_name (qw( Void KVM )) {
......@@ -284,8 +283,7 @@ for my $vm_name (qw( Void KVM )) {
};
}
remove_old_domains();
remove_old_disks();
clean();
done_testing();
......@@ -87,8 +87,7 @@ sub test_fw_domain($vm_name, $domain_name, $remote_ip='99.88.77.66') {
);
ok($req);
ok($req->status);
rvd_back->_process_all_requests_dont_fork();
wait_request($req);
wait_request(background=> 0);
is($req->status,'done');
is($req->error,'');
......@@ -148,8 +147,7 @@ sub test_fw_domain_pause {
ok($req->status);
my @messages = $USER->messages();
rvd_back->process_requests();
wait_request($req);
wait_request(background => 0);
is($req->status,'done');
is($req->error,'');
......
......@@ -55,7 +55,7 @@ for my $vm_name ( @{rvd_front->list_vm_types}) {
} else {
rvd_back->_process_all_requests_dont_fork();
}
wait_request($req);
wait_request( background => $fork );
$domain = rvd_back->search_domain($domain->name);
is($domain->is_active,0);
......
......@@ -51,6 +51,10 @@ sub test_clones($domain, $n_clones) {
ok($clone);
is($domain->clones(), $n_clones+1);
is($domain->clones(is_pool => 1), $n_clones);
my $clone_f = Ravada::Front::Domain->open($clone->id);
my $info = $clone_f->info(user_admin);
is($info->{id_base}, $domain->id,Dumper($info)) or exit;
}
sub test_active($domain, $n_start) {
......@@ -123,9 +127,10 @@ sub test_user($base, $n_start) {
is($clone2->is_pool,1) or exit;
my $clone_f = Ravada::Front::Domain->open($clone2->id);
is($clone_f->{pools},undef);
is($clone_f->{is_pool},1);
is($clone_f->{comment},$user->name);
my $info = $clone_f->info(user_admin);
is($info->{pools},0);
is($info->{is_pool},1) or die Dumper($clone_f);
is($info->{comment},$user->name);
# now we should have another active
wait_request(debug => 0);
......
......@@ -38,7 +38,7 @@
<script src="/fallback/raphael/raphael-min.js"></script>
<script src="/fallback/morris.js/morris.min.js"></script>
%# <script src="/fallback/bootstrap-select/dist/js/bootstrap-select.js"></script>
<script src="/fallback/bootstrap-select-1.13.9/dist/js/bootstrap-select.js"></script>
<script src="/fallback/intro.js/intro.js"></script>
% }
......
......@@ -39,7 +39,9 @@
<a class="nav-link" id="v-pills-remove-tab" ng-click="refresh_machine()" href="#v-pills-clones" data-toggle="pill" role="tab" aria-controls="v-pills-clones" aria-selected="false"><%=l 'Clones' %></a>
% }
% if ($USER->is_admin){
<a class="nav-link" id="v-pills-pool-tab" ng-click="refresh_machine()" href="#v-pills-pool" data-toggle="pill" role="tab" aria-controls="v-pills-pool" aria-selected="false"><%=l 'Pool' %></a>
<a class="nav-link" id="v-pills-pool-tab" ng-click="refresh_machine()" href="#v-pills-pool" data-toggle="pill" role="tab" aria-controls="v-pills-pool" aria-selected="false"
ng-show="showmachine.is_base || showmachine.id_base"
><%=l 'Pool' %></a>
% }
% if ( $monitoring && $USER->is_admin && $domain->is_active ) {
<a class="nav-link" id="v-pills-monitoring-tab" ng-click="refresh_machine()" href="#v-pills-monitoring" data-toggle="pill" role="tab" aria-controls="v-pills-monitoring" aria-selected="false"><%=l 'System overview' %></a>
......
......@@ -69,7 +69,7 @@
</div>
</form>
</div>
<div class="panel-body" ng-hide="showmachine.is_base">
<div class="panel-body" ng-show="!showmachine.is_base && showmachine.id_base">
<div class="row">
<div class="col-md-2">
Pool
......@@ -85,8 +85,6 @@
</small>
</div>
</div>
</div>
</div>
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