public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH pve-network] validation: add support for arrays to change tracking
@ 2023-11-22 12:28 Stefan Hanreich
  2023-11-28 13:49 ` Hannes Dürr
  2023-11-29  9:29 ` [pve-devel] applied: " Thomas Lamprecht
  0 siblings, 2 replies; 3+ messages in thread
From: Stefan Hanreich @ 2023-11-22 12:28 UTC (permalink / raw)
  To: pve-devel

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;
-- 
2.39.2




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

* Re: [pve-devel] [PATCH pve-network] validation: add support for arrays to change tracking
  2023-11-22 12:28 [pve-devel] [PATCH pve-network] validation: add support for arrays to change tracking Stefan Hanreich
@ 2023-11-28 13:49 ` Hannes Dürr
  2023-11-29  9:29 ` [pve-devel] applied: " Thomas Lamprecht
  1 sibling, 0 replies; 3+ messages in thread
From: Hannes Dürr @ 2023-11-28 13:49 UTC (permalink / raw)
  To: Proxmox VE development discussion, Stefan Hanreich

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;




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

* [pve-devel] applied: [PATCH pve-network] validation: add support for arrays to change tracking
  2023-11-22 12:28 [pve-devel] [PATCH pve-network] validation: add support for arrays to change tracking Stefan Hanreich
  2023-11-28 13:49 ` Hannes Dürr
@ 2023-11-29  9:29 ` Thomas Lamprecht
  1 sibling, 0 replies; 3+ messages in thread
From: Thomas Lamprecht @ 2023-11-29  9:29 UTC (permalink / raw)
  To: Proxmox VE development discussion, Stefan Hanreich

Am 22/11/2023 um 13:28 schrieb Stefan Hanreich:
> 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(-)
> 
>

applied, with Hannes' T-b, thanks!




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

end of thread, other threads:[~2023-11-29  9:29 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-11-22 12:28 [pve-devel] [PATCH pve-network] validation: add support for arrays to change tracking Stefan Hanreich
2023-11-28 13:49 ` Hannes Dürr
2023-11-29  9:29 ` [pve-devel] applied: " Thomas Lamprecht

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