[pve-devel] applied: [PATCH manager 1/2] pve5to6: add IP check to misc

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Jun 27 19:40:12 CEST 2019


On 6/27/19 3:45 PM, Mira Limbeck wrote:
> Adds the same check we run in pve-cluster before joining a node to make
> sure the hostname resolves to a configured IP.
> 
> Signed-off-by: Mira Limbeck <m.limbeck at proxmox.com>
> ---
>  PVE/CLI/pve5to6.pm | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/PVE/CLI/pve5to6.pm b/PVE/CLI/pve5to6.pm
> index cb27fd63..65552a35 100644
> --- a/PVE/CLI/pve5to6.pm
> +++ b/PVE/CLI/pve5to6.pm
> @@ -366,6 +366,17 @@ sub check_misc {
>  	if defined($cts);
>      log_warn("$running_guests running guests detected - consider migrating/stopping them.")
>  	if $running_guests > 0;
> +
> +    my $host = PVE::INotify::nodename();
> +    my $local_ip = eval { PVE::Network::get_ip_from_hostname($host) };
> +    if ($@) {
> +	log_warn("Failed to resolve hostname to IP - $@");
> +    } else {
> +	my $cidr = Net::IP::ip_is_ipv6($local_ip) ? "$local_ip/128" : "$local_ip/32";
> +	my $configured_ips = PVE::Network::get_local_ip_from_cidr($cidr);
> +	my $ip_count = scalar(@$configured_ips);
> +	log_warn("IP must be configured exactly once on local node - defined $ip_count times") if ($ip_count != 1);
> +    }
>  }
>  
>  __PACKAGE__->register_method ({
> 

applied, with some followup, i.e., I tried to be a bit conciser about
what got checked and split the no and multiple IP configured in different
error messages.




More information about the pve-devel mailing list