Commit 4d456bf4 authored by Francesc Guasch's avatar Francesc Guasch
Browse files

[#315] shutdown called by id_domain instead name

parent a42dc1d0
......@@ -1801,7 +1801,7 @@ sub _cmd_shutdown {
my $user = Ravada::Auth::SQL->search_by_id( $uid);
$domain->shutdown(timeout => $timeout, id_domain => $id_domain, user => $user
$domain->shutdown(timeout => $timeout, user => $user
, request => $request);
}
......
......@@ -1027,6 +1027,7 @@ sub _pre_shutdown {
my $user = delete $arg{user};
delete $arg{timeout};
delete $arg{request};
confess "Unknown args ".join(",",sort keys %arg)
if keys %arg;
......@@ -1037,7 +1038,6 @@ sub _pre_shutdown {
$self->_pre_shutdown_domain();
if ($self->is_paused) {
my %args = @_;
$self->resume(user => $user);
}
}
......@@ -1059,7 +1059,7 @@ sub _post_shutdown {
}
my $req = Ravada::Request->force_shutdown_domain(
name => $self->name
id_domain => $self->id
, uid => $arg{user}->id
, at => time+$timeout
);
......
......@@ -576,7 +576,7 @@ Shuts down uncleanly the domain
sub force_shutdown{
my $self = shift;
$self->_do_force_shutdown();
return $self->_do_force_shutdown() if $self->is_active;
}
sub _do_force_shutdown {
......
......@@ -60,7 +60,6 @@ sub display {
sub is_active {
my $self = shift;
return ($self->_value('is_active') or 0);
}
......
......@@ -421,8 +421,13 @@ sub _new_request {
$args{args}->{uid} = $args{args}->{id_owner}
if !exists $args{args}->{uid};
$args{at_time} = $args{args}->{at} if exists $args{args}->{at};
$args{id_domain} = $args{args}->{id_domain}
if exists $args{args}->{id_domain} && ! $args{id_domain};
my $id_domain_args = $args{args}->{id_domain};
if ($id_domain_args) {
confess "ERROR: Different id_domain: ".Dumper(\%args)
if $args{id_domain} && $args{id_domain} ne $id_domain_args;
$args{id_domain} = $id_domain_args;
}
$args{args} = encode_json($args{args});
}
_init_connector() if !$CONNECTOR || !$$CONNECTOR;
......
......@@ -1312,7 +1312,7 @@ sub manage_machine {
return access_denied($c) if $domain->id_owner != $USER->id
&& !$USER->is_admin;
Ravada::Request->shutdown_domain(name => $domain->name, uid => $USER->id) if $c->param('shutdown');
Ravada::Request->shutdown_domain(id_domain => $domain->id, uid => $USER->id) if $c->param('shutdown');
Ravada::Request->start_domain( uid => $USER->id
,name => $domain->name
, remote_ip => _remote_ip($c)
......@@ -1337,7 +1337,7 @@ sub settings_machine {
$c->stash(domain => $domain);
$c->stash(USER => $USER);
my $req = Ravada::Request->shutdown_domain(name => $domain->name, uid => $USER->id)
my $req = Ravada::Request->shutdown_domain(id_domain => $domain->id, uid => $USER->id)
if $c->param('shutdown') && $domain->is_active;
$req = Ravada::Request->start_domain(
......@@ -1433,7 +1433,7 @@ sub shutdown_machine {
return login($c) if !_logged_in($c);
my ($domain, $type) = _search_requested_machine($c);
my $req = Ravada::Request->shutdown_domain(name => $domain->name, uid => $USER->id);
my $req = Ravada::Request->shutdown_domain(id_domain => $domain->id, uid => $USER->id);
return $c->redirect_to('/machines') if $type eq 'html';
return $c->render(json => { req => $req->id });
......
......@@ -111,8 +111,10 @@ sub test_start {
ok($req2->status eq 'done',"Expecting request status 'done' , got "
.$req2->status);
my $id_domain;
{
my $domain = $RAVADA->search_domain($name);
$id_domain = $domain->id;
$domain->start($USER) if !$domain->is_active();
ok($domain->is_active);
......@@ -127,7 +129,7 @@ sub test_start {
#
# stop
my $req3 = Ravada::Request->force_shutdown_domain(name => $name, uid => $USER->id);
my $req3 = Ravada::Request->force_shutdown_domain(id_domain => $id_domain, uid => $USER->id);
$RAVADA->process_requests();
wait_request($req3);
ok($req3->status eq 'done',"[$vm_name] expecting request done , got "
......
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