[pve-devel] [PATCH pve-manager 4/5] api : cluster ressources : add sdn

Alexandre Derumier aderumier at odiso.com
Wed Aug 21 05:22:39 CEST 2019


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/API2/Cluster.pm | 28 ++++++++++++++++++++++++++--
 1 file changed, 26 insertions(+), 2 deletions(-)

diff --git a/PVE/API2/Cluster.pm b/PVE/API2/Cluster.pm
index ba9bef27..7249c00a 100644
--- a/PVE/API2/Cluster.pm
+++ b/PVE/API2/Cluster.pm
@@ -190,7 +190,7 @@ __PACKAGE__->register_method({
 	    type => {
 		type => 'string',
 		optional => 1,
-		enum => ['vm', 'storage', 'node'],
+		enum => ['vm', 'storage', 'node', 'sdn'],
 	    },
 	},
     },
@@ -203,7 +203,7 @@ __PACKAGE__->register_method({
 		type => {
 		    description => "Resource type.",
 		    type => 'string',
-		    enum => ['node', 'storage', 'pool', 'qemu', 'lxc', 'openvz'],
+		    enum => ['node', 'storage', 'pool', 'qemu', 'lxc', 'openvz', 'sdn'],
 		},
 		status => {
 		    description => "Resource type dependent status.",
@@ -399,6 +399,30 @@ __PACKAGE__->register_method({
 	    }
 	}
 
+	if($have_sdn) {
+	    if (!$param->{type} || $param->{type} eq 'sdn') {
+
+		my $nodes = PVE::Cluster::get_node_kv("sdn");
+
+		foreach my $node (keys %{$nodes}) {
+		    my $sdns = decode_json($nodes->{$node});
+
+		    foreach my $id (keys %{$sdns}) {
+			my $sdn = $sdns->{$id};
+			#next if !$rpcenv->check($authuser, "/sdn/$id", [ 'SDN.Audit' ], 1);
+			my $entry = {
+			    id => "sdn/$node/$id",
+			    sdn => $id,
+			    node => $node,
+			    type => 'sdn',
+			    status => $sdn->{'status'},
+		        }; 		    
+		    	push @$res, $entry;
+		    }
+	        }
+	    }
+	}
+
 	return $res;
     }});
 
-- 
2.20.1




More information about the pve-devel mailing list