[pve-devel] [PATCH v4 pve-common 6/6] jsonschema : add pve-vnet-id format

Alexandre Derumier aderumier at odiso.com
Wed Apr 3 00:18:34 CEST 2019


---
 src/PVE/JSONSchema.pm | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/PVE/JSONSchema.pm b/src/PVE/JSONSchema.pm
index 1ef3b96..4b0e273 100644
--- a/src/PVE/JSONSchema.pm
+++ b/src/PVE/JSONSchema.pm
@@ -84,6 +84,11 @@ register_standard_option('pve-transport-id', {
     type => 'string', format => 'pve-transport-id',
 }); 
 
+register_standard_option('pve-vnet-id', {
+    description => "The Network vnet identifier.",
+    type => 'string', format => 'pve-vnet-id',
+}); 
+
 register_standard_option('pve-config-digest', {
     description => 'Prevent changes if current configuration file has different SHA1 digest. This can be used to prevent concurrent modifications.',
     type => 'string',
@@ -203,6 +208,17 @@ sub parse_transport_id {
     return $transportid;
 }
 
+PVE::JSONSchema::register_format('pve-vnet-id', \&parse_vnet_id);
+sub parse_vnet_id {
+    my ($vnetid, $noerr) = @_;
+
+    if ($vnetid !~ m/^vnet(\d+)$/i) {
+	return undef if $noerr;
+	die "network vnet ID '$vnetid' contains illegal characters\n";
+    }
+    return $vnetid;
+}
+
 
 register_format('pve-vmid', \&pve_verify_vmid);
 sub pve_verify_vmid {
-- 
2.11.0




More information about the pve-devel mailing list