[pve-devel] [PATCH pve-manager 2/2] API2: Network: display vnets in any_bridge

Alexandre DERUMIER aderumier at odiso.com
Mon Feb 17 16:15:10 CET 2020


Any comment for this patch ?

----- Mail original -----
De: "aderumier" <aderumier at odiso.com>
À: "pve-devel" <pve-devel at pve.proxmox.com>
Cc: "aderumier" <aderumier at odiso.com>
Envoyé: Lundi 10 Février 2020 17:27:11
Objet: [PATCH pve-manager 2/2] API2: Network: display vnets in any_bridge

--- 
PVE/API2/Network.pm | 25 +++++++++++++++++++++++++ 
1 file changed, 25 insertions(+) 

diff --git a/PVE/API2/Network.pm b/PVE/API2/Network.pm 
index a32f6c01..84bd3c3a 100644 
--- a/PVE/API2/Network.pm 
+++ b/PVE/API2/Network.pm 
@@ -18,6 +18,7 @@ use base qw(PVE::RESTHandler); 

my $have_sdn; 
eval { 
+ require PVE::Network::SDN::Vnets; 
require PVE::Network::SDN::Zones; 
require PVE::Network::SDN::Controllers; 
$have_sdn = 1; 
@@ -246,6 +247,30 @@ __PACKAGE__->register_method({ 
($type eq 'bridge' || $type eq 'OVSBridge')); 
delete $ifaces->{$k} if !$match; 
} 
+ 
+ if ($have_sdn && $param->{type} eq 'any_bridge') { 
+ my $vnets_cfg = PVE::Network::SDN::Vnets::config(); 
+ my $zones_cfg = PVE::Network::SDN::Zones::config(); 
+ my @vnetids = PVE::Network::SDN::Vnets::sdn_vnets_ids($vnets_cfg); 
+ my $authuser = $rpcenv->get_user(); 
+ my $nodename = PVE::INotify::nodename(); 
+ 
+ 
+ foreach my $vnetid (@vnetids) { 
+ 
+ my $vnet = PVE::Network::SDN::Vnets::sdn_vnets_config($vnets_cfg, $vnetid); 
+ my $zoneid = $vnet->{zone}; 
+ next if !$zoneid; 
+ my $zone_config = PVE::Network::SDN::Zones::sdn_zones_config($zones_cfg, $zoneid); 
+ 
+ my $privs = [ 'SDN.Audit', 'SDN.Allocate' ]; 
+ next if !$rpcenv->check_any($authuser, "/sdn/vnets/$vnetid", $privs, 1); 
+ next if defined($zone_config->{nodes}) && !$zone_config->{nodes}->{$nodename}; 
+ 
+ my $iface = { type => 'vnet', active => '1' }; 
+ $ifaces->{$vnetid} = $iface; 
+ } 
+ } 
} 

return PVE::RESTHandler::hash_to_array($ifaces, 'iface'); 
-- 
2.20.1 




More information about the pve-devel mailing list