public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH pve-manager]: api2:/cluster return intiger format for VMID
@ 2020-12-01  9:34 Moayad Almalat
  2020-12-01  9:41 ` Aaron Lauterer
  2020-12-01  9:41 ` Dietmar Maurer
  0 siblings, 2 replies; 5+ messages in thread
From: Moayad Almalat @ 2020-12-01  9:34 UTC (permalink / raw)
  To: pve-devel


When call /cluster/nextid over API, it returns ID as a string format
like {"data":"100"}. in the API pve-viewer, the result type is an integer
format.

Signed-off-by: Moayad Almalat <m.almalat@proxmox.com>
---
 PVE/API2/Cluster.pm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/PVE/API2/Cluster.pm b/PVE/API2/Cluster.pm
index bf0e3b4d..ab07b491 100644
--- a/PVE/API2/Cluster.pm
+++ b/PVE/API2/Cluster.pm
@@ -727,7 +727,7 @@ __PACKAGE__->register_method({
 	}
 
 	for (my $i = 100; $i < 10000; $i++) {
-	    return $i if !defined($idlist->{$i});
+	    return int($i) if !defined($idlist->{$i});
 	}
 
 	die "unable to get any free VMID\n";
-- 
2.20.1




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [pve-devel] [PATCH pve-manager]: api2:/cluster return intiger format for VMID
  2020-12-01  9:34 [pve-devel] [PATCH pve-manager]: api2:/cluster return intiger format for VMID Moayad Almalat
@ 2020-12-01  9:41 ` Aaron Lauterer
  2020-12-01  9:41 ` Dietmar Maurer
  1 sibling, 0 replies; 5+ messages in thread
From: Aaron Lauterer @ 2020-12-01  9:41 UTC (permalink / raw)
  To: Proxmox VE development discussion, Moayad Almalat

After taking a quick look, isn't there another instance just above in the code on line 720 which would benefit from the same change?

---------
	if (my $vmid = $param->{vmid}) {
	    return $vmid if !defined($idlist->{$vmid});
                    ^^^^^
	    raise_param_exc({ vmid => "VM $vmid already exists" });
	}
---------

Cheers!


On 12/1/20 10:34 AM, Moayad Almalat wrote:
> 
> When call /cluster/nextid over API, it returns ID as a string format
> like {"data":"100"}. in the API pve-viewer, the result type is an integer
> format.
> 
> Signed-off-by: Moayad Almalat <m.almalat@proxmox.com>
> ---
>   PVE/API2/Cluster.pm | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/PVE/API2/Cluster.pm b/PVE/API2/Cluster.pm
> index bf0e3b4d..ab07b491 100644
> --- a/PVE/API2/Cluster.pm
> +++ b/PVE/API2/Cluster.pm
> @@ -727,7 +727,7 @@ __PACKAGE__->register_method({
>   	}
>   
>   	for (my $i = 100; $i < 10000; $i++) {
> -	    return $i if !defined($idlist->{$i});
> +	    return int($i) if !defined($idlist->{$i});
>   	}
>   
>   	die "unable to get any free VMID\n";
> 




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [pve-devel] [PATCH pve-manager]: api2:/cluster return intiger format for VMID
  2020-12-01  9:34 [pve-devel] [PATCH pve-manager]: api2:/cluster return intiger format for VMID Moayad Almalat
  2020-12-01  9:41 ` Aaron Lauterer
@ 2020-12-01  9:41 ` Dietmar Maurer
  2020-12-01  9:42   ` Dietmar Maurer
  1 sibling, 1 reply; 5+ messages in thread
From: Dietmar Maurer @ 2020-12-01  9:41 UTC (permalink / raw)
  To: Proxmox VE development discussion, Moayad Almalat, pve-devel

>  	for (my $i = 100; $i < 10000; $i++) {
> -	    return $i if !defined($idlist->{$i});
> +	    return int($i) if !defined($idlist->{$i});

IMO, this does not solve the problem, because $i is already and int.




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [pve-devel] [PATCH pve-manager]: api2:/cluster return intiger format for VMID
  2020-12-01  9:41 ` Dietmar Maurer
@ 2020-12-01  9:42   ` Dietmar Maurer
  2020-12-01 10:38     ` Stefan Reiter
  0 siblings, 1 reply; 5+ messages in thread
From: Dietmar Maurer @ 2020-12-01  9:42 UTC (permalink / raw)
  To: Proxmox VE development discussion, Moayad Almalat, pve-devel


> On 12/01/2020 10:41 AM Dietmar Maurer <dietmar@proxmox.com> wrote:
> 
>  
> >  	for (my $i = 100; $i < 10000; $i++) {
> > -	    return $i if !defined($idlist->{$i});
> > +	    return int($i) if !defined($idlist->{$i});
> 
> IMO, this does not solve the problem, because $i is already and int.

or does $idlist->{$i} converts $i to string??




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [pve-devel] [PATCH pve-manager]: api2:/cluster return intiger format for VMID
  2020-12-01  9:42   ` Dietmar Maurer
@ 2020-12-01 10:38     ` Stefan Reiter
  0 siblings, 0 replies; 5+ messages in thread
From: Stefan Reiter @ 2020-12-01 10:38 UTC (permalink / raw)
  To: Proxmox VE development discussion, Dietmar Maurer,
	Moayad Almalat, pve-devel

On 01/12/2020 10:42, Dietmar Maurer wrote:
> 
>> On 12/01/2020 10:41 AM Dietmar Maurer <dietmar@proxmox.com> wrote:
>>
>>   
>>>   	for (my $i = 100; $i < 10000; $i++) {
>>> -	    return $i if !defined($idlist->{$i});
>>> +	    return int($i) if !defined($idlist->{$i});
>>
>> IMO, this does not solve the problem, because $i is already and int.
> 
> or does $idlist->{$i} converts $i to string??
> 

Without testing anything, just my two cents, but we previously had the 
issue where the JSON formatter in Perl would format a value based on 
it's last usage context - and in case of a hash access that's probably a 
string, even if $i "is" an int.




^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-12-01 10:38 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-01  9:34 [pve-devel] [PATCH pve-manager]: api2:/cluster return intiger format for VMID Moayad Almalat
2020-12-01  9:41 ` Aaron Lauterer
2020-12-01  9:41 ` Dietmar Maurer
2020-12-01  9:42   ` Dietmar Maurer
2020-12-01 10:38     ` Stefan Reiter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal