public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH storage] esxi: use mac address when static, generated and vpx
@ 2024-03-26 11:03 Aaron Lauterer
  2024-03-26 11:36 ` Thomas Lamprecht
  0 siblings, 1 reply; 3+ messages in thread
From: Aaron Lauterer @ 2024-03-26 11:03 UTC (permalink / raw)
  To: pve-devel

static -> defined manually
generated -> by ESXi
vpx -> generated by vCenter

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
---
 src/PVE/Storage/ESXiPlugin.pm | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/PVE/Storage/ESXiPlugin.pm b/src/PVE/Storage/ESXiPlugin.pm
index 77fb6c0..c5ddfea 100644
--- a/src/PVE/Storage/ESXiPlugin.pm
+++ b/src/PVE/Storage/ESXiPlugin.pm
@@ -793,7 +793,10 @@ sub for_each_netdev {
 
 	my $ty = $dev->{addressType};
 	my $mac = $dev->{address};
-	if ($ty && fc($ty) eq fc('generated')) {
+	if ($ty && (fc($ty) eq fc('static')
+		|| fc($ty) eq fc('generated')
+		|| fc($ty) eq fc('vpx') # vCenter generated
+	    )) {
 	    $mac = $dev->{generatedAddress} // $mac;
 	}
 
-- 
2.39.2





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

* Re: [pve-devel] [PATCH storage] esxi: use mac address when static, generated and vpx
  2024-03-26 11:03 [pve-devel] [PATCH storage] esxi: use mac address when static, generated and vpx Aaron Lauterer
@ 2024-03-26 11:36 ` Thomas Lamprecht
  2024-03-26 12:06   ` Aaron Lauterer
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Lamprecht @ 2024-03-26 11:36 UTC (permalink / raw)
  To: Proxmox VE development discussion, Aaron Lauterer

Am 26/03/2024 um 12:03 schrieb Aaron Lauterer:
> static -> defined manually
> generated -> by ESXi
> vpx -> generated by vCenter

nice!

> Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
> ---
>  src/PVE/Storage/ESXiPlugin.pm | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/src/PVE/Storage/ESXiPlugin.pm b/src/PVE/Storage/ESXiPlugin.pm
> index 77fb6c0..c5ddfea 100644
> --- a/src/PVE/Storage/ESXiPlugin.pm
> +++ b/src/PVE/Storage/ESXiPlugin.pm
> @@ -793,7 +793,10 @@ sub for_each_netdev {
>  
>  	my $ty = $dev->{addressType};
>  	my $mac = $dev->{address};
> -	if ($ty && fc($ty) eq fc('generated')) {
> +	if ($ty && (fc($ty) eq fc('static')
> +		|| fc($ty) eq fc('generated')
> +		|| fc($ty) eq fc('vpx') # vCenter generated

To compare the same string to different allowed values in Perl we
generally prefer to either use a hash map with known OK values as keys,
or alternatively a regex, e.g.:

if (fc($ty) =~ /^(static|generated|vpx)$/) {
    # ...
}

If there are only a ~ handful of different option, like here, this is
still easy to read but avoids some line bloat.

If you want you can send a v2, else I can also change this on applying?

> +	    )) {
>  	    $mac = $dev->{generatedAddress} // $mac;
>  	}
>  





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

* Re: [pve-devel] [PATCH storage] esxi: use mac address when static, generated and vpx
  2024-03-26 11:36 ` Thomas Lamprecht
@ 2024-03-26 12:06   ` Aaron Lauterer
  0 siblings, 0 replies; 3+ messages in thread
From: Aaron Lauterer @ 2024-03-26 12:06 UTC (permalink / raw)
  To: Thomas Lamprecht, Proxmox VE development discussion

sent a v2, unfortunately also one a bit too quickly (with no changes). 
please ignore that one :)

On  2024-03-26  12:36, Thomas Lamprecht wrote:
> Am 26/03/2024 um 12:03 schrieb Aaron Lauterer:
>> static -> defined manually
>> generated -> by ESXi
>> vpx -> generated by vCenter
> 
> nice!
> 
>> Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
>> ---
>>   src/PVE/Storage/ESXiPlugin.pm | 5 ++++-
>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/src/PVE/Storage/ESXiPlugin.pm b/src/PVE/Storage/ESXiPlugin.pm
>> index 77fb6c0..c5ddfea 100644
>> --- a/src/PVE/Storage/ESXiPlugin.pm
>> +++ b/src/PVE/Storage/ESXiPlugin.pm
>> @@ -793,7 +793,10 @@ sub for_each_netdev {
>>   
>>   	my $ty = $dev->{addressType};
>>   	my $mac = $dev->{address};
>> -	if ($ty && fc($ty) eq fc('generated')) {
>> +	if ($ty && (fc($ty) eq fc('static')
>> +		|| fc($ty) eq fc('generated')
>> +		|| fc($ty) eq fc('vpx') # vCenter generated
> 
> To compare the same string to different allowed values in Perl we
> generally prefer to either use a hash map with known OK values as keys,
> or alternatively a regex, e.g.:
> 
> if (fc($ty) =~ /^(static|generated|vpx)$/) {
>      # ...
> }
> 
> If there are only a ~ handful of different option, like here, this is
> still easy to read but avoids some line bloat.
> 
> If you want you can send a v2, else I can also change this on applying?
> 
>> +	    )) {
>>   	    $mac = $dev->{generatedAddress} // $mac;
>>   	}
>>   
> 




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

end of thread, other threads:[~2024-03-26 12:06 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-26 11:03 [pve-devel] [PATCH storage] esxi: use mac address when static, generated and vpx Aaron Lauterer
2024-03-26 11:36 ` Thomas Lamprecht
2024-03-26 12:06   ` Aaron Lauterer

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