[pve-devel] [PATCH pve-network] validation: add support for arrays to change tracking

Hannes Dürr h.duerr at proxmox.com
Tue Nov 28 14:49:45 CET 2023


Tested-by: Hannes Duerr <h.duerr at proxmox.com>

On 11/22/23 13:28, Stefan Hanreich wrote:
> This is needed so dhcp-ranges are properly displayed as changed in the
> web UI.
>
> Also took the chance to properly indent the encode_value function with
> our indentation scheme.
>
> Signed-off-by: Stefan Hanreich <s.hanreich at proxmox.com>
> ---
>   src/PVE/Network/SDN.pm | 14 ++++++++------
>   1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/src/PVE/Network/SDN.pm b/src/PVE/Network/SDN.pm
> index c306527..3af09b5 100644
> --- a/src/PVE/Network/SDN.pm
> +++ b/src/PVE/Network/SDN.pm
> @@ -241,12 +241,14 @@ sub generate_dhcp_config {
>   sub encode_value {
>       my ($type, $key, $value) = @_;
>   
> -    if ($key eq 'nodes' || $key eq 'exitnodes') {
> -        if(ref($value) eq 'HASH') {
> -            return join(',', sort keys(%$value));
> -        } else {
> -            return $value;
> -        }
> +    if ($key eq 'nodes' || $key eq 'exitnodes' || $key eq 'dhcp-range') {
> +	if (ref($value) eq 'HASH') {
> +	    return join(',', sort keys(%$value));
> +	} elsif (ref($value) eq 'ARRAY') {
> +	    return join(',', sort @$value);
> +	} else {
> +	    return $value;
> +	}
>       }
>   
>       return $value;





More information about the pve-devel mailing list