From: Stefan Hanreich <s.hanre...@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.hanre...@proxmox.com> Co-authored-by: Gabriel Goller <g.gol...@proxmox.com> Signed-off-by: Gabriel Goller <g.gol...@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