[pve-devel] [PATCH pve-network 3/3] rename $network to $sdn everywhere

Alexandre Derumier aderumier at odiso.com
Mon Jun 17 11:26:36 CEST 2019


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/API2/Network/SDN.pm                 | 120 ++++++++++++------------
 PVE/Network/SDN.pm                      |  26 ++---
 PVE/Network/SDN/Plugin.pm               |  36 +++----
 PVE/Network/SDN/VlanPlugin.pm           |  30 +++---
 PVE/Network/SDN/VnetPlugin.pm           |  18 ++--
 PVE/Network/SDN/VxlanMulticastPlugin.pm |  30 +++---
 test/generateconfig.pl                  |  16 ++--
 7 files changed, 138 insertions(+), 138 deletions(-)

diff --git a/PVE/API2/Network/SDN.pm b/PVE/API2/Network/SDN.pm
index 79aff4a..7baf7ee 100644
--- a/PVE/API2/Network/SDN.pm
+++ b/PVE/API2/Network/SDN.pm
@@ -19,13 +19,13 @@ use PVE::RESTHandler;
 
 use base qw(PVE::RESTHandler);
 
-my $network_type_enum = PVE::Network::SDN::Plugin->lookup_types();
+my $sdn_type_enum = PVE::Network::SDN::Plugin->lookup_types();
 
