]> git.puffer.fish Git - matthieu/pve-network.git/commitdiff
add pve-network-id jsonschema
authorAlexandre Derumier <aderumier@odiso.com>
Mon, 17 Jun 2019 09:26:34 +0000 (11:26 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 18 Jun 2019 05:05:59 +0000 (07:05 +0200)
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
PVE/Network/SDN/Plugin.pm

index 3f6d80856c18a9319b1ef1c48a51cc971f793e93..3dca3878e0d08e59bc35c11552cfbefcff1e709b 100644 (file)
@@ -18,6 +18,22 @@ PVE::Cluster::cfs_register_file('networks.cfg.new',
                                 sub { __PACKAGE__->parse_config(@_); },
                                 sub { __PACKAGE__->write_config(@_); });
 
+PVE::JSONSchema::register_standard_option('pve-network-id', {
+    description => "The Network object identifier.",
+    type => 'string', format => 'pve-network-id',
+});
+
+PVE::JSONSchema::register_format('pve-network-id', \&parse_network_id);
+sub parse_network_id {
+    my ($networkid, $noerr) = @_;
+
+    if ($networkid !~ m/^[a-z][a-z0-9\-\_\.]*[a-z0-9]$/i) {
+        return undef if $noerr;
+        die "network object ID '$networkid' contains illegal characters\n";
+    }
+    return $networkid;
+}
+
 my $defaultData = {
 
     propertyList => {