[pve-devel] [PATCH pve-network 4/9] api: nodes: fabrics: add endpoint for querying route status
Stefan Hanreich
s.hanreich at proxmox.com
Thu Oct 30 16:48:29 CET 2025
From: Gabriel Goller <g.goller at proxmox.com>
This endpoint returns all routes from a given fabric, that are
imported in to the kernel routing table. For more information about
the return value, consult the respective proxmox-perl-rs commit. It is
used by the NetworkBrowser panel in pve-manager.
Co-authored-by: Stefan Hanreich <s.hanreich at proxmox.com>
Signed-off-by: Gabriel Goller <g.goller at proxmox.com>
Signed-off-by: Stefan Hanreich <s.hanreich at proxmox.com>
---
src/PVE/API2/Network/SDN/Nodes/Fabric.pm | 94 +++++++++++++++++++++++
src/PVE/API2/Network/SDN/Nodes/Fabrics.pm | 16 ++++
src/PVE/API2/Network/SDN/Nodes/Makefile | 2 +
src/PVE/API2/Network/SDN/Nodes/Status.pm | 8 +-
4 files changed, 119 insertions(+), 1 deletion(-)
create mode 100644 src/PVE/API2/Network/SDN/Nodes/Fabric.pm
create mode 100644 src/PVE/API2/Network/SDN/Nodes/Fabrics.pm
diff --git a/src/PVE/API2/Network/SDN/Nodes/Fabric.pm b/src/PVE/API2/Network/SDN/Nodes/Fabric.pm
new file mode 100644
index 0000000..c1886b7
--- /dev/null
+++ b/src/PVE/API2/Network/SDN/Nodes/Fabric.pm
@@ -0,0 +1,94 @@
+package PVE::API2::Network::SDN::Nodes::Fabric;
+
+use strict;
+use warnings;
+
+use PVE::JSONSchema qw(get_standard_option);
+use PVE::Network::SDN::Fabrics;
+use PVE::RPCEnvironment;
+use PVE::RS::SDN::Fabrics;
+use PVE::Tools qw(extract_param);
+
+use PVE::RESTHandler;
+use base qw(PVE::RESTHandler);
+
+__PACKAGE__->register_method({
+ name => 'diridx',
+ path => '',
+ method => 'GET',
+ description => "Directory index for SDN fabric status.",
+ permissions => {
+ check => ['perm', '/sdn/fabrics/{fabric}', ['SDN.Audit']],
+ },
+ parameters => {
+ additionalProperties => 0,
+ properties => {
+ node => get_standard_option('pve-node'),
+ fabric => get_standard_option('pve-sdn-fabric-id'),
+ },
+ },
+ returns => {
+ type => 'array',
+ items => {
+ type => "object",
+ properties => {
+ subdir => { type => 'string' },
+ },
+ },
+ links => [{ rel => 'child', href => "{subdir}" }],
+ },
+ code => sub {
+ my ($param) = @_;
+ my $res = [
+ { subdir => 'routes' },
+ ];
+
+ return $res;
+ },
+});
+
+__PACKAGE__->register_method({
+ name => 'routes',
+ path => 'routes',
+ method => 'GET',
+ description => "Get routes of all fabrics.",
+ permissions => {
+ check => ['perm', '/sdn/fabrics/{fabric}', ['SDN.Audit']],
+ },
+ protected => 1,
+ proxyto => 'node',
+ parameters => {
+ additionalProperties => 0,
+ properties => {
+ node => get_standard_option('pve-node'),
+ fabric => get_standard_option('pve-sdn-fabric-id'),
+ },
+ },
+ returns => {
+ type => 'array',
+ items => {
+ type => "object",
+ properties => {
+ route => {
+ description => "The CIDR block for this routing table entry.",
+ type => 'string',
+ },
+ via => {
+ description => "A list of nexthops for that route.",
+ type => 'array',
+ items => {
+ type => 'string',
+ description => 'The IP address of the nexthop.',
+ },
+ },
+ },
+ },
+ },
+ code => sub {
+ my ($param) = @_;
+
+ my $fabric_id = extract_param($param, 'fabric');
+ return PVE::RS::SDN::Fabrics::routes($fabric_id);
+ },
+});
+
diff --git a/src/PVE/API2/Network/SDN/Nodes/Fabrics.pm b/src/PVE/API2/Network/SDN/Nodes/Fabrics.pm
new file mode 100644
index 0000000..bbf557b
--- /dev/null
+++ b/src/PVE/API2/Network/SDN/Nodes/Fabrics.pm
@@ -0,0 +1,16 @@
+package PVE::API2::Network::SDN::Nodes::Fabrics;
+
+use strict;
+use warnings;
+
+use PVE::API2::Network::SDN::Nodes::Fabric;
+
+use PVE::RESTHandler;
+use base qw(PVE::RESTHandler);
+
+__PACKAGE__->register_method({
+ subclass => "PVE::API2::Network::SDN::Nodes::Fabric",
+ path => '{fabric}',
+});
+
+1;
diff --git a/src/PVE/API2/Network/SDN/Nodes/Makefile b/src/PVE/API2/Network/SDN/Nodes/Makefile
index edf0225..4e4791a 100644
--- a/src/PVE/API2/Network/SDN/Nodes/Makefile
+++ b/src/PVE/API2/Network/SDN/Nodes/Makefile
@@ -1,4 +1,6 @@
SOURCES=\
+ Fabric.pm\
+ Fabrics.pm\
Status.pm\
Zone.pm\
Zones.pm
diff --git a/src/PVE/API2/Network/SDN/Nodes/Status.pm b/src/PVE/API2/Network/SDN/Nodes/Status.pm
index e862d4a..2ce2702 100644
--- a/src/PVE/API2/Network/SDN/Nodes/Status.pm
+++ b/src/PVE/API2/Network/SDN/Nodes/Status.pm
@@ -3,6 +3,7 @@ package PVE::API2::Network::SDN::Nodes::Status;
use strict;
use warnings;
+use PVE::API2::Network::SDN::Nodes::Fabrics;
use PVE::API2::Network::SDN::Nodes::Zones;
use PVE::JSONSchema qw(get_standard_option);
@@ -10,6 +11,11 @@ use PVE::JSONSchema qw(get_standard_option);
use PVE::RESTHandler;
use base qw(PVE::RESTHandler);
+__PACKAGE__->register_method({
+ subclass => "PVE::API2::Network::SDN::Nodes::Fabrics",
+ path => 'fabrics',
+});
+
__PACKAGE__->register_method({
subclass => "PVE::API2::Network::SDN::Nodes::Zones",
path => 'zones',
@@ -40,7 +46,7 @@ __PACKAGE__->register_method({
my ($param) = @_;
my $result = [
- { name => 'zones' },
+ { name => 'fabrics' }, { name => 'zones' },
];
return $result;
},
--
2.47.3
More information about the pve-devel
mailing list