[pve-devel] [PATCH v3 pve-manager 3/4] api2 : nodes : use zones api status

Thomas Lamprecht t.lamprecht at proxmox.com
Tue Nov 26 17:34:44 CET 2019


On 11/26/19 3:20 PM, Alexandre Derumier wrote:
> Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
> ---
>  PVE/API2/Nodes.pm | 8 +++++---
>  1 file changed, 5 insertions(+), 3 deletions(-)
> 
> diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
> index ddeafbef..93caf66f 100644
> --- a/PVE/API2/Nodes.pm
> +++ b/PVE/API2/Nodes.pm
> @@ -54,7 +54,7 @@ use Socket;
>  
>  my $have_sdn;
>  eval {
> -    require PVE::API2::Network::SDN::Status;
> +    require PVE::API2::Network::SDN::Zones::Status;
>      $have_sdn = 1;
>  };
>  
> @@ -149,8 +149,8 @@ __PACKAGE__->register_method ({
>  
>  if ($have_sdn) {
>      __PACKAGE__->register_method ({
> -	subclass => "PVE::API2::Network::SDN::Status",
> -	path => 'sdn',
> +	subclass => "PVE::API2::Network::SDN::Zones::Status",
> +	path => 'sdn/zones',
>      });
>  }
>  
> @@ -214,6 +214,8 @@ __PACKAGE__->register_method ({
>  	    { name => 'hosts' },
>  	];
>  
> +	push @$result, { name => 'sdn' } if $have_sdn;
> +
>  	return $result;
>      }});
>  
> 

doesn't this additionally needs a intermediate path registry for sdn/
itself? E.g., something like:

----8<----
diff --git a/PVE/API2/Nodes.pm b/PVE/API2/Nodes.pm
index 93caf66f..c3f64699 100644
--- a/PVE/API2/Nodes.pm
+++ b/PVE/API2/Nodes.pm
@@ -152,6 +152,35 @@ if ($have_sdn) {
        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 ({
---

Else I do not see this in the API path traversal?




More information about the pve-devel mailing list