From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 0024F1FF17E for ; Thu, 30 Oct 2025 16:49:42 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 74BCE273A0; Thu, 30 Oct 2025 16:49:08 +0100 (CET) From: Stefan Hanreich To: pve-devel@lists.proxmox.com Date: Thu, 30 Oct 2025 16:48:29 +0100 Message-ID: <20251030154851.540408-23-s.hanreich@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251030154851.540408-1-s.hanreich@proxmox.com> References: <20251030154851.540408-1-s.hanreich@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.184 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Subject: [pve-devel] [PATCH pve-network 4/9] api: nodes: fabrics: add endpoint for querying route status X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox VE development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pve-devel-bounces@lists.proxmox.com Sender: "pve-devel" From: Gabriel Goller 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 Signed-off-by: Gabriel Goller Signed-off-by: Stefan Hanreich --- 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 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel