From 65cb893e275430f5c06f42c2ee1c55e0aa04c843 Mon Sep 17 00:00:00 2001 From: Thomas Lamprecht Date: Wed, 28 Apr 2021 13:45:11 +0200 Subject: [PATCH] zones: code/indendation cleanup Signed-off-by: Thomas Lamprecht --- PVE/Network/SDN/Ipams.pm | 1 - PVE/Network/SDN/Zones.pm | 1 - PVE/Network/SDN/Zones/EvpnPlugin.pm | 17 ++++++++--------- PVE/Network/SDN/Zones/FaucetPlugin.pm | 8 ++++---- PVE/Network/SDN/Zones/Plugin.pm | 24 +++++++++++++----------- PVE/Network/SDN/Zones/VlanPlugin.pm | 4 ++-- PVE/Network/SDN/Zones/VxlanPlugin.pm | 15 +++++++-------- 7 files changed, 34 insertions(+), 36 deletions(-) diff --git a/PVE/Network/SDN/Ipams.pm b/PVE/Network/SDN/Ipams.pm index 302c4d2..e8a4b0b 100644 --- a/PVE/Network/SDN/Ipams.pm +++ b/PVE/Network/SDN/Ipams.pm @@ -3,7 +3,6 @@ package PVE::Network::SDN::Ipams; use strict; use warnings; -use Data::Dumper; use JSON; use PVE::Tools qw(extract_param dir_glob_regex run_command); diff --git a/PVE/Network/SDN/Zones.pm b/PVE/Network/SDN/Zones.pm index 67d8f18..bcef427 100644 --- a/PVE/Network/SDN/Zones.pm +++ b/PVE/Network/SDN/Zones.pm @@ -3,7 +3,6 @@ package PVE::Network::SDN::Zones; use strict; use warnings; -use Data::Dumper; use JSON; use PVE::Tools qw(extract_param dir_glob_regex run_command); diff --git a/PVE/Network/SDN/Zones/EvpnPlugin.pm b/PVE/Network/SDN/Zones/EvpnPlugin.pm index 8d5250c..a4ea8b5 100644 --- a/PVE/Network/SDN/Zones/EvpnPlugin.pm +++ b/PVE/Network/SDN/Zones/EvpnPlugin.pm @@ -29,21 +29,20 @@ sub properties { type => 'string', description => "Frr router name", }, - 'mac' => { - type => 'string', - description => "Anycast logical router mac address", - optional => 1, format => 'mac-addr' - }, + 'mac' => { + type => 'string', + description => "Anycast logical router mac address", + optional => 1, format => 'mac-addr' + }, 'exitnodes' => get_standard_option('pve-node-list'), }; } sub options { - return { - nodes => { optional => 1}, - 'vrf-vxlan' => { optional => 0 }, - controller => { optional => 0 }, + nodes => { optional => 1}, + 'vrf-vxlan' => { optional => 0 }, + controller => { optional => 0 }, exitnodes => { optional => 1 }, mtu => { optional => 1 }, mac => { optional => 1 }, diff --git a/PVE/Network/SDN/Zones/FaucetPlugin.pm b/PVE/Network/SDN/Zones/FaucetPlugin.pm index a9f119c..a811ada 100644 --- a/PVE/Network/SDN/Zones/FaucetPlugin.pm +++ b/PVE/Network/SDN/Zones/FaucetPlugin.pm @@ -22,12 +22,12 @@ sub properties { sub options { return { - nodes => { optional => 1}, + nodes => { optional => 1}, 'dp-id' => { optional => 0 }, # 'uplink-id' => { optional => 0 }, - 'controller' => { optional => 0 }, - dns => { optional => 1 }, - reversedns => { optional => 1 }, + 'controller' => { optional => 0 }, + dns => { optional => 1 }, + reversedns => { optional => 1 }, dnszone => { optional => 1 }, ipam => { optional => 0 }, }; diff --git a/PVE/Network/SDN/Zones/Plugin.pm b/PVE/Network/SDN/Zones/Plugin.pm index 9eabe73..169869d 100644 --- a/PVE/Network/SDN/Zones/Plugin.pm +++ b/PVE/Network/SDN/Zones/Plugin.pm @@ -8,13 +8,14 @@ use PVE::JSONSchema; use PVE::Cluster; use PVE::Network; -use Data::Dumper; use PVE::JSONSchema qw(get_standard_option); use base qw(PVE::SectionConfig); -PVE::Cluster::cfs_register_file('sdn/zones.cfg', - sub { __PACKAGE__->parse_config(@_); }, - sub { __PACKAGE__->write_config(@_); }); +PVE::Cluster::cfs_register_file( + 'sdn/zones.cfg', + sub { __PACKAGE__->parse_config(@_); }, + sub { __PACKAGE__->write_config(@_); }, +); PVE::JSONSchema::register_standard_option('pve-sdn-zone-id', { description => "The SDN zone object identifier.", @@ -41,13 +42,14 @@ my $defaultData = { type => 'string', format => 'pve-configid', type => 'string', }, - nodes => get_standard_option('pve-node-list', { optional => 1 }), - zone => get_standard_option('pve-sdn-zone-id', - { completion => \&PVE::Network::SDN::Zones::complete_sdn_zone }), - ipam => { - type => 'string', - description => "use a specific ipam", - }, + nodes => get_standard_option('pve-node-list', { optional => 1 }), + zone => get_standard_option('pve-sdn-zone-id', { + completion => \&PVE::Network::SDN::Zones::complete_sdn_zone, + }), + ipam => { + type => 'string', + description => "use a specific ipam", + }, }, }; diff --git a/PVE/Network/SDN/Zones/VlanPlugin.pm b/PVE/Network/SDN/Zones/VlanPlugin.pm index cda2a36..93a60a0 100644 --- a/PVE/Network/SDN/Zones/VlanPlugin.pm +++ b/PVE/Network/SDN/Zones/VlanPlugin.pm @@ -31,13 +31,13 @@ sub properties { sub options { return { - nodes => { optional => 1}, + nodes => { optional => 1}, 'bridge' => { optional => 0 }, mtu => { optional => 1 }, dns => { optional => 1 }, reversedns => { optional => 1 }, dnszone => { optional => 1 }, - ipam => { optional => 0 }, + ipam => { optional => 0 }, }; } diff --git a/PVE/Network/SDN/Zones/VxlanPlugin.pm b/PVE/Network/SDN/Zones/VxlanPlugin.pm index c018d34..792e02d 100644 --- a/PVE/Network/SDN/Zones/VxlanPlugin.pm +++ b/PVE/Network/SDN/Zones/VxlanPlugin.pm @@ -33,10 +33,9 @@ sub properties { } sub options { - return { - nodes => { optional => 1}, - peers => { optional => 0 }, + nodes => { optional => 1}, + peers => { optional => 0 }, mtu => { optional => 1 }, dns => { optional => 1 }, reversedns => { optional => 1 }, @@ -68,7 +67,7 @@ sub generate_sdn_config { my @iface_config = (); push @iface_config, "vxlan-id $tag"; - foreach my $address (@peers) { + for my $address (@peers) { next if $address eq $ifaceip; push @iface_config, "vxlan_remoteip $address"; } @@ -82,9 +81,9 @@ sub generate_sdn_config { push @iface_config, "bridge_ports $vxlan_iface"; push @iface_config, "bridge_stp off"; push @iface_config, "bridge_fd 0"; - if($vnet->{vlanaware}) { - push @iface_config, "bridge-vlan-aware yes"; - push @iface_config, "bridge-vids 2-4094"; + if ($vnet->{vlanaware}) { + push @iface_config, "bridge-vlan-aware yes"; + push @iface_config, "bridge-vids 2-4094"; } push @iface_config, "mtu $mtu" if $mtu; push @iface_config, "alias $alias" if $alias; @@ -103,7 +102,7 @@ sub vnet_update_hook { raise_param_exc({ tag => "vxlan tag max value is 16777216"}) if $tag > 16777216; # verify that tag is not already defined globally (vxlan-id are unique) - foreach my $id (keys %{$vnet_cfg->{ids}}) { + for my $id (sort keys %{$vnet_cfg->{ids}}) { next if $id eq $vnetid; my $othervnet = $vnet_cfg->{ids}->{$id}; my $other_tag = $othervnet->{tag}; -- 2.39.5