[pve-devel] [PATCHV2 pve-manager Add job creation checks] Add job creation checks.
Wolfgang Link
w.link at proxmox.com
Tue Jun 6 08:14:43 CEST 2017
We must know if the target and guest exists to avoid creation faulty jobs.
---
PVE/API2/ReplicationConfig.pm | 9 +++++++++
1 file changed, 9 insertions(+)
V2 remove the abstraction in pve-guest- common and check directly.
diff --git a/PVE/API2/ReplicationConfig.pm b/PVE/API2/ReplicationConfig.pm
index 69d56aed..9bc4fd3b 100644
--- a/PVE/API2/ReplicationConfig.pm
+++ b/PVE/API2/ReplicationConfig.pm
@@ -8,6 +8,7 @@ use PVE::Exception qw(raise_perm_exc raise_param_exc);
use PVE::JSONSchema qw(get_standard_option);
use PVE::RPCEnvironment;
use PVE::ReplicationConfig;
+use PVE::Cluster;
use PVE::RESTHandler;
@@ -109,6 +110,14 @@ __PACKAGE__->register_method ({
my $plugin = PVE::ReplicationConfig->lookup($type);
my $id = extract_param($param, 'id');
+ my $nodelist = PVE::Cluster::get_members();
+ my $vmlist = PVE::Cluster::get_vmlist();
+
+ die "Guest does not exists\n"
+ if !defined($vmlist->{ids}->{$param->{guest}});
+ die "Target does not exists\n"
+ if !defined($nodelist->{$param->{target}});
+
my $code = sub {
my $cfg = PVE::ReplicationConfig->new();
--
2.11.0
More information about the pve-devel
mailing list