From: Stefan Hanreich <s.hanre...@proxmox.com> Add CRUD endpoints for OSPF nodes. They are implemented in proxmox-perl-rs.
Signed-off-by: Stefan Hanreich <s.hanre...@proxmox.com> Signed-off-by: Gabriel Goller <g.gol...@proxmox.com> --- src/PVE/API2/Network/SDN/Fabrics/Makefile | 2 +- src/PVE/API2/Network/SDN/Fabrics/OSPFNode.pm | 163 +++++++++++++++++++ 2 files changed, 164 insertions(+), 1 deletion(-) create mode 100644 src/PVE/API2/Network/SDN/Fabrics/OSPFNode.pm diff --git a/src/PVE/API2/Network/SDN/Fabrics/Makefile b/src/PVE/API2/Network/SDN/Fabrics/Makefile index 62d794486ebe..5d529add017d 100644 --- a/src/PVE/API2/Network/SDN/Fabrics/Makefile +++ b/src/PVE/API2/Network/SDN/Fabrics/Makefile @@ -1,4 +1,4 @@ -SOURCES=Common.pm OpenFabric.pm OpenFabricNode.pm OSPF.pm +SOURCES=Common.pm OpenFabric.pm OpenFabricNode.pm OSPF.pm OSPFNode.pm PERL5DIR=${DESTDIR}/usr/share/perl5 diff --git a/src/PVE/API2/Network/SDN/Fabrics/OSPFNode.pm b/src/PVE/API2/Network/SDN/Fabrics/OSPFNode.pm new file mode 100644 index 000000000000..d256bc84d438 --- /dev/null +++ b/src/PVE/API2/Network/SDN/Fabrics/OSPFNode.pm @@ -0,0 +1,163 @@ +package PVE::API2::Network::SDN::Fabrics::OSPFNode; + +use strict; +use warnings; + +use PVE::JSONSchema qw(get_standard_option); +use PVE::Tools qw(extract_param); + +use PVE::API2::Network::SDN::Fabrics::Common; + +use PVE::RESTHandler; +use base qw(PVE::RESTHandler); + +my $interface_format = { + name => { + type => 'string', + format => 'pve-iface', + description => 'Name of the interface', + }, + passive => { + type => 'boolean', + description => 'The passive property of the interface', + optional => 1, + }, + ip => { + type => 'string', + format => 'CIDRv4', + description => 'The IPv4 address of the interface', + optional => 1, + }, + unnumbered => { + type => 'boolean', + description => 'If the interface is unnumbered', + optional => 1, + }, +}; + +our $node_properties = { + digest => get_standard_option('pve-config-digest'), + fabric_id => get_standard_option('pve-sdn-fabric-id'), + node_id => get_standard_option('pve-sdn-fabric-node-id'), + router_id => { + type => 'string', + format => 'ipv4', + description => 'The Router-ID of this node', + }, + interfaces => { + type => 'array', + optional => 1, + description => 'Array of openfabric interfaces as propertystrings', + items => { + type => 'string', + description => 'Propertystring of openfabric interfaces', + format => $interface_format, + }, + }, +}; + +__PACKAGE__->register_method({ + name => 'get_node', + path => '{node_id}', + method => 'GET', + description => 'Get the configuration for a node in an OSPF fabric', + permissions => { + check => ['perm', '/sdn/fabrics/ospf/{fabric_id}', [ 'SDN.Audit', 'SDN.Allocate' ], any => 1], + }, + parameters => { + properties => { + fabric_id => get_standard_option('pve-sdn-fabric-id'), + node_id => get_standard_option('pve-sdn-fabric-node-id'), + }, + }, + returns => { + type => 'object', + properties => $node_properties, + }, + code => sub { + my ($param) = @_; + + return PVE::API2::Network::SDN::Fabrics::Common::get_node("ospf", $param); + }, +}); + + +__PACKAGE__->register_method({ + name => 'add_node', + path => '/', + method => 'POST', + description => 'Add a node to an OSPF fabric', + protected => 1, + permissions => { + check => ['perm', '/sdn/fabrics/ospf/{fabric_id}', [ 'SDN.Allocate' ]], + }, + parameters => { + properties => $node_properties, + }, + returns => { + type => 'null', + }, + code => sub { + my ($param) = @_; + + PVE::Network::SDN::lock_sdn_config( + sub { + PVE::API2::Network::SDN::Fabrics::Common::add_node("ospf", $param); + }, "add sdn fabric node failed"); + }, +}); + +__PACKAGE__->register_method({ + name => 'update_node', + path => '{node_id}', + method => 'PUT', + description => 'Update a node in an OSPF fabric', + protected => 1, + permissions => { + check => ['perm', '/sdn/fabrics/ospf/{fabric_id}', [ 'SDN.Allocate' ]], + }, + parameters => { + properties => $node_properties, + }, + returns => { + type => 'null', + }, + code => sub { + my ($param) = @_; + + PVE::Network::SDN::lock_sdn_config( + sub { + PVE::API2::Network::SDN::Fabrics::Common::edit_node("ospf", $param); + }, "edit sdn fabric node failed"); + }, +}); + +__PACKAGE__->register_method({ + name => 'delete_node', + path => '{node_id}', + method => 'DELETE', + description => 'Delete a node from an OSPF fabric', + protected => 1, + permissions => { + check => ['perm', '/sdn/fabrics/ospf/{fabric_id}', [ 'SDN.Allocate' ]], + }, + parameters => { + properties => { + fabric_id => get_standard_option('pve-sdn-fabric-id'), + node_id => get_standard_option('pve-sdn-fabric-node-id'), + }, + }, + returns => { + type => 'null', + }, + code => sub { + my ($param) = @_; + + PVE::Network::SDN::lock_sdn_config( + sub { + PVE::API2::Network::SDN::Fabrics::Common::delete_node("ospf", $param); + }, "delete sdn fabric node failed"); + }, +}); + +1; -- 2.39.5 _______________________________________________ pve-devel mailing list pve-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel