[pve-devel] [PATCH v2] check_vmid_unused message change

Dietmar Maurer dietmar at proxmox.com
Wed Sep 23 07:55:44 CEST 2015


applied, but simplified the code:

     my $vmtypestr =  $d->{type} eq 'qemu' ? 'VM' : 'CT';
     die "$vmtypestr $vmid already exists on node '$d->{node}'";


On 09/22/2015 04:21 PM, Alen Grizonic wrote:
> changed message if vmid used on a different cluster node
> ---
>   data/PVE/Cluster.pm | 14 +++++++++++---
>   1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/data/PVE/Cluster.pm b/data/PVE/Cluster.pm
> index 63780ac..5860ed9 100644
> --- a/data/PVE/Cluster.pm
> +++ b/data/PVE/Cluster.pm
> @@ -977,15 +977,23 @@ sub check_vmid_unused {
>       my ($vmid, $noerr) = @_;
>       
>       my $vmlist = get_vmlist();
> +    my $node = PVE::INotify::nodename();
>   
>       my $d = $vmlist->{ids}->{$vmid};
>       return 1 if !defined($d);
>       
>       return undef if $noerr;
>   
> -    die "VM $vmid already exists\n" if $d->{type} eq 'qemu';
> -
> -    die "CT $vmid already exists\n";
> +    my $msg = "$vmid already exists";
> +    my $msg_cluster = "$msg on cluster node '$d->{node}'";
> +
> +    if ($d->{node} eq $node) {
> +	die "VM $msg\n" if $d->{type} eq 'qemu';
> +	die "CT $msg\n";
> +    } else {
> +        die "VM $msg_cluster\n" if $d->{type} eq 'qemu';
> +        die "CT $msg_cluster\n";
> +    }
>   }
>   
>   sub check_node_exists {





More information about the pve-devel mailing list