Commit 4fab64a3 authored by Francesc Guasch's avatar Francesc Guasch
Browse files

wip(backend): complete spinoff

issue #852
parent 2dd9e9ba
......@@ -3566,9 +3566,12 @@ sub _req_method {
,add_disk => \&_cmd_add_disk
,copy_screenshot => \&_cmd_copy_screenshot
,cmd_cleanup => \&_cmd_cleanup
,remove_base => \&_cmd_remove_base
,spinoff => \&_cmd_spinoff
,set_base_vm => \&_cmd_set_base_vm
,remove_base_vm => \&_cmd_set_base_vm
,refresh_vms => \&_cmd_refresh_vms
,ping_backend => \&_cmd_ping_backend
,prepare_base => \&_cmd_prepare_base
......
......@@ -175,6 +175,7 @@ around 'force_shutdown' => \&_around_shutdown_now;
before 'remove_base' => \&_pre_remove_base;
after 'remove_base' => \&_post_remove_base;
after 'spinoff' => \&_post_spinoff;
before 'rename' => \&_pre_rename;
after 'rename' => \&_post_rename;
......@@ -1935,6 +1936,11 @@ sub _remove_all_bases($self) {
}
}
sub _post_spinoff($self) {
my $sth = $$CONNECTOR->dbh->prepare("UPDATE domains set id_base=NULL WHERE id=?");
$sth->execute($self->id);
}
sub _pre_shutdown_domain {}
sub _post_remove_base_domain {}
......
......@@ -58,7 +58,7 @@ our %VALID_ARG = (
,open_iptables => $args_manage_iptables
,remove_base => $args_remove_base
,prepare_base => $args_prepare
,spinoff => { id_domain => 1 }
,spinoff => { id_domain => 1, uid => 1 }
,pause_domain => $args_manage
,resume_domain => {%$args_manage, remote_ip => 1 }
,remove_domain => $args_manage
......
......@@ -15,12 +15,17 @@ use Test::Ravada;
sub test_spinoff($base) {
my $clone = $base->clone(name => new_domain_name, user => user_admin);
is($clone->id_base,$base->id);
for my $vol ( $clone->list_volumes_info ) {
next if ref($vol) =~ /ISO/;
like($vol->backing_file, qr(.),$vol->file) or exit;
}
mangle_volume($base->_vm, "spinoff", $clone->list_volumes);
$clone->spinoff();
$clone = Ravada::Domain->open($clone->id);
is($clone->id_base,undef) or exit;
for my $vol ( $clone->list_volumes_info ) {
next if ref($vol) =~ /ISO/;
......
Markdown is supported
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