Commit 77defdc4 authored by Francesc Guasch's avatar Francesc Guasch
Browse files

wip(nodes): balance create volatile machines

issue #1345
parent 8a373a37
......@@ -1924,13 +1924,6 @@ sub create_domain {
or confess "Error: Unkown user '$id_owner'";
$request->status("creating machine") if $request;
if ( $base && $base->is_base && $base->volatile_clones || $user->is_temporary ) {
$request->status("balancing") if $request;
$vm = $vm->balance_vm($base) or die "Error: No free nodes available.";
$request->status("creating machine on ".$vm->name) if $request;
}
confess "Error: missing vm " if !$vm;
my $domain;
eval { $domain = $vm->create_domain(%args)};
......
......@@ -388,7 +388,7 @@ sub _around_create_domain {
# args get deleted but kept on %args_create so when we call $self->$orig below are passed
delete $args{disk};
delete $args{memory};
delete $args{request};
my $request = delete $args{request};
delete $args{iso_file};
delete $args{id_template};
delete @args{'description','remove_cpu','vm','start'};
......@@ -427,6 +427,14 @@ sub _around_create_domain {
return $base->_search_pool_clone($owner) if $from_pool;
if ($self->is_local && $base && $base->is_base
&& ( $base->volatile_clones || $owner->is_temporary )) {
$request->status("balancing") if $request;
my $vm = $self->balance_vm($base) or die "Error: No free nodes available.";
$request->status("creating machine on ".$vm->name) if $request;
$self = $vm;
}
my $domain = $self->$orig(%args_create, volatile => $volatile);
$self->_add_instance_db($domain->id);
$domain->add_volume_swap( size => $swap ) if $swap;
......
......@@ -571,6 +571,10 @@ sub test_volatile_req($vm, $node) {
}
is($clone->_vm->id, $node->id) or exit;
shutdown_domain_internal($clone);
for my $vol ( $clone->list_volumes ) {
ok(!$vm->file_exists($vol),$vol) or exit;
}
for (@clones) {
$_->remove(user_admin);
}
......
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