all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Gabriel Goller <g.goller@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve-network 08/11] add api endpoints for fabrics
Date: Fri, 14 Feb 2025 14:39:48 +0100	[thread overview]
Message-ID: <20250214133951.344500-9-g.goller@proxmox.com> (raw)
In-Reply-To: <20250214133951.344500-1-g.goller@proxmox.com>

Add api endpoints for CRUD of fabrics, nodes, and interfaces.

Signed-off-by: Gabriel Goller <g.goller@proxmox.com>
---
 src/PVE/API2/Network/SDN.pm                   |   7 +
 src/PVE/API2/Network/SDN/Fabrics.pm           |  57 +++
 src/PVE/API2/Network/SDN/Fabrics/Common.pm    | 111 +++++
 src/PVE/API2/Network/SDN/Fabrics/Makefile     |   9 +
 .../API2/Network/SDN/Fabrics/OpenFabric.pm    | 460 ++++++++++++++++++
 src/PVE/API2/Network/SDN/Fabrics/Ospf.pm      | 433 +++++++++++++++++
 src/PVE/API2/Network/SDN/Makefile             |   3 +-
 7 files changed, 1079 insertions(+), 1 deletion(-)
 create mode 100644 src/PVE/API2/Network/SDN/Fabrics.pm
 create mode 100644 src/PVE/API2/Network/SDN/Fabrics/Common.pm
 create mode 100644 src/PVE/API2/Network/SDN/Fabrics/Makefile
 create mode 100644 src/PVE/API2/Network/SDN/Fabrics/OpenFabric.pm
 create mode 100644 src/PVE/API2/Network/SDN/Fabrics/Ospf.pm

diff --git a/src/PVE/API2/Network/SDN.pm b/src/PVE/API2/Network/SDN.pm
index d216e4878b61..ccbf0777e3d4 100644
--- a/src/PVE/API2/Network/SDN.pm
+++ b/src/PVE/API2/Network/SDN.pm
@@ -17,6 +17,7 @@ use PVE::API2::Network::SDN::Vnets;
 use PVE::API2::Network::SDN::Zones;
 use PVE::API2::Network::SDN::Ipams;
 use PVE::API2::Network::SDN::Dns;
+use PVE::API2::Network::SDN::Fabrics;
 
 use base qw(PVE::RESTHandler);
 
@@ -45,6 +46,11 @@ __PACKAGE__->register_method ({
     path => 'dns',
 });
 
