[pve-devel] [PATCH v2 pve-guest-common 3/5] PVE::ReplicationConfig::check_for_existing_jobs - new helper
Dietmar Maurer
dietmar at proxmox.com
Tue May 30 15:12:33 CEST 2017
We want to use that before removing a guest.
Signed-off-by: Dietmar Maurer <dietmar at proxmox.com>
---
PVE/ReplicationConfig.pm | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/PVE/ReplicationConfig.pm b/PVE/ReplicationConfig.pm
index a15b599..7b437f8 100644
--- a/PVE/ReplicationConfig.pm
+++ b/PVE/ReplicationConfig.pm
@@ -164,6 +164,21 @@ sub lock {
}
}
+sub check_for_existing_jobs {
+ my ($cfg, $vmid, $noerr) = @_;
+
+ foreach my $id (keys %{$cfg->{ids}}) {
+ my $data = $cfg->{ids}->{$id};
+
+ if ($data->{guest} == $vmid) {
+ return 1 if $noerr;
+ die "There is a replication job '$id' for guest '$vmid' - " .
+ "Please remove that first.\n"
+ }
+ }
+
+ return undef;
+}
package PVE::ReplicationConfig::Cluster;
--
2.11.0
More information about the pve-devel
mailing list