[pve-devel] [PATCH V2 pve-network 6/7] zones: plugin : readd encode/decode value
Alexandre Derumier
aderumier at odiso.com
Thu Dec 3 10:19:41 CET 2020
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
PVE/Network/SDN.pm | 21 ---------------------
PVE/Network/SDN/Zones/Plugin.pm | 28 ++++++++++++++++++++++++++++
2 files changed, 28 insertions(+), 21 deletions(-)
diff --git a/PVE/Network/SDN.pm b/PVE/Network/SDN.pm
index ed891de..256a7c8 100644
--- a/PVE/Network/SDN.pm
+++ b/PVE/Network/SDN.pm
@@ -6,8 +6,6 @@ use warnings;
use Data::Dumper;
use JSON;
-use PVE::JSONSchema;
-
use PVE::Network::SDN::Vnets;
use PVE::Network::SDN::Zones;
use PVE::Network::SDN::Controllers;
@@ -218,25 +216,6 @@ sub generate_controller_config {
PVE::Network::SDN::Controllers::reload_controller() if $reload;
}
-
-sub decode_value {
- my ($type, $key, $value) = @_;
-
- if ($key eq 'nodes') {
- my $res = {};
-
- foreach my $node (PVE::Tools::split_list($value)) {
- if (PVE::JSONSchema::pve_verify_node_name($node)) {
- $res->{$node} = 1;
- }
- }
-
- return $res;
- }
-
- return $value;
-}
-
sub encode_value {
my ($type, $key, $value) = @_;
diff --git a/PVE/Network/SDN/Zones/Plugin.pm b/PVE/Network/SDN/Zones/Plugin.pm
index ebb5c7e..9db2791 100644
--- a/PVE/Network/SDN/Zones/Plugin.pm
+++ b/PVE/Network/SDN/Zones/Plugin.pm
@@ -69,6 +69,34 @@ sub parse_section_header {
return undef;
}
+sub decode_value {
+ my ($class, $type, $key, $value) = @_;
+
+ if ($key eq 'nodes' || $key eq 'exitnodes') {
+ my $res = {};
+
+ foreach my $node (PVE::Tools::split_list($value)) {
+ if (PVE::JSONSchema::pve_verify_node_name($node)) {
+ $res->{$node} = 1;
+ }
+ }
+
+ return $res;
+ }
+
+ return $value;
+}
+
+sub encode_value {
+ my ($class, $type, $key, $value) = @_;
+
+ if ($key eq 'nodes' || $key eq 'exitnodes') {
+ return join(',', keys(%$value));
+ }
+
+ return $value;
+}
+
sub generate_sdn_config {
my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $controller, $controller_cfg, $subnet_cfg, $interfaces_config, $config) = @_;
--
2.20.1
More information about the pve-devel
mailing list