[pve-devel] applied: [PATCH cluster v2] add get_local_migration_ip method

Dietmar Maurer dietmar at proxmox.com
Fri Oct 28 12:14:32 CEST 2016


applied with small modifications (see below):

> Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
> ---
>  data/PVE/Cluster.pm | 29 +++++++++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> diff --git a/data/PVE/Cluster.pm b/data/PVE/Cluster.pm
> index 893dbe0..c69f339 100644
> --- a/data/PVE/Cluster.pm
> +++ b/data/PVE/Cluster.pm
> @@ -16,6 +16,7 @@ use PVE::INotify;
>  use PVE::IPCC;
>  use PVE::SafeSyslog;
>  use PVE::JSONSchema;
> +use PVE::Network;
>  use JSON;
>  use RRDs;
>  use Encode;
> @@ -1048,6 +1049,34 @@ sub remote_node_ip {
>      return wantarray ? ($ip, $family) : $ip;
>  }
>  
> +sub get_local_migration_ip {
> +    my ($migration_network, $noerr) = @_;
> +
> +    my $ip;
> +    my $cidr = $migration_network;
> +
> +    if (!defined($cidr)) {
> +	my $dc_conf = cfs_read_file('datacenter.cfg');
> +	$cidr = $dc_conf->{migration}->{network}
> +	  if defined($dc_conf->{migration}->{network});
> +    }
> +
> +    if (defined($cidr)) {
> +	my $ips = PVE::Network::get_local_ip_from_cidr($cidr);
> +
> +	die "no IP address configured on local node for the '$cidr' " .
> +	  " sub network\n" if !$noerr && (scalar(@$ips) == 0);
> +
> +	warn "multiple IP address configured for the '$cidr' sub network," .
> +	  "selecting the first found!\n" if !$noerr && (scalar(@$ips) > 1);

I simplified error messages, and use 'die' instead of 'warn'.

> +

return @$ips[0];

> +	$ip = @$ips[0];
> +	$ip = "[$ip]" if $ip && Net::IP::ip_is_ipv6($ip);

this makes no sense here, so I removed that.




More information about the pve-devel mailing list