Unverified Commit bc93c561 authored by Francesc Guasch's avatar Francesc Guasch Committed by GitHub
Browse files

Fix locked in admin machines (#1336)

fix(frontend): update domain status after request

add test in 30_hardware.t

issue #1333
parent 03dc27f8
......@@ -2565,6 +2565,20 @@ sub _do_execute_command {
if $request->status() ne 'done'
&& $request->status() !~ /^retry/i;
}
$self->_set_domain_changed($request) if $request->status eq 'done';
}
sub _set_domain_changed($self, $request) {
my $id_domain = $request->id_domain;
if (!defined $id_domain) {
$id_domain = $request->defined_arg('id_domain');
}
return if !defined $id_domain;
my $sth = $CONNECTOR->dbh->prepare("UPDATE domains set date_changed=CURRENT_TIMESTAMP"
." WHERE id=? ");
$sth->execute($id_domain);
}
sub _cmd_manage_pools($self, $request) {
......
......@@ -29,6 +29,8 @@ my %CREATE_ARGS = (
,Void => { id_owner => $USER->id }
);
my $TEST_TIMESTAMP = 0;
########################################################################
sub create_args {
my $backend = shift;
......@@ -68,6 +70,9 @@ sub test_add_hardware_request_drivers {
sub test_add_hardware_request($vm, $domain, $hardware, $data={}) {
confess if !ref($data) || ref($data) ne 'HASH';
my $date_changed = $domain->_data('date_changed');
my @list_hardware1 = $domain->get_controller($hardware);
my $numero = scalar(@list_hardware1)+1;
while ($hardware eq 'usb' && $numero > 4) {
......@@ -87,6 +92,7 @@ sub test_add_hardware_request($vm, $domain, $hardware, $data={}) {
is($@,'') or return;
$USER->unread_messages();
ok($req, 'Request');
sleep 1 if !$TEST_TIMESTAMP;
rvd_back->_process_all_requests_dont_fork();
is($req->status(),'done');
is($req->error(),'') or exit;
......@@ -117,6 +123,9 @@ sub test_add_hardware_request($vm, $domain, $hardware, $data={}) {
} elsif($hardware eq 'disk') {
like($new_hardware->{file},qr(\.iso$)) or die Dumper($info->{hardware}->{$hardware});
}
if (!$TEST_TIMESTAMP++) {
isnt($domain->_data('date_changed'), $date_changed);
}
}
sub test_add_cdrom($domain) {
......@@ -639,6 +648,7 @@ for my $vm_name ( qw(Void KVM )) {
ok(!$domain_b->is_active);
}
ok($TEST_TIMESTAMP);
}
end();
......
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