]> git.proxmox.com Git - pve-cluster.git/blobdiff - data/PVE/CLI/pvecm.pm
error out when getting remote ip address fails
[pve-cluster.git] / data / PVE / CLI / pvecm.pm
index 624c09613847118be27c56d48d686a716ff09f8b..f5d5422eac91da581d20bc5838cc68fb31898693 100755 (executable)
@@ -841,7 +841,20 @@ __PACKAGE__->register_method ({
     description => "Used by VM/CT migration - do not use manually.",
     parameters => {
        additionalProperties => 0,
-       properties => {},
+       properties => {
+           get_migration_ip => {
+               type => 'boolean',
+               default => 0,
+               description => 'return the migration IP, if configured',
+               optional => 1,
+           },
+           migration_network => {
+               type => 'string',
+               format => 'CIDR',
+               description => 'the migration network used to detect the local migration IP',
+               optional => 1,
+           },
+       },
     },
     returns => { type => 'null'},
     code => sub {
@@ -852,6 +865,17 @@ __PACKAGE__->register_method ({
            return undef;
        }
 
+       if ($param->{get_migration_ip}) {
+           my $network = $param->{migration_network};
+           if (my $ip = PVE::Cluster::get_local_migration_ip($network)) {
+               print "ip: '$ip'\n";
+           } else {
+               print "no ip\n";
+           }
+           # do not keep tunnel open when asked for migration ip
+           return undef;
+       }
+
        print "tunnel online\n";
        *STDOUT->flush();