[pve-devel] [PATCH pve-network 1/3] add pve-network-id jsonschema
Alexandre Derumier
aderumier at odiso.com
Mon Jun 17 11:26:34 CEST 2019
Signed-off-by: Alexandre Derumier <aderumier at 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
More information about the pve-devel
mailing list