[pve-devel] [PATCH pve-manager 1/8] api: nodes: use new status module for sdn subdirectory

Stefan Hanreich s.hanreich at proxmox.com
Thu Oct 30 16:48:35 CET 2025


In order to avoid having to import every single new module for future
status reporting, SDN now exposes a single module that is imported
here.

Also remove the legacy have_sdn guards here, since SDN is
pre-installed for awhile and the guard therefore not needed anymore.

Signed-off-by: Stefan Hanreich <s.hanreich at proxmox.com>
---
 PVE/API2/Nodes.pm | 50 ++++++-----------------------------------------
 1 file changed, 6 insertions(+), 44 deletions(-)

diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
index 4590b6186..08d9d1b51 100644
--- a/PVE/API2/Nodes.pm
+++ b/PVE/API2/Nodes.pm
@@ -49,6 +49,7 @@ use PVE::API2::Hardware;
 use PVE::API2::LXC::Status;
 use PVE::API2::LXC;
 use PVE::API2::Network;
+use PVE::API2::Network::SDN::Nodes::Status;
 use PVE::API2::NodeConfig;
 use PVE::API2::Qemu::CPU;
 use PVE::API2::Qemu;
@@ -60,12 +61,6 @@ use PVE::API2::Subscription;
 use PVE::API2::Tasks;
 use PVE::API2::VZDump;
 
-my $have_sdn;
-eval {
-    require PVE::API2::Network::SDN::Zones::Status;
-    $have_sdn = 1;
-};
-
 use base qw(PVE::RESTHandler);
 
 my $verify_command_item_desc = {
@@ -201,42 +196,10 @@ __PACKAGE__->register_method({
     path => 'config',
 });
 
-if ($have_sdn) {
-    __PACKAGE__->register_method({
-        subclass => "PVE::API2::Network::SDN::Zones::Status",
-        path => 'sdn/zones',
-    });
-
-    __PACKAGE__->register_method({
-        name => 'sdnindex',
-        path => 'sdn',
-        method => 'GET',
-        permissions => { user => 'all' },
-        description => "SDN index.",
-        parameters => {
-            additionalProperties => 0,
-            properties => {
-                node => get_standard_option('pve-node'),
-            },
-        },
-        returns => {
-            type => 'array',
-            items => {
-                type => "object",
-                properties => {},
-            },
-            links => [{ rel => 'child', href => "{name}" }],
-        },
-        code => sub {
-            my ($param) = @_;
-
-            my $result = [
-                { name => 'zones' },
-            ];
-            return $result;
-        },
-    });
-}
+__PACKAGE__->register_method({
+    subclass => "PVE::API2::Network::SDN::Nodes::Status",
+    path => 'sdn',
+});
 
 __PACKAGE__->register_method({
     name => 'index',
@@ -285,6 +248,7 @@ __PACKAGE__->register_method({
             { name => 'rrd' }, # fixme: remove?
             { name => 'rrddata' },
             { name => 'scan' },
+            { name => 'sdn' },
             { name => 'services' },
             { name => 'spiceshell' },
             { name => 'startall' },
@@ -303,8 +267,6 @@ __PACKAGE__->register_method({
             { name => 'wakeonlan' },
         ];
 
-        push @$result, { name => 'sdn' } if $have_sdn;
-
         return $result;
     },
 });
-- 
2.47.3




More information about the pve-devel mailing list