[pve-devel] [RFC PATCH] api: network: add return schema for interface listing

Thomas Lamprecht t.lamprecht at proxmox.com
Thu Dec 5 09:43:07 CET 2024


Am 05.12.24 um 09:27 schrieb Dominik Csapak:
> Most optiosn come from the api call parameter list
> (`json_config_properties`). The description and types for the remaining
> ons are either taken from the manpages, source code or similar
> documentation where available.
> 
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
> sending as RFC because some descriptions are very barebones due to lack
> of documentation on the specific properties (link-type, vxlan-*, etc.)
> 
> @s.hahnreich, maybe could you take a look at these and expand on some of
> them?
> 
>  PVE/API2/Network.pm | 97 ++++++++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 95 insertions(+), 2 deletions(-)
> 
> diff --git a/PVE/API2/Network.pm b/PVE/API2/Network.pm
> index b9db9b27..df3db5af 100644
> --- a/PVE/API2/Network.pm
> +++ b/PVE/API2/Network.pm
> @@ -38,7 +38,7 @@ my $bond_mode_enum = [
>      ];
>  
>  my $network_type_enum = ['bridge', 'bond', 'eth', 'alias', 'vlan',
> -			 'OVSBridge', 'OVSBond', 'OVSPort', 'OVSIntPort'];
> +			 'OVSBridge', 'OVSBond', 'OVSPort', 'OVSIntPort', 'vnet'];
>  
>  my $confdesc = {
>      type => {
> @@ -223,7 +223,100 @@ __PACKAGE__->register_method({
>  	type => "array",
>  	items => {
>  	    type => "object",
> -	    properties => {},
> +	    properties => json_config_properties({
> +		iface => get_standard_option('pve-iface'),
> +		active => {
> +		    type => 'boolean',
> +		    optional => 1,
> +		    description => "Set to 1 if the interface is active.",

some rather higher level and certainly pre-existing in quite a few places, but might
it be better to do s/1/true/ here? IIRC the API accepts both IIRC, so not really a
problem if the user takes this literally, 

Some extra checking would be certainly good, but FWIW, if there's not something totally
amiss here (@Stefan Hanreich) then I could apply this now and we improve descriptions
later™.




More information about the pve-devel mailing list