]> git.proxmox.com Git - pve-guest-common.git/commitdiff
PVE::ReplicationConfig::check_for_existing_jobs - new helper
authorDietmar Maurer <dietmar@proxmox.com>
Tue, 23 May 2017 15:52:30 +0000 (17:52 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Mon, 29 May 2017 05:33:38 +0000 (07:33 +0200)
We want to use that before removing a guest.

PVE/ReplicationConfig.pm

index a15b599a1f58c552675493a48912ce62c41e52d9..7b437f8dd5815ccaa8c29403c1dbb29480e6dd12 100644 (file)
@@ -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;