Commit fad874f3 authored by frankiejol's avatar frankiejol
Browse files

refactor(backend): allow set VM disabled

parent 913a847b
......@@ -9,7 +9,7 @@ use Carp qw(carp croak);
use Data::Dumper;
use DBIx::Connector;
use File::Copy;
use Hash::Util qw(lock_hash);
use Hash::Util qw(unlock_hash lock_hash);
use JSON::XS;
use Moose;
use POSIX qw(WNOHANG);
......@@ -1653,16 +1653,19 @@ sub _init_config {
sub _init_config_vm {
for my $vm ( @{$CONFIG->{vm}} ) {
die "$vm not available in this system.\n".($ERROR_VM{$vm})
confess "$vm not available in this system.\n".($ERROR_VM{$vm})
if !exists $VALID_VM{$vm} || !$VALID_VM{$vm};
}
for my $vm ( keys %VALID_VM ) {
delete $VALID_VM{$vm}
if exists $VALID_VM{$vm}
if ( exists $VALID_VM{$vm}
&& exists $CONFIG->{vm}
&& scalar @{$CONFIG->{vm}}
&& !grep /^$vm$/,@{$CONFIG->{vm}};
&& !grep /^$vm$/,@{$CONFIG->{vm}}) {
unlock_hash(%VALID_VM);
delete $VALID_VM{$vm};
lock_hash(%VALID_VM);
}
}
lock_hash(%VALID_VM);
......
......@@ -150,15 +150,16 @@ sub test_nat($vm_name) {
$domain->remove(user_admin);
unlink($file_config);
DumpFile($file_config,{ vm => \@VMS });
$rvd_back = Ravada->new(
connector => connector()
, config => $FILE_CONFIG
, config => $file_config
, warn_error => 0
);
rvd_back($FILE_CONFIG);
rvd_back($file_config);
unlink($file_config);
}
sub test_chain($vm_name, %args) {
......@@ -199,7 +200,7 @@ for my $vm_name ( @VMS ) {
my $vm;
init( $FILE_CONFIG );
{ $vm = rvd_back->search_vm($vm_name) };
eval { $vm = rvd_back->search_vm($vm_name) };
SKIP: {
my $msg = "SKIPPED test: No $vm_name VM found ".($@ or '');
......
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