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

refactor(requests): run request after_request (#1046)

issue #1045
parent ac249d5c
......@@ -1156,6 +1156,7 @@ sub _upgrade_tables {
$self->_upgrade_table('requests','at_time','int(11) DEFAULT NULL');
$self->_upgrade_table('requests','pid','int(11) DEFAULT NULL');
$self->_upgrade_table('requests','start_time','int(11) DEFAULT NULL');
$self->_upgrade_table('requests','after_request','int(11) DEFAULT NULL');
$self->_upgrade_table('requests','at_time','int(11) DEFAULT NULL');
$self->_upgrade_table('requests','run_time','float DEFAULT NULL');
......
......@@ -271,7 +271,7 @@ sub remove_domain {
my $self = {};
bless($self,$class);
return $self->_new_request(command => 'remove' , args => encode_json(\%args));
return $self->_new_request(command => 'remove' , args => \%args);
}
......@@ -330,7 +330,7 @@ sub start_clones {
my $self = {};
bless($self,$class);
return $self->_new_request(command => 'start_clones' , args => encode_json($args));
return $self->_new_request(command => 'start_clones' , args => $args);
}
=head2 pause_domain
......@@ -350,7 +350,7 @@ sub pause_domain {
my $self = {};
bless($self,$class);
return $self->_new_request(command => 'pause' , args => encode_json($args));
return $self->_new_request(command => 'pause' , args => $args);
}
=head2 resume_domain
......@@ -370,7 +370,7 @@ sub resume_domain {
my $self = {};
bless($self,$class);
return $self->_new_request(command => 'resume' , args => encode_json($args));
return $self->_new_request(command => 'resume' , args => $args);
}
......@@ -466,7 +466,7 @@ sub prepare_base {
return $self->_new_request(command => 'prepare_base'
, id_domain => $args{id_domain}
, args => encode_json( $args ));
, args => $args );
}
......@@ -496,7 +496,7 @@ sub remove_base {
my $req = $self->_new_request(command => 'remove_base'
, id_domain => $args->{id_domain}
, args => encode_json( $args ));
, args => $args );
return $req;
}
......@@ -561,6 +561,9 @@ sub _new_request {
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{after_request} = delete $args{args}->{after_request}
if exists $args{args}->{after_request};
}
$args{args} = encode_json($args{args});
}
......@@ -892,7 +895,7 @@ sub rename_domain {
return $self->_new_request(
command => 'rename_domain'
, id_domain => $args->{id_domain}
, args => encode_json($args)
, args => $args
);
}
......@@ -921,7 +924,7 @@ sub set_driver {
return $self->_new_request(
command => 'set_driver'
, id_domain => $args->{id_domain}
, args => encode_json($args)
, args => $args
);
}
......@@ -949,7 +952,7 @@ sub add_hardware {
return $self->_new_request(
command => 'add_hardware'
,id_domain => $args->{id_domain}
,args => encode_json($args)
,args => $args
);
}
......@@ -977,7 +980,7 @@ sub remove_hardware {
return $self->_new_request(
command => 'remove_hardware'
,id_domain => $args->{id_domain}
,args => encode_json($args)
,args => $args
);
}
......@@ -1008,7 +1011,7 @@ sub hybernate {
return $self->_new_request(
command => 'hybernate'
, id_domain => $args->{id_domain}
, args => encode_json($args)
, args => $args
);
}
......@@ -1031,7 +1034,7 @@ sub download {
return $self->_new_request(
command => 'download'
, args => encode_json($args)
, args => $args
);
}
......@@ -1182,7 +1185,7 @@ sub remove_base_vm {
return $self->_new_request(
command => 'remove_base_vm'
, args => encode_json($args)
, args => $args
);
}
......@@ -1574,6 +1577,13 @@ sub AUTOLOAD {
my $name = $AUTOLOAD;
$name =~ s/.*://;
if(!ref($self) && $VALID_ARG{$name} ) {
return _new_request($self
, command => $name
, args => _check_args($name, @_)
);
}
confess "Can't locate object method $name via package $self"
if !ref($self);
......
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