From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <pve-devel-bounces@lists.proxmox.com>
Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9])
	by lore.proxmox.com (Postfix) with ESMTPS id EB4E61FF15C
	for <inbox@lore.proxmox.com>; Fri,  4 Apr 2025 18:39:25 +0200 (CEST)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 2FCEEE95;
	Fri,  4 Apr 2025 18:38:55 +0200 (CEST)
From: Gabriel Goller <g.goller@proxmox.com>
To: pve-devel@lists.proxmox.com
Date: Fri,  4 Apr 2025 18:28:49 +0200
Message-Id: <20250404162908.563060-39-g.goller@proxmox.com>
X-Mailer: git-send-email 2.39.5
In-Reply-To: <20250404162908.563060-1-g.goller@proxmox.com>
References: <20250404162908.563060-1-g.goller@proxmox.com>
MIME-Version: 1.0
X-SPAM-LEVEL: Spam detection results:  0
 AWL -0.022 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 13/19] api: openfabric: add api
 endpoints
X-BeenThere: pve-devel@lists.proxmox.com
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: Proxmox VE development discussion <pve-devel.lists.proxmox.com>
List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=unsubscribe>
List-Archive: <http://lists.proxmox.com/pipermail/pve-devel/>
List-Post: <mailto:pve-devel@lists.proxmox.com>
List-Help: <mailto:pve-devel-request@lists.proxmox.com?subject=help>
List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel>, 
 <mailto:pve-devel-request@lists.proxmox.com?subject=subscribe>
Reply-To: Proxmox VE development discussion <pve-devel@lists.proxmox.com>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: pve-devel-bounces@lists.proxmox.com
Sender: "pve-devel" <pve-devel-bounces@lists.proxmox.com>

From: Stefan Hanreich <s.hanreich@proxmox.com>

Add CRUD endpoints for OpenFabric fabrics. The logic is handled by
proxmox-perl-rs itself, the endpoints are just proxying the Rust
implementation.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
Co-authored-by: Gabriel Goller <g.goller@proxmox.com>
Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 src/PVE/API2/Network/SDN/Fabrics/Makefile     |   2 +-
 .../API2/Network/SDN/Fabrics/OpenFabric.pm    | 125 ++++++++++++++++++
 2 files changed, 126 insertions(+), 1 deletion(-)
 create mode 100644 src/PVE/API2/Network/SDN/Fabrics/OpenFabric.pm

diff --git a/src/PVE/API2/Network/SDN/Fabrics/Makefile b/src/PVE/API2/Network/SDN/Fabrics/Makefile
index d4267b63997c..9caae13ad963 100644
--- a/src/PVE/API2/Network/SDN/Fabrics/Makefile
+++ b/src/PVE/API2/Network/SDN/Fabrics/Makefile
@@ -1,4 +1,4 @@
-SOURCES=Common.pm
+SOURCES=Common.pm OpenFabric.pm
 
 
 PERL5DIR=${DESTDIR}/usr/share/perl5
diff --git a/src/PVE/API2/Network/SDN/Fabrics/OpenFabric.pm b/src/PVE/API2/Network/SDN/Fabrics/OpenFabric.pm
new file mode 100644
index 000000000000..7382f1095d49
--- /dev/null
+++ b/src/PVE/API2/Network/SDN/Fabrics/OpenFabric.pm
@@ -0,0 +1,125 @@
+package PVE::API2::Network::SDN::Fabrics::OpenFabric;
+
+use strict;
+use warnings;
+
+use PVE::JSONSchema qw(get_standard_option);
+
+use PVE::API2::Network::SDN::Fabrics::Common;
+use PVE::API2::Network::SDN::Fabrics::OpenFabricNode;
+
+use PVE::RESTHandler;
+use base qw(PVE::RESTHandler);
+
+my $update_fabric_properties = {
+    digest => get_standard_option('pve-config-digest'),
+    fabric_id => get_standard_option('pve-sdn-fabric-id'),
+    hello_interval => $PVE::API2::Network::SDN::Fabrics::OpenFabricNode::hello_interval_option,
+};
+
+our $fabric_properties = {
+    loopback_prefix => get_standard_option('pve-sdn-fabric-loopback-prefix'),
+    %$update_fabric_properties,
+};
+
+__PACKAGE__->register_method ({
+    subclass => "PVE::API2::Network::SDN::Fabrics::OpenFabricNode",
+    path => '{fabric_id}/node',
+});
+
+__PACKAGE__->register_method({
+    name => 'get_fabric',
+    path => '{fabric_id}',
+    method => 'GET',
+    description => 'Get the configuration for an OpenFabric fabric',
+    permissions => {
+	check => ['perm', '/sdn/fabrics/openfabric/{fabric_id}', [ 'SDN.Audit', 'SDN.Allocate' ], any => 1],
+    },
+    parameters => {
+	properties => {
+	    fabric_id => get_standard_option('pve-sdn-fabric-id'),
+	},
+    },
+    returns => {
+	type => 'object',
+	properties => $fabric_properties,
+    },
+    code => sub {
+	my ($param) = @_;
+
+	return PVE::API2::Network::SDN::Fabrics::Common::get_fabric("openfabric", $param);
+    },
+});
+
+__PACKAGE__->register_method({
+    name => 'add_fabric',
+    path => '/',
+    method => 'POST',
+    description => 'Add an OpenFabric fabric',
+    protected => 1,
+    permissions => {
+	check => ['perm', '/sdn/fabrics/openfabric', [ 'SDN.Allocate' ]],
+    },
+    parameters => {
+	properties => $fabric_properties,
+    },
+    returns => { type => 'null' },
+    code => sub {
+	my ($param) = @_;
+
+	PVE::Network::SDN::lock_sdn_config(
+	    sub {
+		PVE::API2::Network::SDN::Fabrics::Common::add_fabric("openfabric", $param);
+	    }, "add sdn fabric failed");
+    },
+});
+
+__PACKAGE__->register_method({
+    name => 'update_fabric',
+    path => '{fabric_id}',
+    method => 'PUT',
+    description => 'Update a OpenFabric fabric',
+    protected => 1,
+    permissions => {
+	check => ['perm', '/sdn/fabrics/openfabric/{fabric_id}', [ 'SDN.Allocate' ]],
+    },
+    parameters => {
+	properties => $update_fabric_properties,
+    },
+    returns => { type => 'null' },
+    code => sub {
+	my ($param) = @_;
+
+	PVE::Network::SDN::lock_sdn_config(
+	    sub {
+		PVE::API2::Network::SDN::Fabrics::Common::edit_fabric("openfabric", $param);
+	    }, "edit sdn fabric failed");
+    },
+});
+
+__PACKAGE__->register_method({
+    name => 'delete_fabric',
+    path => '{fabric_id}',
+    method => 'DELETE',
+    description => 'Delete a OpenFabric fabric',
+    protected => 1,
+    permissions => {
+	check => ['perm', '/sdn/fabrics/openfabric/{fabric_id}', [ 'SDN.Allocate' ]],
+    },
+    parameters => {
+	properties => {
+	    fabric_id => get_standard_option('pve-sdn-fabric-id'),
+	},
+    },
+    returns => { type => 'null' },
+    code => sub {
+	my ($param) = @_;
+
+	PVE::Network::SDN::lock_sdn_config(
+	    sub {
+		PVE::API2::Network::SDN::Fabrics::Common::delete_fabric("openfabric", $param);
+	    }, "delete sdn fabric failed");
+    },
+});
+
+1;
-- 
2.39.5



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel