[pve-devel] [PATCH v4 pve-common 5/6] jsonschema : add pve-transport-id

Alexandre Derumier aderumier at odiso.com
Wed Apr 3 00:18:33 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 f0fc2aa..1ef3b96 100644
--- a/src/PVE/JSONSchema.pm
+++ b/src/PVE/JSONSchema.pm
@@ -79,6 +79,11 @@ register_standard_option('pve-storage-id', {
     type => 'string', format => 'pve-storage-id',
 }); 
 
+register_standard_option('pve-transport-id', {
+    description => "The Network transport identifier.",
+    type => 'string', format => 'pve-transport-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',
@@ -187,6 +192,17 @@ sub parse_storage_id {
     return $storeid;
 }
 
+PVE::JSONSchema::register_format('pve-transport-id', \&parse_transport_id);
+sub parse_transport_id {
+    my ($transportid, $noerr) = @_;
+
+    if ($transportid !~ m/^[a-z][a-z0-9\-\_\.]*[a-z0-9]$/i) {
+	return undef if $noerr;
+	die "network transport ID '$transportid' contains illegal characters\n";
+    }
+    return $transportid;
+}
+
 
 register_format('pve-vmid', \&pve_verify_vmid);
 sub pve_verify_vmid {
-- 
2.11.0




More information about the pve-devel mailing list