Skip to content

Commit

Permalink
Fix/network clone (#2019)
Browse files Browse the repository at this point in the history
fix(backend): assign network to clone
  • Loading branch information
frankiejol authored Feb 5, 2024
1 parent 35534f7 commit 298fc4f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
4 changes: 3 additions & 1 deletion lib/Ravada/Domain.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2875,6 +2875,7 @@ sub clone {
my $volatile = delete $args{volatile};
my $id_owner = delete $args{id_owner};
my $alias = delete $args{alias};
my $options = delete $args{options};

confess "ERROR: Unknown args ".join(",",sort keys %args)
if keys %args;
Expand Down Expand Up @@ -2908,6 +2909,7 @@ sub clone {
push @args_copy, ( remote_ip => $remote_ip) if $remote_ip;
push @args_copy, ( from_pool => $from_pool) if defined $from_pool;
push @args_copy, ( add_to_pool => $add_to_pool) if defined $add_to_pool;
push @args_copy, ( options => $options ) if defined $options;
if ( $self->volatile_clones && !defined $volatile ) {
$volatile = 1;
}
Expand Down Expand Up @@ -5316,7 +5318,7 @@ sub _pre_clone($self,%args) {

confess "ERROR: Missing user owner of new domain" if !$user;

for (qw(is_pool start add_to_pool from_pool with_cd volatile id_owner alias)) {
for (qw(is_pool start add_to_pool from_pool with_cd volatile id_owner alias options)) {
delete $args{$_};
}
confess "ERROR: Unknown arguments ".join(",",sort keys %args) if keys %args;
Expand Down
1 change: 1 addition & 0 deletions lib/Ravada/Request.pm
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ our %VALID_ARG = (
,start => 2,
,remote_ip => 2
,with_cd => 2
,options => 2
}
,change_owner => {uid => 1, id_domain => 1}
,add_hardware => {uid => 1, id_domain => 1, name => 1, number => 2, data => 2 }
Expand Down
3 changes: 3 additions & 0 deletions lib/Ravada/VM/KVM.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1262,6 +1262,9 @@ sub _domain_create_from_base {

_xml_modify_disk($xml, \@device_disk);#, \@swap_disk);

my $network = $args{options}->{network};
$self->_xml_set_network($xml, $network) if $network;

my ($domain, $spice_password)
= $self->_domain_create_common($xml,%args, is_volatile=>$volatile, base => $base);
$domain->_insert_db(name=> $args{name}, id_base => $base->id, id_owner => $args{id_owner}
Expand Down
19 changes: 17 additions & 2 deletions t/vm/networking.t
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ sub test_assign_network($vm, $net) {
network => $net->{name}
}
);
wait_request(debug => 1);
wait_request(debug => 0);

my $domain = rvd_back->search_domain($name);
ok($domain);
Expand Down Expand Up @@ -419,11 +419,26 @@ sub test_assign_network_clone($vm, $net, $volatile) {
,options => { network => $net->{name}}
,name => $name_clone
);
wait_request(debug => 1);
wait_request(debug => 0);
my $clone = rvd_back->search_domain($name_clone);
ok($clone);

_check_domain_network($clone, $net->{name});

my $name_clone3 = new_domain_name();
my $req3 = Ravada::Request->clone(
id_domain => $domain->id
,uid => user_admin->id
,options => { network => $net->{name}}
,name => $name_clone3
);
wait_request(debug => 0);
my $clone3 = rvd_back->search_domain($name_clone3);
ok($clone3);

_check_domain_network($clone, $net->{name});

remove_domain($domain);
}

sub _check_domain_network_kvm($domain, $net_name) {
Expand Down

0 comments on commit 298fc4f

Please sign in to comment.