+__PACKAGE__->register_method ({
+    subclass => "PVE::API2::Network::SDN::Fabrics",
+    path => 'fabrics',
+});
+
 __PACKAGE__->register_method({
     name => 'index',
     path => '',
@@ -76,6 +82,7 @@ __PACKAGE__->register_method({
 	    { id => 'controllers' },
 	    { id => 'ipams' },
 	    { id => 'dns' },
+	    { id => 'fabrics' },
 	];
 
 	return $res;
diff --git a/src/PVE/API2/Network/SDN/Fabrics.pm b/src/PVE/API2/Network/SDN/Fabrics.pm
new file mode 100644
index 000000000000..8eb88efca102
--- /dev/null
+++ b/src/PVE/API2/Network/SDN/Fabrics.pm
@@ -0,0 +1,57 @@
+package PVE::API2::Network::SDN::Fabrics;
+
+use strict;
+use warnings;
+
+use Storable qw(dclone);
+
+use PVE::RPCEnvironment;
+use PVE::Tools qw(extract_param);
+
+use PVE::API2::Network::SDN::Fabrics::OpenFabric;
+use PVE::API2::Network::SDN::Fabrics::Ospf;
+
+use PVE::Network::SDN::Fabrics;
+
+use PVE::RESTHandler;
+use base qw(PVE::RESTHandler);
+
+
+__PACKAGE__->register_method ({
+    subclass => "PVE::API2::Network::SDN::Fabrics::OpenFabric",
+    path => 'openfabric',
+});
+__PACKAGE__->register_method ({
+    subclass => "PVE::API2::Network::SDN::Fabrics::Ospf",
+    path => 'ospf',
+});
+
+__PACKAGE__->register_method({
+    name => 'index',
+    path => '',
+    method => 'GET',
+    description => 'Index of SDN Fabrics',
+    permissions => {
+	description => "Only list entries where you have 'SDN.Audit' or 'SDN.Allocate' permissions on '/sdn/fabrics/<fabric>'",
+	user => 'all',
+    },
+    parameters => {
+    	additionalProperties => 0,
+    },
+    returns => {
+	type => 'array',
+	items => {
+	    oneOf => [
+
+	    ],
+	},
+    },
+    code => sub {
+	my ($param) = @_;
+
+	my $config = PVE::Network::SDN::Fabrics::get_all_configs();
+	return $config;
+    },
+});
+ 
+1;
diff --git a/src/PVE/API2/Network/SDN/Fabrics/Common.pm b/src/PVE/API2/Network/SDN/Fabrics/Common.pm
new file mode 100644
index 000000000000..f3042a18090d
--- /dev/null
+++ b/src/PVE/API2/Network/SDN/Fabrics/Common.pm
@@ -0,0 +1,111 @@
+package PVE::API2::Network::SDN::Fabrics::Common;
+
+use strict;
+use warnings;
+
+use PVE::Network::SDN::Fabrics;
+
+sub delete_fabric {
+    my ($type, $param) = @_;
+
+    my $fabrics = PVE::Network::SDN::Fabrics::get_config($type);
+    $fabrics->delete_fabric($param);
+    PVE::Network::SDN::Fabrics::write_config($fabrics);
+    return $fabrics->get_inner();
+}
+
+sub delete_node {
+    my ($type, $param) = @_;
+
+    my $fabrics = PVE::Network::SDN::Fabrics::get_config($type);
+    $fabrics->delete_node($param);
+    PVE::Network::SDN::Fabrics::write_config($fabrics);
+    return $fabrics->get_inner();
+}
+
+sub delete_interface {
+    my ($type, $param) = @_;
+
+    my $fabrics = PVE::Network::SDN::Fabrics::get_config($type);
+    $fabrics->delete_interface($param);
+    PVE::Network::SDN::Fabrics::write_config($fabrics);
+    return $fabrics->get_inner();
+}
+
+sub add_node {
+    my ($type, $param) = @_;
+
+    my $fabrics = PVE::Network::SDN::Fabrics::get_config($type);
+    $fabrics->add_node($param);
+    PVE::Network::SDN::Fabrics::write_config($fabrics);
+
+    return $fabrics->get_inner();
+}
+
+sub add_fabric {
+    my ($type, $param) = @_;
+
+    my $fabrics = PVE::Network::SDN::Fabrics::get_config($type);
+    $fabrics->add_fabric($param);
+    PVE::Network::SDN::Fabrics::write_config($fabrics);
+
+    return $fabrics->get_inner();
+}
+
+sub get_fabric {
+    my ($type, $param) = @_;
+
+    my $fabrics = PVE::Network::SDN::Fabrics::get_config($type);
+    my $return_value = $fabrics->get_fabric($param->{fabric});
+    # Add the fabric id to the return value. The rust return value doesn't contain 
+    # the fabric name (as it's in the key of the section config hashmap, so we add it here).
+    $return_value->{fabric}->{name} = $param->{fabric};
+    return $return_value;
+}
+
+sub get_node {
+    my ($type, $param) = @_;
+
+    my $fabrics = PVE::Network::SDN::Fabrics::get_config($type);
+    my $return_value = $fabrics->get_node($param->{fabric}, $param->{node});
+    # Add the node id to the return value. The rust return value doesn't contain 
+    # the nodename (as it's in the key of the section config hashmap, so we add it here).
+    $return_value->{node}->{node} = $param->{node};
+    return $return_value;
+}
+
+sub get_interface {
+    my ($type, $param) = @_;
+
+    my $fabrics = PVE::Network::SDN::Fabrics::get_config($type);
+    return $fabrics->get_interface($param->{fabric}, $param->{node}, $param->{name});
+}
+
+sub edit_fabric {
+    my ($type, $param) = @_;
+
+    my $fabrics = PVE::Network::SDN::Fabrics::get_config($type);
+    $fabrics->edit_fabric($param);
+    PVE::Network::SDN::Fabrics::write_config($fabrics);
+    return $fabrics->get_inner();
+}
+
+sub edit_node {
+    my ($type, $param) = @_;
+
+    my $fabrics = PVE::Network::SDN::Fabrics::get_config($type);
+    $fabrics->edit_node($param);
+    PVE::Network::SDN::Fabrics::write_config($fabrics);
+    return $fabrics->get_inner();
+}
+
+sub edit_interface {
+    my ($type, $param) = @_;
+
+    my $fabrics = PVE::Network::SDN::Fabrics::get_config($type);
+    $fabrics->edit_interface($param);
+    PVE::Network::SDN::Fabrics::write_config($fabrics);
+    return $fabrics->get_inner();
+}
+
+1;
diff --git a/src/PVE/API2/Network/SDN/Fabrics/Makefile b/src/PVE/API2/Network/SDN/Fabrics/Makefile
new file mode 100644
index 000000000000..e433f2e7d0a6
--- /dev/null
+++ b/src/PVE/API2/Network/SDN/Fabrics/Makefile
@@ -0,0 +1,9 @@
+SOURCES=OpenFabric.pm Ospf.pm Common.pm
+
+
+PERL5DIR=${DESTDIR}/usr/share/perl5
+
+.PHONY: install
+install:
+	for i in ${SOURCES}; do install -D -m 0644 $$i ${PERL5DIR}/PVE/API2/Network/SDN/Fabrics/$$i; done
+
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..626893aa61b7
--- /dev/null
+++ b/src/PVE/API2/Network/SDN/Fabrics/OpenFabric.pm
@@ -0,0 +1,460 @@
+package PVE::API2::Network::SDN::Fabrics::OpenFabric;
+
+use strict;
+use warnings;
+
+use Storable qw(dclone);
+
+use PVE::RPCEnvironment;
+use PVE::Tools qw(extract_param);
+
+use PVE::Network::SDN::Fabrics;
+use PVE::API2::Network::SDN::Fabrics::Common;
+
+use PVE::RESTHandler;
+use base qw(PVE::RESTHandler);
+
+__PACKAGE__->register_method({
+    name => 'delete_fabric',
+    path => '{fabric}',
+    method => 'DELETE',
+    description => 'Delete SDN Fabric',
+    protected => 1,
+    permissions => {
+	check => ['perm', '/sdn/fabrics/openfabric/{fabric}', [ 'SDN.Allocate' ]],
+    },
+    parameters => {
+    	additionalProperties => 1,
+	properties => {
+	    fabric => {
+		type => 'string',
+	    },
+	},
+    },
+    returns => {
+	type => 'object',
+	properties => {
+	    data => {
+		type => 'object',
+	    }
+	}
+    },
+    code => sub {
+	my ($param) = @_;
+
+	return PVE::API2::Network::SDN::Fabrics::Common::delete_fabric("openfabric", $param);
+    },
+});
+
+__PACKAGE__->register_method({
+    name => 'delete_node',
+    path => '{fabric}/node/{node}',
+    method => 'DELETE',
+    description => 'Delete SDN Fabric Node',
+    protected => 1,
+    permissions => {
+	check => ['perm', '/sdn/fabrics/openfabric/{fabric}/node/{node}', [ 'SDN.Allocate' ]],
+    },
+    parameters => {
+    	additionalProperties => 1,
+	properties => {
+	    fabric => {
+		type => 'string',
+	    },
+	    node => {
+		type => 'string',
+	    },
+	},
+    },
+    returns => {
+	type => 'object',
+	properties => {
+	    data => {
+		type => 'object',
+	    }
+	}
+    },
+    code => sub {
+	my ($param) = @_;
+
+	return PVE::API2::Network::SDN::Fabrics::Common::delete_node("openfabric", $param);
+    },
+});
+
+__PACKAGE__->register_method({
+    name => 'delete_interface',
+    path => '{fabric}/node/{node}/interface/{name}',
+    method => 'DELETE',
+    description => 'Delete SDN Fabric Node Interface',
+    protected => 1,
+    permissions => {
+	check => ['perm', '/sdn/fabrics/openfabric/{fabric}/node/{node}/interface/{name}', [ 'SDN.Allocate' ]],
+    },
+    parameters => {
+    	additionalProperties => 1,
+	properties => {
+	    fabric => {
+		type => 'string',
+	    },
+	    node => {
+		type => 'string',
+	    },
+	    name => {
+		type => 'string',
+	    },
+	},
+    },
+    returns => {
+	type => 'object',
+    },
+    code => sub {
+	my ($param) = @_;
+
+	return PVE::API2::Network::SDN::Fabrics::Common::delete_interface("openfabric", $param);
+    },
+});
+
+__PACKAGE__->register_method({
+    name => 'update_fabric',
+    path => '{fabric}',
+    method => 'PUT',
+    description => 'Update SDN Fabric configuration',
+    protected => 1,
+    permissions => {
+	check => ['perm', '/sdn/fabrics/openfabric/{fabric}', [ 'SDN.Allocate' ]],
+    },
+    parameters => {
+	additionalProperties => 1,
+	properties => {
+	    fabric => {
+		type => 'string'
+	    },
+	    hello_interval => {
+		type => 'integer',
+	    },
+	},
+    },
+    returns => {
+	type => 'object',
+	properties => {
+	    data => {
+		type => 'object',
+	    }
+	}
+    },
+    code => sub {
+	my ($param) = @_;
+
+	return PVE::API2::Network::SDN::Fabrics::Common::edit_fabric("openfabric", $param);
+    },
+});
+
+__PACKAGE__->register_method({
+    name => 'update_node',
+    path => '{fabric}/node/{node}',
+    method => 'PUT',
+    description => 'Update SDN Fabric Node configuration',
+    protected => 1,
+    permissions => {
+	check => ['perm', '/sdn/fabrics/openfabric/{fabric}/node/{node}', [ 'SDN.Allocate' ]],
+    },
+    parameters => {
+	additionalProperties => 1,
+	properties => {
+	    fabric => {
+		type => 'string',
+	    },
+	    node => {
+		type => 'string',
+	    },
+	    net => {
+		type => 'string',
+	    },
+	    interfaces => {
+		type => 'array',
+		items => {
+		    type => 'string',
+		},
+	    },
+	},
+    },
+    returns => {
+	type => 'object',
+	properties => {
+	    data => {
+		type => 'object',
+	    }
+	}
+    },
+    code => sub {
+	my ($param) = @_;
+
+	return PVE::API2::Network::SDN::Fabrics::Common::edit_node("openfabric", $param);
+    },
+});
+
+__PACKAGE__->register_method({
+    name => 'update_interface',
+    path => '{fabric}/node/{node}/interface/{name}',
+    method => 'PUT',
+    description => 'Update SDN Fabric Interface configuration',
+    protected => 1,
+    permissions => {
+	check => ['perm', '/sdn/fabrics/openfabric/{fabric}/node/{node}/interface/{name}', [ 'SDN.Allocate' ]],
+    },
+    parameters => {
+       additionalProperties => 1,
+	properties => {
+	    fabric => {
+		type => 'string',
+	    },
+	    node => {
+		type => 'string',
+	    },
+	    name => {
+		type => 'string',
+	    },
+	    passive => {
+		type => 'boolean',
+	    },
+	    hello_interval => {
+		optional => 1,
+		type => 'string',
+	    },
+	    hello_multiplier => {
+		optional => 1,
+		type => 'string',
+	    },
+	    csnp_interval => {
+		optional => 1,
+		type => 'string',
+	    },
+	},
+    },
+    returns => {
+	type => 'object',
+	properties => {
+	    data => {
+		type => 'object',
+	    }
+	}
+    },
+    code => sub {
+	my ($param) = @_;
+
+	return PVE::API2::Network::SDN::Fabrics::Common::edit_interface("openfabric", $param);
+    },
+});
+
+
+__PACKAGE__->register_method({
+    name => 'get_fabric',
+    path => '{fabric}',
+    method => 'GET',
+    description => 'Get SDN Fabric configuration',
+    permissions => {
+	check => ['perm', '/sdn/fabrics/openfabric/{fabric}', [ 'SDN.Allocate' ]],
+    },
+    parameters => {
+    	additionalProperties => 1,
+	properties => {}
+    },
+    returns => {
+	type => 'object',
+	properties => {
+	    data => {
+		type => 'object',
+		properties => {
+		    fabric => {
+			type => 'object',
+			properties => {
+			    name => {
+				type => 'string'
+			    }
+			}
+		    }
+		}
+	    }
+	}
+    },
+    code => sub {
+	my ($param) = @_;
+
+	return PVE::API2::Network::SDN::Fabrics::Common::get_fabric("openfabric", $param);
+    },
+});
+
+__PACKAGE__->register_method({
+    name => 'get_node',
+    path => '{fabric}/node/{node}',
+    method => 'GET',
+    description => 'Get SDN Fabric Node configuration',
+    permissions => {
+	check => ['perm', '/sdn/fabrics/openfabric/{fabric}', [ 'SDN.Allocate' ]],
+    },
+    parameters => {
+    	additionalProperties => 1,
+       properties => {}
+    },
+    returns => {
+	type => 'object',
+	properties => {
+	    data => {
+		type => 'object',
+		properties => {
+		    node => {
+			type => 'object',
+			properties => {
+			    net => {
+				type => 'string',
+			    },
+			    node => {
+				type => 'string',
+			    },
+			    interface => {
+				type => 'array',
+				items => {
+				    type => 'string'
+				}
+			    },
+			}
+		    }
+		}
+	    }
+	}
+    },
+    code => sub {
+	my ($param) = @_;
+
+	return PVE::API2::Network::SDN::Fabrics::Common::get_node("openfabric", $param);
+    },
+});
+
+
+__PACKAGE__->register_method({
+    name => 'get_interface',
+    path => '{fabric}/node/{node}/interface/{name}',
+    method => 'GET',
+    description => 'Get SDN Fabric Interface configuration',
+    permissions => {
+	check => ['perm', '/sdn/fabrics/openfabric/{fabric}', [ 'SDN.Allocate' ]],
+    },
+    parameters => {
+       additionalProperties => 1,
+    },
+    returns => {
+	type => 'object',
+	properties => {
+	    data => {
+		type => 'object',
+		properties => {
+		    name => {
+			type => 'string',
+		    },
+		    passive => {
+			type => 'boolean',
+		    },
+		    hello_interval => {
+			optional => 1,
+			type => 'number',
+		    },
+		    hello_multiplier => {
+			optional => 1,
+			type => 'number',
+		    },
+		    csnp_interval => {
+			optional => 1,
+			type => 'number',
+		    },
+		}
+	    }
+	}
+    },
+    code => sub {
+	my ($param) = @_;
+
+	return PVE::API2::Network::SDN::Fabrics::Common::get_interface("openfabric", $param);
+    },
+});
+
+
+__PACKAGE__->register_method({
+    name => 'add_fabric',
+    path => '/',
+    method => 'POST',
+    description => 'Create SDN Fabric configuration',
+    protected => 1,
+    permissions => {
+	check => ['perm', '/sdn/fabrics/openfabric', [ 'SDN.Allocate' ]],
+    },
+    parameters => {
+    	additionalProperties => 1,
+	properties => {
+	    "type" => {
+		type => 'string',
+	    },
+	    "name" => {
+		type => 'string',
+	    },
+	},
+    },
+    returns => {
+	type => 'object',
+	properties => {
+	    data => {
+		type => 'object',
+	    }
+	}
+    },
+    code => sub {
+	my ($param) = @_;
+
+	return PVE::API2::Network::SDN::Fabrics::Common::add_fabric("openfabric", $param);
+    },
+});
+
+__PACKAGE__->register_method({
+    name => 'add_node',
+    path => '{fabric}/node/{node}',
+    method => 'POST',
+    description => 'Create SDN Fabric Node configuration',
+    protected => 1,
+    permissions => {
+	check => ['perm', '/sdn/fabrics/openfabric/{fabric}/node/{node}', [ 'SDN.Allocate' ]],
+    },
+    parameters => {
+    	additionalProperties => 1,
+	properties => {
+	    fabric => {
+		type => 'string',
+	    },
+	    node => {
+		type => 'string',
+	    },
+	    net => {
+		type => 'string',
+	    },
+	    interfaces => {
+		type => 'array',
+		items => {
+		    type => 'string',
+		},
+	    },
+	},
+    },
+    returns => {
+	type => 'object',
+	properties => {
+	    data => {
+		type => 'object',
+	    }
+	}
+    },
+    code => sub {
+	my ($param) = @_;
+
+	return PVE::API2::Network::SDN::Fabrics::Common::add_node("openfabric", $param);
+    },
+});
+
+1;
diff --git a/src/PVE/API2/Network/SDN/Fabrics/Ospf.pm b/src/PVE/API2/Network/SDN/Fabrics/Ospf.pm
new file mode 100644
index 000000000000..309d29788667
--- /dev/null
+++ b/src/PVE/API2/Network/SDN/Fabrics/Ospf.pm
@@ -0,0 +1,433 @@
+package PVE::API2::Network::SDN::Fabrics::Ospf;
+
+use strict;
+use warnings;
+
+use Storable qw(dclone);
+
+use PVE::RPCEnvironment;
+use PVE::Tools qw(extract_param);
+
+use PVE::Network::SDN::Fabrics;
+use PVE::API2::Network::SDN::Fabrics::Common;
+
+use PVE::RESTHandler;
+use base qw(PVE::RESTHandler);
+
+__PACKAGE__->register_method({
+    name => 'delete_fabric',
+    path => '{fabric}',
+    method => 'DELETE',
+    description => 'Delete SDN Fabric',
+    protected => 1,
+    permissions => {
+	check => ['perm', '/sdn/fabrics/ospf/{fabric}', [ 'SDN.Allocate' ]],
+    },
+    parameters => {
+    	additionalProperties => 1,
+	properties => {
+	    fabric => {
+		type => 'string',
+	    },
+	},
+    },
+    returns => {
+	type => 'object',
+	properties => {
+	    data => {
+		type => 'object',
+	    }
+	}
+    },
+    code => sub {
+	my ($param) = @_;
+
+	return PVE::API2::Network::SDN::Fabrics::Common::delete_fabric("ospf", $param);
+    },
+});
+
+__PACKAGE__->register_method({
+    name => 'delete_node',
+    path => '{fabric}/node/{node}',
+    method => 'DELETE',
+    description => 'Delete SDN Fabric Node',
+    protected => 1,
+    permissions => {
+	check => ['perm', '/sdn/fabrics/ospf/{fabric}/node/{node}', [ 'SDN.Allocate' ]],
+    },
+    parameters => {
+    	additionalProperties => 1,
+	properties => {
+	    fabric => {
+		type => 'string',
+	    },
+	    node => {
+		type => 'string',
+	    },
+	},
+    },
+    returns => {
+	type => 'object',
+	properties => {
+	    data => {
+		type => 'object',
+	    }
+	}
+    },
+    code => sub {
+	my ($param) = @_;
+
+	return PVE::API2::Network::SDN::Fabrics::Common::delete_node("ospf", $param);
+    },
+});
+
+__PACKAGE__->register_method({
+    name => 'delete_interface',
+    path => '{fabric}/node/{node}/interface/{name}',
+    method => 'DELETE',
+    description => 'Delete SDN Fabric Node Interface',
+    protected => 1,
+    permissions => {
+	check => ['perm', '/sdn/fabrics/ospf/{fabric}/node/{node}/interface/{name}', [ 'SDN.Allocate' ]],
+    },
+    parameters => {
+    	additionalProperties => 1,
+	properties => {
+	    fabric => {
+		type => 'string',
+	    },
+	    node => {
+		type => 'string',
+	    },
+	    name => {
+		type => 'string',
+	    },
+	},
+    },
+    returns => {
+	type => 'null',
+    },
+    code => sub {
+	my ($param) = @_;
+
+	return PVE::API2::Network::SDN::Fabrics::Common::delete_interface("ospf", $param);
+    },
+});
+
+__PACKAGE__->register_method({
+    name => 'update_fabric',
+    path => '{fabric}',
+    method => 'PUT',
+    description => 'Update SDN Fabric configuration',
+    protected => 1,
+    permissions => {
+	check => ['perm', '/sdn/fabrics/ospf/{fabric}', [ 'SDN.Allocate' ]],
+    },
+    parameters => {
+	additionalProperties => 1,
+	properties => {
+	    fabric => {
+		type => 'string'
+	    },
+	},
+    },
+    returns => {
+	type => 'object',
+	properties => {
+	    data => {
+		type => 'object',
+	    }
+	}
+    },
+    code => sub {
+	my ($param) = @_;
+
+	return PVE::API2::Network::SDN::Fabrics::Common::edit_fabric("ospf", $param);
+    },
+});
+
+__PACKAGE__->register_method({
+    name => 'update_node',
+    path => '{fabric}/node/{node}',
+    method => 'PUT',
+    description => 'Update SDN Fabric Interface configuration',
+    protected => 1,
+    permissions => {
+	check => ['perm', '/sdn/fabrics/ospf/{fabric}', [ 'SDN.Allocate' ]],
+    },
+    parameters => {
+	additionalProperties => 1,
+	properties => {
+	    fabric => {
+		type => 'string',
+	    },
+	    node => {
+		type => 'string',
+	    },
+	    router_id => {
+		type => 'string',
+	    },
+	    interfaces => {
+		type => 'array',
+		items => {
+		    type => 'string',
+		},
+	    },
+	},
+    },
+    returns => {
+	type => 'object',
+	properties => {
+	    data => {
+		type => 'object',
+	    }
+	}
+    },
+    code => sub {
+	my ($param) = @_;
+
+	return PVE::API2::Network::SDN::Fabrics::Common::edit_node("ospf", $param);
+    },
+});
+
+__PACKAGE__->register_method({
+    name => 'update_interface',
+    path => '{fabric}/node/{node}/interface/{name}',
+    method => 'PUT',
+    description => 'Update SDN Fabric Interface configuration',
+    protected => 1,
+    permissions => {
+	check => ['perm', '/sdn/fabrics/ospf/{fabric}/node/{node}/interface/{name}', [ 'SDN.Allocate' ]],
+    },
+    parameters => {
+       additionalProperties => 1,
+	properties => {
+	    fabric => {
+		type => 'string',
+	    },
+	    node => {
+		type => 'string',
+	    },
+	    name => {
+		type => 'string',
+	    },
+	    passive => {
+		type => 'boolean',
+	    },
+	},
+    },
+    returns => {
+	type => 'object',
+	properties => {
+	    data => {
+		type => 'object',
+	    }
+	}
+    },
+    code => sub {
+	my ($param) = @_;
+
+	return PVE::API2::Network::SDN::Fabrics::Common::edit_interface("ospf", $param);
+    },
+});
+
+__PACKAGE__->register_method({
+    name => 'get_fabric',
+    path => '{fabric}',
+    method => 'GET',
+    description => 'Get SDN Fabric configuration',
+    permissions => {
+	check => ['perm', '/sdn/fabrics/ospf/{fabric}', [ 'SDN.Allocate' ]],
+    },
+    parameters => {
+	additionalProperties => 1,
+	properties => {}
+    },
+    returns => {
+	type => 'object',
+	properties => {
+	    data => {
+		type => 'object',
+		properties => {
+		    fabric => {
+			type => 'object',
+			properties => {
+			    name => {
+				type => 'string'
+			    }
+			}
+		    }
+		}
+	    }
+	}
+    },
+    code => sub {
+	my ($param) = @_;
+
+	return PVE::API2::Network::SDN::Fabrics::Common::get_fabric("ospf", $param);
+    },
+});
+
+__PACKAGE__->register_method({
+    name => 'get_node',
+    path => '{fabric}/node/{node}',
+    method => 'GET',
+    description => 'Get SDN Fabric Node configuration',
+    permissions => {
+	check => ['perm', '/sdn/fabrics/ospf/{fabric}', [ 'SDN.Allocate' ]],
+    },
+    parameters => {
+    	additionalProperties => 1,
+       properties => {}
+    },
+    returns => {
+	type => 'object',
+	properties => {
+	    data => {
+		type => 'object',
+		properties => {
+		    node => {
+			type => 'object',
+			properties => {
+			    router_id => {
+				type => 'string',
+			    },
+			    node => {
+				type => 'string',
+			    },
+			    interface => {
+				type => 'array',
+				items => {
+				    type => 'string'
+				}
+			    },
+			}
+		    }
+		}
+	    }
+	}
+    },
+    code => sub {
+	my ($param) = @_;
+
+	return PVE::API2::Network::SDN::Fabrics::Common::get_node("ospf", $param);
+    },
+});
+
+
+__PACKAGE__->register_method({
+    name => 'get_interface',
+    path => '{fabric}/node/{node}/interface/{name}',
+    method => 'GET',
+    description => 'Get SDN Fabric Interface configuration',
+    permissions => {
+	check => ['perm', '/sdn/fabrics/ospf/{fabric}', [ 'SDN.Allocate' ]],
+    },
+    parameters => {
+       additionalProperties => 1,
+    },
+    returns => {
+	type => 'object',
+	properties => {
+	    data => {
+		type => 'object',
+		properties => {
+		    name => {
+			type => 'string',
+		    },
+		    passive => {
+			type => 'boolean',
+		    },
+		}
+	    }
+	}
+    },
+    code => sub {
+	my ($param) = @_;
+
+	return PVE::API2::Network::SDN::Fabrics::Common::get_interface("ospf", $param);
+    },
+});
+
+
+__PACKAGE__->register_method({
+    name => 'add_fabric',
+    path => '/',
+    method => 'POST',
+    description => 'Create SDN Fabric configuration',
+    protected => 1,
+    permissions => {
+	check => ['perm', '/sdn/fabrics/ospf', [ 'SDN.Allocate' ]],
+    },
+    parameters => {
+    	additionalProperties => 1,
+	properties => {
+	    "type" => {
+		type => 'string',
+	    },
+	    "name" => {
+		type => 'string',
+	    },
+	},
+    },
+    returns => {
+	type => 'object',
+	properties => {
+	    data => {
+		type => 'object',
+	    }
+	}
+    },
+    code => sub {
+	my ($param) = @_;
+
+	return PVE::API2::Network::SDN::Fabrics::Common::add_fabric("ospf", $param);
+    },
+});
+
+__PACKAGE__->register_method({
+    name => 'add_node',
+    path => '{fabric}/node/{node}',
+    method => 'POST',
+    description => 'Create SDN Fabric Node configuration',
+    protected => 1,
+    permissions => {
+	check => ['perm', '/sdn/fabrics/ospf/{fabric}/node/{node}', [ 'SDN.Allocate' ]],
+    },
+    parameters => {
+    	additionalProperties => 1,
+	properties => {
+	    fabric => {
+		type => 'string',
+	    },
+	    node => {
+		type => 'string',
+	    },
+	    router_id => {
+		type => 'string',
+	    },
+	    interfaces => {
+		type => 'array',
+		items => {
+		    type => 'string',
+		},
+	    },
+	},
+    },
+    returns => {
+	type => 'object',
+	properties => {
+	    data => {
+		type => 'object',
+	    }
+	}
+    },
+    code => sub {
+	my ($param) = @_;
+
+	return PVE::API2::Network::SDN::Fabrics::Common::add_node("ospf", $param);
+    },
+});
+
+
+1;
diff --git a/src/PVE/API2/Network/SDN/Makefile b/src/PVE/API2/Network/SDN/Makefile
index abd1bfae020e..08bec7535530 100644
--- a/src/PVE/API2/Network/SDN/Makefile
+++ b/src/PVE/API2/Network/SDN/Makefile
@@ -1,4 +1,4 @@
-SOURCES=Vnets.pm Zones.pm Controllers.pm Subnets.pm Ipams.pm Dns.pm Ips.pm
+SOURCES=Vnets.pm Zones.pm Controllers.pm Subnets.pm Ipams.pm Dns.pm Ips.pm Fabrics.pm
 
 
 PERL5DIR=${DESTDIR}/usr/share/perl5
@@ -7,4 +7,5 @@ PERL5DIR=${DESTDIR}/usr/share/perl5
 install:
 	for i in ${SOURCES}; do install -D -m 0644 $$i ${PERL5DIR}/PVE/API2/Network/SDN/$$i; done
 	make -C Zones install
+	make -C Fabrics install
 
-- 
2.39.5



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


  parent reply	other threads:[~2025-02-14 13:41 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-14 13:39 [pve-devel] [RFC cluster/manager/network/proxmox{-ve-rs, -perl-rs} 00/11] Add SDN Fabrics Gabriel Goller
2025-02-14 13:39 ` [pve-devel] [PATCH proxmox-ve-rs 01/11] add crate with common network types Gabriel Goller
2025-03-03 15:08   ` Stefan Hanreich
2025-03-05  8:28     ` Gabriel Goller
2025-02-14 13:39 ` [pve-devel] [PATCH proxmox-ve-rs 02/11] add proxmox-frr crate with frr types Gabriel Goller
2025-03-03 16:29   ` Stefan Hanreich
2025-03-04 16:28     ` Gabriel Goller
2025-02-14 13:39 ` [pve-devel] [PATCH proxmox-ve-rs 03/11] add intermediate fabric representation Gabriel Goller
2025-02-28 13:57   ` Thomas Lamprecht
2025-02-28 16:19     ` Gabriel Goller
2025-03-04 17:30     ` Gabriel Goller
2025-03-05  9:03       ` Wolfgang Bumiller
2025-03-04  8:45   ` Stefan Hanreich
2025-03-05  9:09     ` Gabriel Goller
2025-02-14 13:39 ` [pve-devel] [PATCH proxmox-perl-rs 04/11] fabrics: add CRUD and generate fabrics methods Gabriel Goller
2025-03-04  9:28   ` Stefan Hanreich
2025-03-05 10:20     ` Gabriel Goller
2025-02-14 13:39 ` [pve-devel] [PATCH pve-cluster 05/11] cluster: add sdn fabrics config files Gabriel Goller
2025-02-28 12:19   ` Thomas Lamprecht
2025-02-28 12:52     ` Gabriel Goller
2025-02-14 13:39 ` [pve-devel] [PATCH pve-network 06/11] add config file and common read/write methods Gabriel Goller
2025-02-14 13:39 ` [pve-devel] [PATCH pve-network 07/11] merge the frr config with the fabrics frr config on apply Gabriel Goller
2025-02-14 13:39 ` Gabriel Goller [this message]
2025-03-04  9:51   ` [pve-devel] [PATCH pve-network 08/11] add api endpoints for fabrics Stefan Hanreich
2025-02-14 13:39 ` [pve-devel] [PATCH pve-manager 09/11] sdn: add Fabrics view Gabriel Goller
2025-03-04  9:57   ` Stefan Hanreich
2025-03-07 15:57     ` Gabriel Goller
2025-02-14 13:39 ` [pve-devel] [PATCH pve-manager 10/11] sdn: add fabric edit/delete forms Gabriel Goller
2025-03-04 10:07   ` Stefan Hanreich
2025-03-07 16:04     ` Gabriel Goller
2025-02-14 13:39 ` [pve-devel] [PATCH pve-manager 11/11] network: return loopback interface on network endpoint Gabriel Goller
2025-03-03 16:58 ` [pve-devel] [RFC cluster/manager/network/proxmox{-ve-rs, -perl-rs} 00/11] Add SDN Fabrics Stefan Hanreich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250214133951.344500-9-g.goller@proxmox.com \
    --to=g.goller@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal