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 67F2E1FF15C for ; Fri, 22 Aug 2025 11:01:30 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id CF9B8BCF1; Fri, 22 Aug 2025 11:01:14 +0200 (CEST) From: Gabriel Goller To: pve-devel@lists.proxmox.com Date: Fri, 22 Aug 2025 11:00:40 +0200 Message-ID: <20250822090102.102949-9-g.goller@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250822090102.102949-1-g.goller@proxmox.com> References: <20250822090102.102949-1-g.goller@proxmox.com> MIME-Version: 1.0 X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1755853267159 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.006 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 SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH pve-network v2 2/3] fabrics: add api endpoint to return fabrics routes 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" Add api endpoint that returns all the routes distributed through the fabrics. Signed-off-by: Gabriel Goller --- src/PVE/API2/Network/SDN/Fabrics.pm | 61 ++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/src/PVE/API2/Network/SDN/Fabrics.pm b/src/PVE/API2/Network/SDN/Fabrics.pm index 5644fbee0fff..94905e865ce1 100644 --- a/src/PVE/API2/Network/SDN/Fabrics.pm +++ b/src/PVE/API2/Network/SDN/Fabrics.pm @@ -12,6 +12,7 @@ use PVE::API2::Network::SDN::Fabrics::Fabric; use PVE::API2::Network::SDN::Fabrics::Node; use PVE::RESTHandler; +use PVE::JSONSchema qw(get_standard_option); use base qw(PVE::RESTHandler); __PACKAGE__->register_method({ @@ -49,7 +50,10 @@ __PACKAGE__->register_method({ my ($param) = @_; my $res = [ - { subdir => 'fabric' }, { subdir => 'node' }, { subdir => 'all' }, + { subdir => 'fabric' }, + { subdir => 'node' }, + { subdir => 'all' }, + { subdir => 'routes' }, ]; return $res; @@ -175,4 +179,59 @@ __PACKAGE__->register_method({ }, }); +__PACKAGE__->register_method({ + name => 'routes', + path => 'routes', + method => 'GET', + description => "Get routes 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'), + route => { + description => "Route", + type => 'string', + }, + via => { + description => "Nexthop", + type => 'string', + }, + }, + }, + }, + code => sub { + my ($param) = @_; + + my $rpcenv = PVE::RPCEnvironment::get(); + my $authuser = $rpcenv->get_user(); + + my $res = []; + + my $routes = PVE::RS::SDN::Fabrics::routes(); + my $fabric_privs = ['SDN.Audit', 'SDN.Allocate']; + for my $route (@$routes) { + my $fabric_id = $route->{fabric_id}; + next if !$rpcenv->check_any($authuser, "/sdn/fabrics/$fabric_id", $fabric_privs, 1); + push @$res, $route; + } + + return $res; + }, +}); + 1; -- 2.47.2 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel