Signed-off-by: Alexandre Derumier <aderum...@odiso.com>
---
 PVE/Network/SDN/Plugin.pm | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/PVE/Network/SDN/Plugin.pm b/PVE/Network/SDN/Plugin.pm
index 3f6d808..3dca387 100644
--- a/PVE/Network/SDN/Plugin.pm
+++ b/PVE/Network/SDN/Plugin.pm
@@ -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 => {
-- 
2.20.1

_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to