Commit 0259b733 authored by Francesc Guasch's avatar Francesc Guasch
Browse files

fix(backend): set display ip on start

parent 6c4a32e0
......@@ -3467,7 +3467,7 @@ sub set_driver_id {
$sth->finish;
}
sub _listen_ip($self, $remote_ip) {
sub _listen_ip($self, $remote_ip=undef) {
return $self->_vm->listen_ip($remote_ip);
}
......
......@@ -611,10 +611,8 @@ sub display_info($self, $user) {
my ($tls_port) = $graph->getAttribute('tlsPort');
my ($address) = $graph->getAttribute('listen');
confess "ERROR: Machine ".$self->name." is not active in node ".$self->_vm->name."\n"
warn "ERROR: Machine ".$self->name." is not active in node ".$self->_vm->name."\n"
if !$port && !$self->is_active;
die "Unable to get port for domain ".$self->name." ".$graph->toString
if !$port;
my $display = $type."://$address:$port";
......@@ -672,7 +670,7 @@ sub start {
my $remote_ip = delete $arg{remote_ip};
my $request = delete $arg{request};
my $display_ip;
my $display_ip = $self->_listen_ip();
if ($remote_ip) {
$set_password = 0;
my $network = Ravada::Network->new(address => $remote_ip);
......@@ -2088,6 +2086,7 @@ sub migrate($self, $node, $request=undef) {
#dom already in remote node
$self->domain($dom);
} else {
$self->_set_spice_ip(1, $node->ip);
my $xml = $self->domain->get_xml_description();
my $doc = XML::LibXML->load_xml(string => $xml);
......
......@@ -601,6 +601,7 @@ sub hibernate($self, $user) {
sub type { 'Void' }
sub migrate($self, $node, $request=undef) {
$self->_set_display($node->ip);
my $config_remote;
$config_remote = $self->_load();
my $device = $config_remote->{hardware}->{device}
......
......@@ -277,10 +277,42 @@ sub test_set_vm($vm, $node) {
is($base_f->list_instances,2) or exit;
test_bind_ip($node, $base,'1.2.3.4');
test_bind_ip($node, $base);
$base->remove(user_admin);
is(scalar($base->list_instances),undef);
}
sub test_bind_ip($node, $base, $remote_ip=undef) {
my @clone;
my $clone_2;
my @remote_ip;
@remote_ip = ( remote_ip => $remote_ip ) if $remote_ip;
for (1 .. 20) {
my $clone= $base->clone( user => user_admin, name => new_domain_name);
if ($clone->type eq 'KVM') {
$clone->_set_spice_ip(undef,'2.3.4.5');
my $cloneb = Ravada::Domain->open($clone->id);
}
my $req = Ravada::Request->start_domain(uid => user_admin->id
,id_domain => $clone->id
,@remote_ip
);
wait_request();
is($req->status,'done');
is($req->error, '');
push @clone,($clone);
$clone_2 = Ravada::Domain->open($clone->id);
last if $clone_2->_vm->id == $node->id;
}
my $node_ip = $node->ip;
is($clone_2->_vm->id, $node->id) or exit;
like($clone_2->display(user_admin),qr($node_ip)) or exit;
for (@clone) {
$_->remove(user_admin);
}
}
sub test_instances($clone, $expected) {
confess;
my @instances = $clone->list_instances();
......
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