Commit ba132202 authored by Francesc Guasch's avatar Francesc Guasch Committed by frankiejol
Browse files

refactor: do not re-expose in nested bases

Also show all pool machines are started if volatile
parent 1fc23ca0
...@@ -3431,7 +3431,7 @@ sub list_ports($self) { ...@@ -3431,7 +3431,7 @@ sub list_ports($self) {
$clone_port{$data->{internal_port}}++; $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 $base = Ravada::Front::Domain->open($self->id_base);
my @ports_base = $base->list_ports(); my @ports_base = $base->list_ports();
for my $data (@ports_base) { for my $data (@ports_base) {
......
...@@ -1311,6 +1311,23 @@ sub import_base($vm) { ...@@ -1311,6 +1311,23 @@ sub import_base($vm) {
$BASE = create_domain($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(); clean();
...@@ -1339,6 +1356,8 @@ for my $vm_name ( vm_names() ) { ...@@ -1339,6 +1356,8 @@ for my $vm_name ( vm_names() ) {
flush_rules() if !$<; flush_rules() if !$<;
import_base($vm); import_base($vm);
test_expose_nested_base($vm);
test_interfaces($vm); test_interfaces($vm);
test_redirect_ip_duplicated($vm); test_redirect_ip_duplicated($vm);
......
...@@ -15,6 +15,9 @@ use Test::Ravada; ...@@ -15,6 +15,9 @@ use Test::Ravada;
no warnings "experimental::signatures"; no warnings "experimental::signatures";
use feature qw(signatures); use feature qw(signatures);
my $BASE_NAME = "zz-test-base-alpine";
my $BASE;
sub test_duplicate_req { sub test_duplicate_req {
my $req = Ravada::Request->manage_pools(uid => user_admin->id); my $req = Ravada::Request->manage_pools(uid => user_admin->id);
my $req_dupe = 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) { ...@@ -283,13 +286,47 @@ sub test_no_pool($vm) {
wait_request( debug => 0); wait_request( debug => 0);
} }
sub test_remove_clone($vm) { sub import_base($vm) {
my $base;
if ($vm->type eq 'KVM') { if ($vm->type eq 'KVM') {
my $base0 = import_domain( $vm->type , 'zz-test-base-alpine'); $BASE = import_domain($vm->type, $BASE_NAME, 1);
$base = $base0->clone(name => new_domain_name , user => user_admin); 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->pools(1);
$base->volatile_clones(1); $base->volatile_clones(1);
...@@ -343,6 +380,9 @@ for my $vm_name (reverse vm_names() ) { ...@@ -343,6 +380,9 @@ for my $vm_name (reverse vm_names() ) {
skip($msg,10) if !$vm; skip($msg,10) if !$vm;
diag("*** Testing pools in $vm_name ***"); diag("*** Testing pools in $vm_name ***");
import_base($vm);
test_exposed_port($vm);
test_remove_clone($vm); test_remove_clone($vm);
test_duplicate_req(); test_duplicate_req();
......
...@@ -27,14 +27,18 @@ ...@@ -27,14 +27,18 @@
</div> </div>
<div class="col-mg-4"> <div class="col-mg-4">
<small class="text-secondary">Virtual machines in the pool.</small> <small class="text-secondary">Virtual machines in the pool.</small>
</div> </div>
</div> </div>
<div class="row"> <div class="row">
<div class="col-md-2"> <div class="col-md-2" ng-hide="showmachine.volatile_clones">
Start Start
</div> </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" <input type="number" size="2" ng-model="showmachine.pool_start"
ng-disabled="showmachine.pools==0" ng-disabled="showmachine.pools==0"
ng-change="set('pool_start')" ng-change="set('pool_start')"
...@@ -42,7 +46,7 @@ ...@@ -42,7 +46,7 @@
style="width: 5em" style="width: 5em"
> >
</div> </div>
<div class="col-mg-4"> <div class="col-mg-4" ng-hide="showmachine.volatile_clones">
<small class="text-secondary"> <small class="text-secondary">
Virtual machines pre-started Virtual machines pre-started
</small> </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