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

Alexandre Derumier aderumier at odiso.com
Tue Jun 25 00:04:19 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 bfeaf784..fd083359 100644
--- a/PVE/API2/Cluster.pm
+++ b/PVE/API2/Cluster.pm
@@ -182,7 +182,7 @@ __PACKAGE__->register_method({
 	    type => {
 		type => 'string',
 		optional => 1,
-		enum => ['vm', 'storage', 'node'],
+		enum => ['vm', 'storage', 'node', 'sdn'],
 	    },
 	},
     },
@@ -195,7 +195,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.",
@@ -391,6 +391,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