Commit 75b5853a authored by Francesc Guasch's avatar Francesc Guasch
Browse files

Merge branch 'master' of github.com:UPC/ravada

parents 26d99dbb cbb9c327
......@@ -3107,7 +3107,7 @@ sub list_ports($self) {
$clone_port{$data->{internal_port}}++;
}
if ($self->id_base) {
if (!$self->is_base && $self->id_base) {
my $base = Ravada::Front::Domain->open($self->id_base);
my @ports_base = $base->list_ports();
for my $data (@ports_base) {
......
This diff is collapsed.
......@@ -1315,6 +1315,23 @@ sub import_base($vm) {
$BASE = create_domain($vm);
}
}
sub test_expose_nested_base($vm) {
my $base = $BASE->clone(name => new_domain_name, user => user_admin);
$base->expose(22);
$base->prepare_base(user_admin);
my $base2 = $base->clone(name => new_domain_name , user => user_admin);
$base2->prepare_base(user_admin);
ok($base2->exposed_port(22));
$base2->remove_expose(22);
ok(!$base2->exposed_port(22));
$base2->remove(user_admin);
$base->remove(user_admin);
}
##############################################################
clean();
......@@ -1343,6 +1360,8 @@ for my $vm_name ( 'KVM', 'Void' ) {
flush_rules() if !$<;
import_base($vm);
test_expose_nested_base($vm);
test_interfaces($vm);
test_redirect_ip_duplicated($vm);
......
......@@ -15,6 +15,9 @@ use Test::Ravada;
no warnings "experimental::signatures";
use feature qw(signatures);
my $BASE_NAME = "zz-test-base-alpine";
my $BASE;
sub test_duplicate_req {
my $req = Ravada::Request->manage_pools(uid => user_admin->id);
my $req_dupe = Ravada::Request->manage_pools(uid => user_admin->id);
......@@ -283,13 +286,47 @@ sub test_no_pool($vm) {
wait_request( debug => 0);
}
sub test_remove_clone($vm) {
my $base;
sub import_base($vm) {
if ($vm->type eq 'KVM') {
my $base0 = import_domain( $vm->type , 'zz-test-base-alpine');
$base = $base0->clone(name => new_domain_name , user => user_admin);
$BASE = import_domain($vm->type, $BASE_NAME, 1);
confess "Error: domain $BASE_NAME is not base" unless $BASE->is_base;
confess "Error: domain $BASE_NAME has exported ports that conflict with the tests"
if $BASE->list_ports;
} else {
$BASE = create_domain($vm);
}
}
sub test_exposed_port($vm) {
my $base = $BASE->clone(name => new_domain_name, user => user_admin);
$base->pools(1);
$base->volatile_clones(1);
my $n = 3;
$base->pool_clones($n);
$base->expose(22);
my $req = Ravada::Request->manage_pools(uid => user_admin->id , _no_duplicate => 1);
wait_request( debug => 1, skip => 'set_time' );
is($req->status, 'done');
my $req_refresh = Ravada::Request->refresh_vms( _no_duplicate => 1);
wait_request( debug => 1 ,skip => 'set_time' );
is($req_refresh->status, 'done');
is(scalar($base->clones), $n);
my $clone = $base->clone(name => new_domain_name(), user => user_admin);
for my $clone ( $base->clones ) {
Ravada::Domain->open($clone->{id})->remove(user_admin);
}
$base = create_domain($vm) if !$base;
$base->remove(user_admin);
}
sub test_remove_clone($vm) {
my $base = $BASE->clone(name => new_domain_name, user => user_admin);
$base->pools(1);
$base->volatile_clones(1);
......@@ -344,6 +381,9 @@ for my $vm_name (reverse vm_names() ) {
skip($msg,10) if !$vm;
diag("*** Testing pools in $vm_name ***");
import_base($vm);
test_exposed_port($vm);
test_remove_clone($vm);
test_duplicate_req();
......
......@@ -27,14 +27,18 @@
</div>
<div class="col-mg-4">
<small class="text-secondary">Virtual machines in the pool.</small>
</div>
</div>
<div class="row">
<div class="col-md-2">
<div class="col-md-2" ng-hide="showmachine.volatile_clones">
Start
</div>
<div class="col-md-2">
<div class="col-md-6" ng-show="showmachine.volatile_clones">
<small class="text-secondary">
<%=l 'Clones are volatile, so all the pool will be started.' %>
</small>
</div>
<div class="col-md-2" ng-hide="showmachine.volatile_clones">
<input type="number" size="2" ng-model="showmachine.pool_start"
ng-disabled="showmachine.pools==0"
ng-change="set('pool_start')"
......@@ -42,7 +46,7 @@
style="width: 5em"
>
</div>
<div class="col-mg-4">
<div class="col-mg-4" ng-hide="showmachine.volatile_clones">
<small class="text-secondary">
Virtual machines pre-started
</small>
......
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