[pve-devel] [PATCH v2 pve-network 12/15] limit vnet/zones/controller to 10 characters

Alexandre Derumier aderumier at odiso.com
Tue Nov 26 10:00:27 CET 2019


linux have 16 characters limit for interfaces,
but we can prepend "vxlan", "vrf",... when we generate
interfaces

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/Network/SDN/Controllers/Plugin.pm | 5 +++--
 PVE/Network/SDN/VnetPlugin.pm         | 5 +++--
 PVE/Network/SDN/Zones/Plugin.pm       | 7 ++++---
 3 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/PVE/Network/SDN/Controllers/Plugin.pm b/PVE/Network/SDN/Controllers/Plugin.pm
index df385f1..3aed73a 100644
--- a/PVE/Network/SDN/Controllers/Plugin.pm
+++ b/PVE/Network/SDN/Controllers/Plugin.pm
@@ -27,10 +27,11 @@ PVE::JSONSchema::register_format('pve-sdn-controller-id', \&parse_sdn_controller
 sub parse_sdn_controller_id {
     my ($id, $noerr) = @_;
 
-    if ($id !~ m/^[a-z][a-z0-9\-\_\.]*[a-z0-9]$/i) {
+    if ($id !~ m/^[a-z][a-z0-9]*[a-z0-9]$/i) {
         return undef if $noerr;
-        die "SDN controller object ID '$id' contains illegal characters\n";
+        die "controller ID '$id' contains illegal characters\n";
     }
+    die "controller ID '$id' can't be more length than 10 characters\n" if length($id) > 10;
     return $id;
 }
 
diff --git a/PVE/Network/SDN/VnetPlugin.pm b/PVE/Network/SDN/VnetPlugin.pm
index 28a7b59..2da1e1e 100644
--- a/PVE/Network/SDN/VnetPlugin.pm
+++ b/PVE/Network/SDN/VnetPlugin.pm
@@ -23,10 +23,11 @@ PVE::JSONSchema::register_format('pve-sdn-vnet-id', \&parse_sdn_vnet_id);
 sub parse_sdn_vnet_id {
     my ($id, $noerr) = @_;
 
-    if ($id !~ m/^[a-z][a-z0-9\-\_\.]*[a-z0-9]$/i) {
+    if ($id !~ m/^[a-z][a-z0-9]*[a-z0-9]$/i) {
         return undef if $noerr;
-        die "SDN object vnet ID '$id' contains illegal characters\n";
+        die "vnet ID '$id' contains illegal characters\n";
     }
+    die "vnet ID '$id' can't be more length than 10 characters\n" if length($id) > 10;
     return $id;
 }
 
diff --git a/PVE/Network/SDN/Zones/Plugin.pm b/PVE/Network/SDN/Zones/Plugin.pm
index c252dfc..3204d69 100644
--- a/PVE/Network/SDN/Zones/Plugin.pm
+++ b/PVE/Network/SDN/Zones/Plugin.pm
@@ -27,10 +27,11 @@ PVE::JSONSchema::register_format('pve-sdn-zone-id', \&parse_sdn_zone_id);
 sub parse_sdn_zone_id {
     my ($id, $noerr) = @_;
 
-    if ($id !~ m/^[a-z][a-z0-9\-\_\.]*[a-z0-9]$/i) {
-        return undef if $noerr;
-        die "SDN zone object ID '$id' contains illegal characters\n";
+    if ($id !~ m/^[a-z][a-z0-9]*[a-z0-9]$/i) {
+	return undef if $noerr;
+	die "zone ID '$id' contains illegal characters\n";
     }
+    die "zone ID '$id' can't be more length than 10 characters\n" if length($id) > 10;
     return $id;
 }
 
-- 
2.20.1




More information about the pve-devel mailing list