Commit 41ceaf60 authored by Francesc Guasch's avatar Francesc Guasch
Browse files

refactor(backend): properly check for missing volumes first

parent cbb93bb2
......@@ -894,6 +894,10 @@ sub _check_free_space_prepare_base($self) {
my $pool_base = $self->_vm->default_storage_pool_name;
$pool_base = $self->_vm->base_storage_pool() if $self->_vm->base_storage_pool();
for my $volume ($self->list_volumes(device => 'disk')) {;
next if !$volume;
die "Error: volume $volume is missing.\n" if !$self->_vm->file_exists($volume);
}
for my $volume ($self->list_volumes_info(device => 'disk')) {;
next if !$volume->file;
die "Error: volume ".$volume->file." is missing.\n" if !$self->_vm->file_exists($volume->file);
......
......@@ -614,13 +614,24 @@ sub disk_device {
return list_volumes(@_);
}
sub list_volumes($self, @args) {
my @vol = $self->list_volumes_info(@args);
my @vol2;
for (@vol) {
push @vol2,($_->{file});
sub list_volumes($self, $attribute=undef, $value=undef) {
my $data = $self->_load();
return () if !exists $data->{hardware}->{device};
my @vol;
my $n_order = 0;
for my $dev (@{$data->{hardware}->{device}}) {
next if exists $dev->{type}
&& $dev->{type} eq 'base';
if (exists $dev->{file} ) {
confess "Error loading $dev->{file} ".$@ if $@;
next if defined $attribute
&& (!exists $dev->{$attribute} || $dev->{$attribute} ne $value);
}
push @vol,($dev->{file});
}
return @vol2;
return @vol;
}
sub list_volumes_info($self, $attribute=undef, $value=undef) {
......
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