[pve-devel] [PATCH pve-network 3/3] fabrics: add api endpoint to return fabric neighbors

Gabriel Goller g.goller at proxmox.com
Wed Aug 13 15:30:12 CEST 2025


Add api endpoint that returns all the fabric neighbors of the current
node.

Signed-off-by: Gabriel Goller <g.goller at proxmox.com>
---
 src/PVE/API2/Network/SDN/Fabrics.pm | 56 +++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/src/PVE/API2/Network/SDN/Fabrics.pm b/src/PVE/API2/Network/SDN/Fabrics.pm
index 94905e865ce1..65666b69cd9e 100644
--- a/src/PVE/API2/Network/SDN/Fabrics.pm
+++ b/src/PVE/API2/Network/SDN/Fabrics.pm
@@ -54,6 +54,7 @@ __PACKAGE__->register_method({
             { subdir => 'node' },
             { subdir => 'all' },
             { subdir => 'routes' },
+            { subdir => 'neighbors' },
         ];
 
         return $res;
@@ -234,4 +235,59 @@ __PACKAGE__->register_method({
     },
 });
 
+__PACKAGE__->register_method({
+    name => 'neighbors',
+    path => 'neighbors',
+    method => 'GET',
+    description => "Get neighbors of all fabrics.",
+    permissions => {
+        description => "Only list entries where you have 'SDN.Audit' or 'SDN.Allocate'",
+        user => 'all',
+    },
+    protected => 1,
+    proxyto => 'node',
+    parameters => {
+        additionalProperties => 0,
+        properties => {
+            node => get_standard_option('pve-node'),
+        },
+    },
+    returns => {
+        type => 'array',
+        items => {
+            type => "object",
+            properties => {
+                fabric_id => get_standard_option('pve-sdn-fabric-id'),
+                protocol => get_standard_option('pve-sdn-fabric-protocol'),
+                neighbor => {
+                    description => "Neighbor",
+                    type => 'string',
+                },
+                status => {
+                    description => "Status",
+                    type => 'string',
+                },
+            },
+        },
+    },
+    code => sub {
+        my ($param) = @_;
+
+        my $rpcenv = PVE::RPCEnvironment::get();
+        my $authuser = $rpcenv->get_user();
+
+        my $res = [];
+
+        my $neighbors = PVE::RS::SDN::Fabrics::neighbors();
+        my $fabric_privs = ['SDN.Audit', 'SDN.Allocate'];
+        for my $neighbor (@$neighbors) {
+            my $fabric_id = $neighbor->{fabric_id};
+            next if !$rpcenv->check_any($authuser, "/sdn/fabrics/$fabric_id", $fabric_privs, 1);
+            push @$res, $neighbor;
+        }
+
+        return $res;
+    },
+});
+
 1;
-- 
2.47.2





More information about the pve-devel mailing list