[pve-devel] [PATCH manager] refuse to create replication jobs for unreplicatable VMs

Wolfgang Bumiller w.bumiller at proxmox.com
Mon Jun 26 16:34:33 CEST 2017


---
Otherwise they'll notice it only once the job has been triggered...

 PVE/API2/Replication.pm       | 2 +-
 PVE/API2/ReplicationConfig.pm | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/PVE/API2/Replication.pm b/PVE/API2/Replication.pm
index 117fe57d..ddfc2d0e 100644
--- a/PVE/API2/Replication.pm
+++ b/PVE/API2/Replication.pm
@@ -20,7 +20,7 @@ use base qw(PVE::RESTHandler);
 
 my $pvesr_lock_path = "/var/lock/pvesr.lck";
 
-my $lookup_guest_class = sub {
+our $lookup_guest_class = sub {
     my ($vmtype) = @_;
 
     if ($vmtype eq 'qemu') {
diff --git a/PVE/API2/ReplicationConfig.pm b/PVE/API2/ReplicationConfig.pm
index f5523662..c5ae76f6 100644
--- a/PVE/API2/ReplicationConfig.pm
+++ b/PVE/API2/ReplicationConfig.pm
@@ -118,11 +118,16 @@ __PACKAGE__->register_method ({
 	my $nodelist = PVE::Cluster::get_members();
 	my $vmlist = PVE::Cluster::get_vmlist();
 
+	my $guest_info = $vmlist->{ids}->{$guest};
 	die "Guest '$guest' does not exists.\n"
-	    if !defined($vmlist->{ids}->{$guest});
+	    if !defined($guest_info);
 	die "Target '$param->{target}' does not exists.\n"
 	    if defined($param->{target}) && !defined($nodelist->{$param->{target}});
 
+	my $guest_class = $PVE::API2::Replication::lookup_guest_class->($guest_info->{type});
+	my $guest_conf = $guest_class->load_config($guest);
+	$guest_class->get_replicatable_volumes(PVE::Storage::config(), $guest, $guest_conf, 0, 0);
+
 	my $code = sub {
 	    my $cfg = PVE::ReplicationConfig->new();
 
-- 
2.11.0





More information about the pve-devel mailing list