From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <h.duerr@proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by lists.proxmox.com (Postfix) with ESMTPS id 1542A9EC67
 for <pve-devel@lists.proxmox.com>; Tue, 28 Nov 2023 14:50:17 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
 by firstgate.proxmox.com (Proxmox) with ESMTP id E6E7817C8B
 for <pve-devel@lists.proxmox.com>; Tue, 28 Nov 2023 14:49:46 +0100 (CET)
Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com
 [94.136.29.106])
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
 key-exchange X25519 server-signature RSA-PSS (2048 bits))
 (No client certificate requested)
 by firstgate.proxmox.com (Proxmox) with ESMTPS
 for <pve-devel@lists.proxmox.com>; Tue, 28 Nov 2023 14:49:46 +0100 (CET)
Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1])
 by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 2FEAC40FD0
 for <pve-devel@lists.proxmox.com>; Tue, 28 Nov 2023 14:49:46 +0100 (CET)
Message-ID: <b7520c27-9cf5-4c64-8d8f-273c14fd04f0@proxmox.com>
Date: Tue, 28 Nov 2023 14:49:45 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
Content-Language: en-US
To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>,
 Stefan Hanreich <s.hanreich@proxmox.com>
References: <20231122122808.214325-1-s.hanreich@proxmox.com>
From: =?UTF-8?Q?Hannes_D=C3=BCrr?= <h.duerr@proxmox.com>
In-Reply-To: <20231122122808.214325-1-s.hanreich@proxmox.com>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-SPAM-LEVEL: Spam detection results:  0
 AWL 0.001 Adjusted score from AWL reputation of From: address
 BAYES_00                 -1.9 Bayes spam probability is 0 to 1%
 DMARC_MISSING             0.1 Missing DMARC policy
 KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment
 SPF_HELO_NONE           0.001 SPF: HELO does not publish an SPF Record
 SPF_PASS               -0.001 SPF: sender matches SPF record
 T_SCC_BODY_TEXT_LINE    -0.01 -
 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See
 http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more
 information. [sdn.pm]
Subject: Re: [pve-devel] [PATCH pve-network] validation: add support for
 arrays to change tracking
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
X-List-Received-Date: Tue, 28 Nov 2023 13:50:17 -0000

Tested-by: Hannes Duerr <h.duerr@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@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;