[pve-devel] [PATCH cluster v2] error out when getting remote ip address fails

Dietmar Maurer dietmar at proxmox.com
Fri Nov 11 06:35:02 CET 2016


comments inline:

> Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
> ---
>  data/PVE/CLI/pvecm.pm | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/data/PVE/CLI/pvecm.pm b/data/PVE/CLI/pvecm.pm
> index 65a063d..04c7462 100755
> --- a/data/PVE/CLI/pvecm.pm
> +++ b/data/PVE/CLI/pvecm.pm
> @@ -867,10 +867,17 @@ __PACKAGE__->register_method ({
>  
>  	if ($param->{get_migration_ip}) {
>  	    my $network = $param->{migration_network};
> -	    if (my $ip = PVE::Cluster::get_local_migration_ip($network, 1)) {
> +
> +	    my $ip;
> +	    eval { $ip = PVE::Cluster::get_local_migration_ip($network); };
> +	    my $err = $@;
> +
> +	    if ($err) {
> +		die "could not get migration ip: $err\n";

Why don't you simply generate a reasonable error message 
inside get_local_migration_ip()? Then you can simply write:

my $ip = PVE::Cluster::get_local_migration_ip($network);

no need for eval/die at all!

> +	    } elsif (defined($ip)) {
>  		print "ip: '$ip'\n";
>  	    } else {
> -		print "no ip\n"
> +		print "no ip\n";
>  	    }
>  	    # do not keep tunnel open when asked for migration ip
>  	    return undef;
> -- 
> 2.1.4
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel




More information about the pve-devel mailing list