-my $api_network_config = sub {
-    my ($cfg, $networkid) = @_;
+my $api_sdn_config = sub {
+    my ($cfg, $sdnid) = @_;
 
-    my $scfg = dclone(PVE::Network::SDN::network_config($cfg, $networkid));
-    $scfg->{network} = $networkid;
+    my $scfg = dclone(PVE::Network::SDN::sdn_config($cfg, $sdnid));
+    $scfg->{sdn} = $sdnid;
     $scfg->{digest} = $cfg->{digest};
 
     return $scfg;
@@ -35,18 +35,18 @@ __PACKAGE__->register_method ({
     name => 'index', 
     path => '',
     method => 'GET',
-    description => "Network index.",
+    description => "SDN index.",
     permissions => { 
-	description => "Only list entries where you have 'Network.Audit' or 'Network.Allocate' permissions on '/cluster/network/<network>'",
+	description => "Only list entries where you have 'SDN.Audit' or 'SDN.Allocate' permissions on '/cluster/sdn/<sdn>'",
 	user => 'all',
     },
     parameters => {
     	additionalProperties => 0,
 	properties => {
 	    type => { 
-		description => "Only list network of specific type",
+		description => "Only list sdn of specific type",
 		type => 'string', 
-		enum => $network_type_enum,
+		enum => $sdn_type_enum,
 		optional => 1,
 	    },
 	},
@@ -55,9 +55,9 @@ __PACKAGE__->register_method ({
 	type => 'array',
 	items => {
 	    type => "object",
-	    properties => { network => { type => 'string'} },
+	    properties => { sdn => { type => 'string'} },
 	},
-	links => [ { rel => 'child', href => "{network}" } ],
+	links => [ { rel => 'child', href => "{sdn}" } ],
     },
     code => sub {
 	my ($param) = @_;
@@ -68,13 +68,13 @@ __PACKAGE__->register_method ({
 
 	my $cfg = PVE::Network::SDN::config();
 
-	my @sids = PVE::Network::SDN::networks_ids($cfg);
+	my @sids = PVE::Network::SDN::sdn_ids($cfg);
 	my $res = [];
-	foreach my $networkid (@sids) {
-#	    my $privs = [ 'Network.Audit', 'Network.Allocate' ];
-#	    next if !$rpcenv->check_any($authuser, "/cluster/network/$networkid", $privs, 1);
+	foreach my $sdnid (@sids) {
+#	    my $privs = [ 'SDN.Audit', 'SDN.Allocate' ];
+#	    next if !$rpcenv->check_any($authuser, "/cluster/sdn/$sdnid", $privs, 1);
 
-	    my $scfg = &$api_network_config($cfg, $networkid);
+	    my $scfg = &$api_sdn_config($cfg, $sdnid);
 	    next if $param->{type} && $param->{type} ne $scfg->{type};
 	    push @$res, $scfg;
 	}
@@ -84,17 +84,17 @@ __PACKAGE__->register_method ({
 
 __PACKAGE__->register_method ({
     name => 'read', 
-    path => '{network}',
+    path => '{sdn}',
     method => 'GET',
-    description => "Read network configuration.",
+    description => "Read sdn configuration.",
 #    permissions => { 
-#	check => ['perm', '/cluster/network/{network}', ['Network.Allocate']],
+#	check => ['perm', '/cluster/sdn/{sdn}', ['SDN.Allocate']],
 #   },
 
     parameters => {
     	additionalProperties => 0,
 	properties => {
-	    network => get_standard_option('pve-network-id'),
+	    sdn => get_standard_option('pve-sdn-id'),
 	},
     },
     returns => { type => 'object' },
@@ -103,7 +103,7 @@ __PACKAGE__->register_method ({
 
 	my $cfg = PVE::Network::SDN::config();
 
-	return &$api_network_config($cfg, $param->{network});
+	return &$api_sdn_config($cfg, $param->{sdn});
     }});
 
 __PACKAGE__->register_method ({
@@ -111,9 +111,9 @@ __PACKAGE__->register_method ({
     protected => 1,
     path => '', 
     method => 'POST',
-    description => "Create a new network object.",
+    description => "Create a new sdn object.",
 #    permissions => { 
-#	check => ['perm', '/cluster/network', ['Network.Allocate']],
+#	check => ['perm', '/cluster/sdn', ['SDN.Allocate']],
 #    },
     parameters => PVE::Network::SDN::Plugin->createSchema(),
     returns => { type => 'null' },
@@ -121,23 +121,23 @@ __PACKAGE__->register_method ({
 	my ($param) = @_;
 
 	my $type = extract_param($param, 'type');
-	my $networkid = extract_param($param, 'network');
+	my $sdnid = extract_param($param, 'sdn');
 
 	my $plugin = PVE::Network::SDN::Plugin->lookup($type);
-	my $opts = $plugin->check_config($networkid, $param, 1, 1);
+	my $opts = $plugin->check_config($sdnid, $param, 1, 1);
 
-        PVE::Network::SDN::lock_network_config(
+        PVE::Network::SDN::lock_sdn_config(
 	    sub {
 
 		my $cfg = PVE::Network::SDN::config();
 
 		my $scfg = undef;
-		if ($scfg = PVE::Network::SDN::network_config($cfg, $networkid, 1)) {
-		    die "network object ID '$networkid' already defined\n";
+		if ($scfg = PVE::Network::SDN::sdn_config($cfg, $sdnid, 1)) {
+		    die "sdn object ID '$sdnid' already defined\n";
 		}
 
-		$cfg->{ids}->{$networkid} = $opts;
-		$plugin->on_update_hook($networkid, $cfg);
+		$cfg->{ids}->{$sdnid} = $opts;
+		$plugin->on_update_hook($sdnid, $cfg);
 		#also verify transport associated to vnet
 		if($scfg && $scfg->{type} eq 'vnet') {
 		    my $transportid = $scfg->{transportzone};
@@ -149,7 +149,7 @@ __PACKAGE__->register_method ({
 
 		PVE::Network::SDN::write_config($cfg);
 	    
-	    }, "create network object failed");
+	    }, "create sdn object failed");
 
 	return undef;
     }});
@@ -159,9 +159,9 @@ __PACKAGE__->register_method ({
     protected => 1,
     path => '',
     method => 'PUT',
-    description => "Apply network changes.",
+    description => "Apply sdn changes.",
 #    permissions => { 
-#	check => ['perm', '/cluster/network', ['Network.Allocate']],
+#	check => ['perm', '/cluster/sdn', ['SDN.Allocate']],
 #    },
     parameters => {
 	additionalProperties => 0,
@@ -170,9 +170,9 @@ __PACKAGE__->register_method ({
     code => sub {
 	my ($param) = @_;
 
-	die "no network changes to apply" if !-e "/etc/pve/networks.cfg.new";
-	rename("/etc/pve/networks.cfg.new", "/etc/pve/networks.cfg")
-	    || die "applying networks.cfg changes failed - $!\n";
+	die "no sdn changes to apply" if !-e "/etc/pve/sdn.cfg.new";
+	rename("/etc/pve/sdn.cfg.new", "/etc/pve/sdn.cfg")
+	    || die "applying sdn.cfg changes failed - $!\n";
 
 
 	return undef;
@@ -183,9 +183,9 @@ __PACKAGE__->register_method ({
     protected => 1,
     path => '',
     method => 'DELETE',
-    description => "Revert network changes.",
+    description => "Revert sdn changes.",
 #    permissions => { 
-#	check => ['perm', '/cluster/network', ['Network.Allocate']],
+#	check => ['perm', '/cluster/sdn', ['SDN.Allocate']],
 #    },
     parameters => {
 	additionalProperties => 0,
@@ -194,8 +194,8 @@ __PACKAGE__->register_method ({
     code => sub {
 	my ($param) = @_;
 
-	die "no network changes to revert" if !-e "/etc/pve/networks.cfg.new";
-	unlink "/etc/pve/networks.cfg.new";
+	die "no sdn changes to revert" if !-e "/etc/pve/sdn.cfg.new";
+	unlink "/etc/pve/sdn.cfg.new";
 
 	return undef;
     }});
@@ -203,37 +203,37 @@ __PACKAGE__->register_method ({
 __PACKAGE__->register_method ({
     name => 'update',
     protected => 1,
-    path => '{network}',
+    path => '{sdn}',
     method => 'PUT',
-    description => "Update network object configuration.",
+    description => "Update sdn object configuration.",
 #    permissions => { 
-#	check => ['perm', '/cluster/network', ['Network.Allocate']],
+#	check => ['perm', '/cluster/sdn', ['SDN.Allocate']],
 #    },
     parameters => PVE::Network::SDN::Plugin->updateSchema(),
     returns => { type => 'null' },
     code => sub {
 	my ($param) = @_;
 
-	my $networkid = extract_param($param, 'network');
+	my $sdnid = extract_param($param, 'sdn');
 	my $digest = extract_param($param, 'digest');
 
-        PVE::Network::SDN::lock_network_config(
+        PVE::Network::SDN::lock_sdn_config(
 	 sub {
 
 	    my $cfg = PVE::Network::SDN::config();
 
 	    PVE::SectionConfig::assert_if_modified($cfg, $digest);
 
-	    my $scfg = PVE::Network::SDN::network_config($cfg, $networkid);
+	    my $scfg = PVE::Network::SDN::sdn_config($cfg, $sdnid);
 
 	    my $plugin = PVE::Network::SDN::Plugin->lookup($scfg->{type});
-	    my $opts = $plugin->check_config($networkid, $param, 0, 1);
+	    my $opts = $plugin->check_config($sdnid, $param, 0, 1);
 
 	    foreach my $k (%$opts) {
 		$scfg->{$k} = $opts->{$k};
 	    }
 
-	    $plugin->on_update_hook($networkid, $cfg);
+	    $plugin->on_update_hook($sdnid, $cfg);
 	    #also verify transport associated to vnet
             if($scfg->{type} eq 'vnet') {
                 my $transportid = $scfg->{transportzone};
@@ -244,7 +244,7 @@ __PACKAGE__->register_method ({
             }
 	    PVE::Network::SDN::write_config($cfg);
 
-	    }, "update network object failed");
+	    }, "update sdn object failed");
 
 	return undef;
     }});
@@ -252,17 +252,17 @@ __PACKAGE__->register_method ({
 __PACKAGE__->register_method ({
     name => 'delete',
     protected => 1,
-    path => '{network}', # /cluster/network/{network}
+    path => '{sdn}',
     method => 'DELETE',
-    description => "Delete network object configuration.",
+    description => "Delete sdn object configuration.",
 #    permissions => { 
-#	check => ['perm', '/cluster/network', ['Network.Allocate']],
+#	check => ['perm', '/cluster/sdn', ['SDN.Allocate']],
 #    },
     parameters => {
     	additionalProperties => 0,
 	properties => { 
-	    network => get_standard_option('pve-network-id', {
-                completion => \&PVE::Network::SDN::complete_network,
+	    sdn => get_standard_option('pve-sdn-id', {
+                completion => \&PVE::Network::SDN::complete_sdn,
             }),
 	},
     },
@@ -270,22 +270,22 @@ __PACKAGE__->register_method ({
     code => sub {
 	my ($param) = @_;
 
-	my $networkid = extract_param($param, 'network');
+	my $sdnid = extract_param($param, 'sdn');
 
-        PVE::Network::SDN::lock_network_config(
+        PVE::Network::SDN::lock_sdn_config(
 	    sub {
 
 		my $cfg = PVE::Network::SDN::config();
 
-		my $scfg = PVE::Network::SDN::network_config($cfg, $networkid);
+		my $scfg = PVE::Network::SDN::sdn_config($cfg, $sdnid);
 
 		my $plugin = PVE::Network::SDN::Plugin->lookup($scfg->{type});
-		$plugin->on_delete_hook($networkid, $cfg);
+		$plugin->on_delete_hook($sdnid, $cfg);
 
-		delete $cfg->{ids}->{$networkid};
+		delete $cfg->{ids}->{$sdnid};
 		PVE::Network::SDN::write_config($cfg);
 
-	    }, "delete network object failed");
+	    }, "delete sdn object failed");
 
 
 	return undef;
diff --git a/PVE/Network/SDN.pm b/PVE/Network/SDN.pm
index efac541..8078c3f 100644
--- a/PVE/Network/SDN.pm
+++ b/PVE/Network/SDN.pm
@@ -19,50 +19,50 @@ PVE::Network::SDN::VxlanMulticastPlugin->register();
 PVE::Network::SDN::Plugin->init();
 
 
-sub network_config {
-    my ($cfg, $networkid, $noerr) = @_;
+sub sdn_config {
+    my ($cfg, $sdnid, $noerr) = @_;
 
-    die "no network ID specified\n" if !$networkid;
+    die "no sdn ID specified\n" if !$sdnid;
 
-    my $scfg = $cfg->{ids}->{$networkid};
-    die "network '$networkid' does not exists\n" if (!$noerr && !$scfg);
+    my $scfg = $cfg->{ids}->{$sdnid};
+    die "sdn '$sdnid' does not exists\n" if (!$noerr && !$scfg);
 
     return $scfg;
 }
 
 sub config {
-    my $config = cfs_read_file("networks.cfg.new");
-    $config = cfs_read_file("networks.cfg") if !keys %{$config->{ids}};
+    my $config = cfs_read_file("sdn.cfg.new");
+    $config = cfs_read_file("sdn.cfg") if !keys %{$config->{ids}};
     return $config;
 }
 
 sub write_config {
     my ($cfg) = @_;
 
-    cfs_write_file("networks.cfg.new", $cfg);
+    cfs_write_file("sdn.cfg.new", $cfg);
 }
 
-sub lock_network_config {
+sub lock_sdn_config {
     my ($code, $errmsg) = @_;
 
-    cfs_lock_file("networks.cfg.new", undef, $code);
+    cfs_lock_file("sdn.cfg.new", undef, $code);
     if (my $err = $@) {
         $errmsg ? die "$errmsg: $err" : die $err;
     }
 }
 
-sub networks_ids {
+sub sdn_ids {
     my ($cfg) = @_;
 
     return keys %{$cfg->{ids}};
 }
 
-sub complete_network {
+sub complete_sdn {
     my ($cmdname, $pname, $cvalue) = @_;
 
     my $cfg = PVE::Network::SDN::config();
 
-    return  $cmdname eq 'add' ? [] : [ PVE::Network::SDN::networks_ids($cfg) ];
+    return  $cmdname eq 'add' ? [] : [ PVE::Network::SDN::sdn_ids($cfg) ];
 }
 
 sub status {
diff --git a/PVE/Network/SDN/Plugin.pm b/PVE/Network/SDN/Plugin.pm
index 3dca387..a76442b 100644
--- a/PVE/Network/SDN/Plugin.pm
+++ b/PVE/Network/SDN/Plugin.pm
@@ -11,27 +11,27 @@ use Data::Dumper;
 use PVE::JSONSchema qw(get_standard_option);
 use base qw(PVE::SectionConfig);
 
-PVE::Cluster::cfs_register_file('networks.cfg',
+PVE::Cluster::cfs_register_file('sdn.cfg',
 				 sub { __PACKAGE__->parse_config(@_); });
 
-PVE::Cluster::cfs_register_file('networks.cfg.new',
+PVE::Cluster::cfs_register_file('sdn.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_standard_option('pve-sdn-id', {
+    description => "The SDN object identifier.",
+    type => 'string', format => 'pve-sdn-id',
 });
 
-PVE::JSONSchema::register_format('pve-network-id', \&parse_network_id);
-sub parse_network_id {
-    my ($networkid, $noerr) = @_;
+PVE::JSONSchema::register_format('pve-sdn-id', \&parse_sdn_id);
+sub parse_sdn_id {
+    my ($sdnid, $noerr) = @_;
 
-    if ($networkid !~ m/^[a-z][a-z0-9\-\_\.]*[a-z0-9]$/i) {
+    if ($sdnid !~ m/^[a-z][a-z0-9\-\_\.]*[a-z0-9]$/i) {
         return undef if $noerr;
-        die "network object ID '$networkid' contains illegal characters\n";
+        die "SDN object ID '$sdnid' contains illegal characters\n";
     }
-    return $networkid;
+    return $sdnid;
 }
 
 my $defaultData = {
@@ -42,8 +42,8 @@ my $defaultData = {
 	    type => 'string', format => 'pve-configid',
 	    type => 'string',
 	},
-        network => get_standard_option('pve-network-id',
-            { completion => \&PVE::Network::SDN::complete_network }),
+        sdn => get_standard_option('pve-sdn-id',
+            { completion => \&PVE::Network::SDN::complete_sdn }),
     },
 };
 
@@ -55,30 +55,30 @@ sub parse_section_header {
     my ($class, $line) = @_;
 
     if ($line =~ m/^(\S+):\s*(\S+)\s*$/) {
-        my ($type, $networkid) = (lc($1), $2);
+        my ($type, $sdnid) = (lc($1), $2);
 	my $errmsg = undef; # set if you want to skip whole section
 	eval { PVE::JSONSchema::pve_verify_configid($type); };
 	$errmsg = $@ if $@;
 	my $config = {}; # to return additional attributes
-	return ($type, $networkid, $errmsg, $config);
+	return ($type, $sdnid, $errmsg, $config);
     }
     return undef;
 }
 
-sub generate_network_config {
+sub generate_sdn_config {
     my ($class, $plugin_config, $node, $data, $ctime) = @_;
 
     die "please implement inside plugin";
 }
 
 sub on_delete_hook {
-    my ($class, $networkid, $scfg) = @_;
+    my ($class, $sndid, $scfg) = @_;
 
     # do nothing by default
 }
 
 sub on_update_hook {
-    my ($class, $networkid, $scfg) = @_;
+    my ($class, $sdnid, $scfg) = @_;
 
     # do nothing by default
 }
diff --git a/PVE/Network/SDN/VlanPlugin.pm b/PVE/Network/SDN/VlanPlugin.pm
index 364a19a..88a1274 100644
--- a/PVE/Network/SDN/VlanPlugin.pm
+++ b/PVE/Network/SDN/VlanPlugin.pm
@@ -10,8 +10,8 @@ sub type {
     return 'vlan';
 }
 
-PVE::JSONSchema::register_format('pve-network-vlanrange', \&pve_verify_network_vlanrange);
-sub pve_verify_network_vlanrange {
+PVE::JSONSchema::register_format('pve-sdn-vlanrange', \&pve_verify_sdn_vlanrange);
+sub pve_verify_sdn_vlanrange {
    my ($vlanstr) = @_;
 
    PVE::Network::SDN::Plugin::parse_tag_number_or_range($vlanstr, '4096');
@@ -27,7 +27,7 @@ sub properties {
 	    description => 'Uplink interface',
 	},
 	'vlan-allowed' => {
-	    type => 'string', format => 'pve-network-vlanrange',
+	    type => 'string', format => 'pve-sdn-vlanrange',
 	    description => "Allowed vlan range",
 	},
 	'vlan-aware' => {
@@ -56,7 +56,7 @@ sub options {
 }
 
 # Plugin implementation
-sub generate_network_config {
+sub generate_sdn_config {
     my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $uplinks) = @_;
 
     my $tag = $vnet->{tag};
@@ -91,31 +91,31 @@ sub generate_network_config {
 }
 
 sub on_delete_hook {
-    my ($class, $transportid, $network_cfg) = @_;
+    my ($class, $transportid, $sdn_cfg) = @_;
 
     # verify that no vnet are associated to this transport
-    foreach my $id (keys %{$network_cfg->{ids}}) {
-	my $network = $network_cfg->{ids}->{$id};
+    foreach my $id (keys %{$sdn_cfg->{ids}}) {
+	my $sdn = $sdn_cfg->{ids}->{$id};
 	die "transport $transportid is used by vnet $id"
-	    if ($network->{type} eq 'vnet' && defined($network->{transportzone}) && $network->{transportzone} eq $transportid);
+	    if ($sdn->{type} eq 'vnet' && defined($sdn->{transportzone}) && $sdn->{transportzone} eq $transportid);
     }
 }
 
 sub on_update_hook {
-    my ($class, $transportid, $network_cfg) = @_;
+    my ($class, $transportid, $sdn_cfg) = @_;
 
-    my $transport = $network_cfg->{ids}->{$transportid};
+    my $transport = $sdn_cfg->{ids}->{$transportid};
 
     # verify that vlan-allowed don't conflict with another vlan-allowed transport
 
     # verify that vlan-allowed is matching currently vnet tag in this transport
     my $vlanallowed = $transport->{'vlan-allowed'};
     if ($vlanallowed) {
-	foreach my $id (keys %{$network_cfg->{ids}}) {
-	    my $network = $network_cfg->{ids}->{$id};
-	    if ($network->{type} eq 'vnet' && defined($network->{tag})) {
-		if(defined($network->{transportzone}) && $network->{transportzone} eq $transportid) {
-		    my $tag = $network->{tag};
+	foreach my $id (keys %{$sdn_cfg->{ids}}) {
+	    my $sdn = $sdn_cfg->{ids}->{$id};
+	    if ($sdn->{type} eq 'vnet' && defined($sdn->{tag})) {
+		if(defined($sdn->{transportzone}) && $sdn->{transportzone} eq $transportid) {
+		    my $tag = $sdn->{tag};
 		    eval {
 			PVE::Network::SDN::Plugin::parse_tag_number_or_range($vlanallowed, '4096', $tag);
 		    };
diff --git a/PVE/Network/SDN/VnetPlugin.pm b/PVE/Network/SDN/VnetPlugin.pm
index ecab6a3..6da17b7 100644
--- a/PVE/Network/SDN/VnetPlugin.pm
+++ b/PVE/Network/SDN/VnetPlugin.pm
@@ -62,21 +62,21 @@ sub options {
 }
 
 sub on_delete_hook {
-    my ($class, $networkid, $network_cfg) = @_;
+    my ($class, $sdnid, $sdn_cfg) = @_;
 
     return;
 }
 
 sub on_update_hook {
-    my ($class, $networkid, $network_cfg) = @_;
+    my ($class, $sdnid, $sdn_cfg) = @_;
     # verify that tag is not already defined in another vnet
-    if (defined($network_cfg->{ids}->{$networkid}->{tag})) {
-	my $tag = $network_cfg->{ids}->{$networkid}->{tag};
-	foreach my $id (keys %{$network_cfg->{ids}}) {
-	    next if $id eq $networkid;
-	    my $network = $network_cfg->{ids}->{$id};
-	    if ($network->{type} eq 'vnet' && defined($network->{tag})) {
-		die "tag $tag already exist in vnet $id" if $tag eq $network->{tag};
+    if (defined($sdn_cfg->{ids}->{$sdnid}->{tag})) {
+	my $tag = $sdn_cfg->{ids}->{$sdnid}->{tag};
+	foreach my $id (keys %{$sdn_cfg->{ids}}) {
+	    next if $id eq $sdnid;
+	    my $sdn = $sdn_cfg->{ids}->{$id};
+	    if ($sdn->{type} eq 'vnet' && defined($sdn->{tag})) {
+		die "tag $tag already exist in vnet $id" if $tag eq $sdn->{tag};
 	    }
 	}
     }
diff --git a/PVE/Network/SDN/VxlanMulticastPlugin.pm b/PVE/Network/SDN/VxlanMulticastPlugin.pm
index 750da4f..ac60734 100644
--- a/PVE/Network/SDN/VxlanMulticastPlugin.pm
+++ b/PVE/Network/SDN/VxlanMulticastPlugin.pm
@@ -6,8 +6,8 @@ use PVE::Network::SDN::Plugin;
 
 use base('PVE::Network::SDN::Plugin');
 
-PVE::JSONSchema::register_format('pve-network-vxlanrange', \&pve_verify_network_vxlanrange);
-sub pve_verify_network_vxlanrange {
+PVE::JSONSchema::register_format('pve-sdn-vxlanrange', \&pve_verify_sdn_vxlanrange);
+sub pve_verify_sdn_vxlanrange {
    my ($vxlanstr) = @_;
 
    PVE::Network::SDN::Plugin::parse_tag_number_or_range($vxlanstr, '16777216');
@@ -22,7 +22,7 @@ sub type {
 sub properties {
     return {
         'vxlan-allowed' => {
-            type => 'string', format => 'pve-network-vxlanrange',
+            type => 'string', format => 'pve-sdn-vxlanrange',
             description => "Allowed vlan range",
         },
         'multicast-address' => {
@@ -43,7 +43,7 @@ sub options {
 }
 
 # Plugin implementation
-sub generate_network_config {
+sub generate_sdn_config {
     my ($class, $plugin_config, $zoneid, $vnetid, $vnet, $uplinks) = @_;
 
     my $tag = $vnet->{tag};
@@ -79,31 +79,31 @@ sub generate_network_config {
 }
 
 sub on_delete_hook {
-    my ($class, $transportid, $network_cfg) = @_;
+    my ($class, $transportid, $sdn_cfg) = @_;
 
     # verify that no vnet are associated to this transport
-    foreach my $id (keys %{$network_cfg->{ids}}) {
-	my $network = $network_cfg->{ids}->{$id};
+    foreach my $id (keys %{$sdn_cfg->{ids}}) {
+	my $sdn = $sdn_cfg->{ids}->{$id};
 	die "transport $transportid is used by vnet $id" 
-	    if ($network->{type} eq 'vnet' && defined($network->{transportzone}) && $network->{transportzone} eq $transportid);
+	    if ($sdn->{type} eq 'vnet' && defined($sdn->{transportzone}) && $sdn->{transportzone} eq $transportid);
     }
 }
 
 sub on_update_hook {
-    my ($class, $transportid, $network_cfg) = @_;
+    my ($class, $transportid, $sdn_cfg) = @_;
 
-    my $transport = $network_cfg->{ids}->{$transportid};
+    my $transport = $sdn_cfg->{ids}->{$transportid};
 
     # verify that vxlan-allowed don't conflict with another vxlan-allowed transport
 
     # verify that vxlan-allowed is matching currently vnet tag in this transport  
     my $vxlanallowed = $transport->{'vxlan-allowed'};
     if ($vxlanallowed) {
-	foreach my $id (keys %{$network_cfg->{ids}}) {
-	    my $network = $network_cfg->{ids}->{$id};
-	    if ($network->{type} eq 'vnet' && defined($network->{tag})) {
-		if(defined($network->{transportzone}) && $network->{transportzone} eq $transportid) {
-		    my $tag = $network->{tag};
+	foreach my $id (keys %{$sdn_cfg->{ids}}) {
+	    my $sdn = $sdn_cfg->{ids}->{$id};
+	    if ($sdn->{type} eq 'vnet' && defined($sdn->{tag})) {
+		if(defined($sdn->{transportzone}) && $sdn->{transportzone} eq $transportid) {
+		    my $tag = $sdn->{tag};
 		    eval {
 			PVE::Network::SDN::Plugin::parse_tag_number_or_range($vxlanallowed, '16777216', $tag);
 		    };
diff --git a/test/generateconfig.pl b/test/generateconfig.pl
index 1477261..0a652b8 100644
--- a/test/generateconfig.pl
+++ b/test/generateconfig.pl
@@ -14,11 +14,11 @@ PVE::Network::SDN::VxlanMulticastPlugin->register();
 PVE::Network::SDN::Plugin->init();
 
 
-my $rawconfig = generate_network_config();
+my $rawconfig = generate_sdn_config();
 print $rawconfig;
 write_final_config($rawconfig);
 
-sub generate_network_config {
+sub generate_sdn_config {
 
      #only support ifupdown2
     die "you need ifupdown2 to reload networking\n" if !-e '/usr/share/ifupdown2';
@@ -40,15 +40,15 @@ sub generate_network_config {
 	}
      }
 
-    my $network_cfg = PVE::Cluster::cfs_read_file('networks.cfg');
+    my $sdn_cfg = PVE::Cluster::cfs_read_file('sdn.cfg');
     my $vnet_cfg = undef;
     my $transport_cfg = undef;
 
-    foreach my $id (keys %{$network_cfg->{ids}}) {
-	if ($network_cfg->{ids}->{$id}->{type} eq 'vnet') {
-	    $vnet_cfg->{ids}->{$id} = $network_cfg->{ids}->{$id};
+    foreach my $id (keys %{$sdn_cfg->{ids}}) {
+	if ($sdn_cfg->{ids}->{$id}->{type} eq 'vnet') {
+	    $vnet_cfg->{ids}->{$id} = $sdn_cfg->{ids}->{$id};
 	} else {
-	    $transport_cfg->{ids}->{$id} = $network_cfg->{ids}->{$id};
+	    $transport_cfg->{ids}->{$id} = $sdn_cfg->{ids}->{$id};
 	}
     }
 
@@ -62,7 +62,7 @@ sub generate_network_config {
 	     my $plugin_config = $transport_cfg->{ids}->{$zone};
 	     die "zone $zone don't exist" if !defined($plugin_config);
              my $plugin = PVE::Network::SDN::Plugin->lookup($plugin_config->{type});
-             $rawconfig .= $plugin->generate_network_config($plugin_config, $zone, $id, $vnet, $uplinks);
+             $rawconfig .= $plugin->generate_sdn_config($plugin_config, $zone, $id, $vnet, $uplinks);
         }
 
 return $rawconfig;
-- 
2.20.1




More information about the pve-devel mailing list