[pve-devel] [PATCH storage] esxi: use mac address when static, generated and vpx

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Mar 26 12:36:56 CET 2024


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 at 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;
>  	}
>  





More information about the pve-devel mailing list