Commit d1db2159 authored by Francesc Guasch's avatar Francesc Guasch
Browse files

request for prepare base

parent f370d5b8
......@@ -432,6 +432,23 @@ sub _cmd_start {
}
sub _cmd_prepare_base {
my $self = shift;
my $request = shift;
$request->status('working');
my $name = $request->args('name');
eval {
my $domain = $self->search_domain($name);
die "Unknown domain '$name'\n" if !$domain;
$domain->prepare_base();
};
$request->status('done');
$request->error($@);
}
sub _cmd_shutdown {
my $self = shift;
my $request = shift;
......@@ -459,6 +476,7 @@ sub _req_method {
,create => \&_cmd_create
,remove => \&_cmd_remove
,shutdown => \&_cmd_shutdown
,prepare_base => \&_cmd_prepare_base
);
return $methods{$cmd};
}
......
......@@ -146,16 +146,13 @@ sub remove {
eval { $self->remove_disks() };
warn "WARNING: Problem removing disks for ".$self->name." : $@" if $@;
eval { $self->remove_file_image() } if $self->file_base_img;
$self->_remove_file_image();
# warn "WARNING: Problem removing ".$self->file_base_img." for ".$self->name
# ." , I will try again later : $@" if $@;
$self->domain->undefine();
if ($self->file_base_img) {
eval { $self->remove_file_image() };
warn "WARNING: Problem removing ".$self->file_base_img." for ".$self->name." : $@" if $@;
}
$self->_remove_file_image();
$self->_remove_domain_db();
}
......@@ -167,12 +164,10 @@ sub _remove_file_image {
return if !$file || ! -e $file;
chmod 0700, $file or die "$! $file";
eval { $self->_vol_remove($file,1) };
if ( -e $file ) {
eval { unlink $file or die "$! $file"};
}
$self->vm->storage_pool->refresh();
chmod 0770, $file or die "$! $file";
$self->_vol_remove($file,1);
unlink $file or die "$! $file" if -e $file;
$self->storage->refresh();
}
sub _disk_device {
......
......@@ -154,7 +154,29 @@ sub shutdown_domain {
return $self->_new_request(command => 'shutdown' , args => encode_json({ name => $name }));
}
=head2 prepare_base
Returns a new request for preparing a domain base
my $req = Ravada::Request->prepare_base( $name );
=cut
sub prepare_base {
my $proto = shift;
my $class=ref($proto) || $proto;
my $name = shift;
$name = $name->name if ref($name) =~ /Domain/;
my %args = ( name => $name ) or confess "Missing domain name";
my $self = {};
bless($self,$class);
return $self->_new_request(command => 'prepare_base'
, args => encode_json({ name => $name }));
}
sub _new_request {
my $self = shift;
......
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