[pve-devel] [PATCH pve-manager 1/2] api2 : cluster: add sdn api endpoint

Thomas Lamprecht t.lamprecht at proxmox.com
Mon Jun 24 07:31:03 CEST 2019


On 6/21/19 3:54 PM, Alexandre Derumier wrote:
> Signed-off-by: Alexandre Derumier <aderumier at odiso.com>

I would really like to avoid any hard dependency for now, until this
is not more ready and more tested (@Stoiko ;)).

But, to not hinder you to much we could go a "include and register
API if it's installed" approach, e.g., someting like pve-firewall
does for qemu-server and container (it does it for other reasons but,
the principle would stay the same):

https://git.proxmox.com/?p=pve-firewall.git;a=blob;f=src/PVE/Firewall.pm;h=b08cea57312b9e6a54680e24abced4e4de4c47be;hb=HEAD#l30

So do a guarded include, if it works also register the SDN api
endpoint and return the "sdn" entry in the index call. With that one
would simply needs to install pve-network to make the API available and
test it quite easily. Would that sound OK for you?

> ---
>  PVE/API2/Cluster.pm | 7 +++++++
>  debian/control      | 1 +
>  2 files changed, 8 insertions(+)
> 
> diff --git a/PVE/API2/Cluster.pm b/PVE/API2/Cluster.pm
> index 8af5f3f0..c826aecf 100644
> --- a/PVE/API2/Cluster.pm
> +++ b/PVE/API2/Cluster.pm
> @@ -23,6 +23,7 @@ use PVE::Firewall;
>  use PVE::API2::Firewall::Cluster;
>  use PVE::API2::ReplicationConfig;
>  use PVE::API2::ACMEAccount;
> +use PVE::API2::Network::SDN;
>  
>  use base qw(PVE::RESTHandler);
>  
> @@ -56,6 +57,11 @@ __PACKAGE__->register_method ({
>      path => 'acme',
>  });
>  
> +__PACKAGE__->register_method ({
> +    subclass => "PVE::API2::Network::SDN",
> +    path => 'sdn',
> +});
> +
>  my $dc_schema = PVE::Cluster::get_datacenter_schema();
>  my $dc_properties = { 
>      delete => {
> @@ -103,6 +109,7 @@ __PACKAGE__->register_method ({
>  	    { name => 'config' },
>  	    { name => 'acme' },
>  	    { name => 'ceph' },
> +	    { name => 'sdn' },
>  	    ];
>  
>  	return $result;
> diff --git a/debian/control b/debian/control
> index 9ab0a7cd..1d94d3c8 100644
> --- a/debian/control
> +++ b/debian/control
> @@ -47,6 +47,7 @@ Depends: apt-transport-https,
>           libpve-guest-common-perl (>= 2.0-14),
>           libpve-http-server-perl (>= 2.0-12),
>           libpve-storage-perl (>= 6.0-1),
> +         libpve-network-perl,
>           librados2-perl,
>           libtemplate-perl,
>           libterm-readline-gnu-perl,
> 





More information about the pve-devel mailing list