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

fixed remove file image of the bases

parent ec19a88a
......@@ -279,6 +279,9 @@ sub list_bases {
my @domains;
for my $vm (@{$self->vm}) {
for my $domain ($vm->list_domains) {
eval { $domain->id };
warn $@ if $@;
next if $@;
push @domains,($domain) if $domain->is_base;
}
}
......
......@@ -127,7 +127,7 @@ sub _vol_remove {
return 1;
}
=head2 remove
=head2 removekvm_22_domain_kvm_base.ro.qcow2
Removes this domain. It removes also the disk drives and base images.
......@@ -146,13 +146,16 @@ sub remove {
eval { $self->remove_disks() };
warn "WARNING: Problem removing disks for ".$self->name." : $@" if $@;
$self->_remove_file_image();
eval { $self->_remove_file_image() };
warn "WARNING: Problem removing file image for ".$self->name." : $@" if $@;
# warn "WARNING: Problem removing ".$self->file_base_img." for ".$self->name
# ." , I will try again later : $@" if $@;
$self->domain->undefine();
$self->_remove_file_image();
eval { $self->_remove_file_image() };
warn "WARNING: Problem removing file image for ".$self->name." : $@" if $@;
$self->_remove_domain_db();
}
......@@ -164,10 +167,16 @@ sub _remove_file_image {
return if !$file || ! -e $file;
chmod 0770, $file or die "$! $file";
$self->_vol_remove($file,1);
unlink $file or die "$! $file" if -e $file;
$self->storage->refresh();
chmod 0770, $file or die "$! chmodding $file";
chown $<,$(,$file or die "$! chowning $file";
eval { $self->_vol_remove($file,1) };
if ( -e $file ) {
eval { unlink $file or die "$! $file" };
$self->storage->refresh();
}
return if ! -e $file;
warn $@ if $@;
}
sub _disk_device {
......
......@@ -16,8 +16,7 @@ my $RAVADA;
eval { $RAVADA = Ravada->new( connector => $test->connector) };
my ($DOMAIN_NAME) = $0 =~ m{.*/(.*/.*)\.};
$DOMAIN_NAME =~ s{/}{_}g;
my ($DOMAIN_NAME) = $0 =~ m{.*/(.*)\.};
my $DOMAIN_NAME_SON=$DOMAIN_NAME."_son";
$DOMAIN_NAME_SON =~ s/base_//;
......@@ -42,9 +41,10 @@ sub test_remove_domain {
eval { $domain->remove() };
ok(!$@ , "Error removing domain $name : $@") ;
ok(! -e $domain->file_base_img ,"Image file was not removed "
. $domain->file_base_img )
if $domain->file_base_img;
if ( $domain->file_base_img ) {
ok(! -e $domain->file_base_img ,"Image file was not removed "
.$domain->file_base_img )
}
}
$domain = $RAVADA->search_domain($name,1);
......
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