all lists on lists.proxmox.com
 help / color / mirror / Atom feed
From: Stefan Hanreich <s.hanreich@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH pve-network 4/5] api: vnets: update schema of endpoints
Date: Fri, 28 Feb 2025 15:01:35 +0100	[thread overview]
Message-ID: <20250228140136.124286-5-s.hanreich@proxmox.com> (raw)
In-Reply-To: <20250228140136.124286-1-s.hanreich@proxmox.com>

The possible properties returned by the vnet endpoints were only
partly documented. Add all missing properties and improve descriptions
for existing properties.

Extract all duplicate properties into a separate variable, so we
don't have to rewrite the whole API definition for every endpoint.

Signed-off-by: Stefan Hanreich <s.hanreich@proxmox.com>
---
 src/PVE/API2/Network/SDN/Vnets.pm | 88 ++++++++++++++++++++++++++++++-
 src/PVE/Network/SDN/VnetPlugin.pm | 37 +++++++------
 2 files changed, 108 insertions(+), 17 deletions(-)

diff --git a/src/PVE/API2/Network/SDN/Vnets.pm b/src/PVE/API2/Network/SDN/Vnets.pm
index bd37dd3..a579c36 100644
--- a/src/PVE/API2/Network/SDN/Vnets.pm
+++ b/src/PVE/API2/Network/SDN/Vnets.pm
@@ -73,6 +73,38 @@ my $check_vnet_access = sub {
     $rpcenv->check_any($authuser, "/sdn/zones/$zoneid/$vnet", $privs);
 };
 
+my $VNET_PROPERTIES = {
+    alias => {
+	type => 'string',
+	description => "Alias name of the VNet.",
+	pattern => qr/[\(\)-_.\w\d\s]{0,256}/i,
+	maxLength => 256,
+	optional => 1,
+    },
+    'isolate-ports' => {
+	type => 'boolean',
+	description => "If true, sets the isolated property for all interfaces on the bridge of this VNet.",
+	optional => 1,
+    },
+    tag => {
+	type => 'integer',
+	description => 'VLAN Tag (for VLAN or QinQ zones) or VXLAN VNI (for VXLAN or EVPN zones).',
+	optional => 1,
+	minimum => 1,
+	maximum => 16777215,
+    },
+    vlanaware => {
+	type => 'boolean',
+	description => 'Allow VLANs to pass through this VNet.',
+	optional => 1,
+    },
+    zone => {
+	type => 'string',
+	description => 'Name of the zone this VNet belongs to.',
+	optional => 1,
+    },
+};
+
 __PACKAGE__->register_method ({
     name => 'index',
     path => '',
@@ -102,7 +134,32 @@ __PACKAGE__->register_method ({
 	type => 'array',
 	items => {
 	    type => "object",
-	    properties => {},
+	    properties => {
+		digest => {
+		    type => 'string',
+		    optional => 1,
+		    description => 'Digest of the VNet section.',
+		},
+		state => get_standard_option('pve-sdn-config-state'),
+		type => {
+		    type => 'string',
+		    enum => ['vnet'],
+		    optional => 0,
+		    description => 'Type of the VNet.',
+		},
+		vnet => {
+		    type => 'string',
+		    optional => 0,
+		    description => 'Name of the VNet.',
+		},
+		pending => {
+		    type => 'object',
+		    description => 'Changes that have not yet been applied to the running configuration.',
+		    optional => 1,
+		    properties => $VNET_PROPERTIES
+		},
+		%$VNET_PROPERTIES,
+	    },
 	},
 	links => [ { rel => 'child', href => "{vnet}" } ],
     },
@@ -165,7 +222,34 @@ __PACKAGE__->register_method ({
 	    },
 	},
     },
-    returns => { type => 'object' },
+    returns => {
+	properties => {
+	    digest => {
+		type => 'string',
+		optional => 1,
+		description => 'Digest of the VNet section.',
+	    },
+	    state => get_standard_option('pve-sdn-config-state'),
+	    type => {
+		type => 'string',
+		enum => ['vnet'],
+		optional => 0,
+		description => 'Type of the VNet.',
+	    },
+	    vnet => {
+		type => 'string',
+		optional => 0,
+		description => 'Name of the VNet.',
+	    },
+	    pending => {
+		type => 'object',
+		description => 'Changes that have not yet been applied to the running configuration.',
+		optional => 1,
+		properties => $VNET_PROPERTIES,
+	    },
+	    %$VNET_PROPERTIES,
+	},
+    },
     code => sub {
 	my ($param) = @_;
 
diff --git a/src/PVE/Network/SDN/VnetPlugin.pm b/src/PVE/Network/SDN/VnetPlugin.pm
index f44380a..1fca9c1 100644
--- a/src/PVE/Network/SDN/VnetPlugin.pm
+++ b/src/PVE/Network/SDN/VnetPlugin.pm
@@ -50,31 +50,38 @@ sub private {
 sub properties {
     return {
 	zone => {
-            type => 'string',
-            description => "zone id",
+	    type => 'string',
+	    description => 'Name of the zone this VNet belongs to.',
 	},
         type => {
-            description => "Type",
-            optional => 1,
-        },
+	    type => 'string',
+	    enum => ['vnet'],
+	    description => 'Type of the VNet.',
+	    optional => 1,
+	},
 	tag => {
-            type => 'integer',
-            description => "vlan or vxlan id",
+	    type => 'integer',
+	    description => 'VLAN Tag (for VLAN or QinQ zones) or VXLAN VNI (for VXLAN or EVPN zones).',
+	    optional => 1,
+	    minimum => 1,
+	    maximum => 16777215,
 	},
 	vlanaware => {
 	    type => 'boolean',
-	    description => 'Allow vm VLANs to pass through this vnet.',
+	    description => 'Allow VLANs to pass through this vnet.',
+	    optional => 1,
 	},
-        alias => {
-            type => 'string',
-            description => "alias name of the vnet",
-            pattern => qr/[\(\)-_.\w\d\s]{0,256}/i,
-            maxLength => 256,
+	alias => {
+	    type => 'string',
+	    description => "Alias name of the VNet.",
+	    pattern => qr/[\(\)-_.\w\d\s]{0,256}/i,
+	    maxLength => 256,
 	    optional => 1,
-        },
+	},
 	'isolate-ports' => {
 	    type => 'boolean',
-	    description => "If true, sets the isolated property for all members of this VNet",
+	    description => "If true, sets the isolated property for all interfaces on the bridge of this VNet.",
+	    optional => 1,
 	}
     };
 }
-- 
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-28 14:01 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-28 14:01 [pve-devel] [PATCH network 0/5] Improve documentation for SDN API endpoints used by PDM Stefan Hanreich
2025-02-28 14:01 ` [pve-devel] [PATCH pve-network 1/5] controllers: fix maximum value for ASN Stefan Hanreich
2025-03-10 15:29   ` Shannon Sterz
2025-03-11  5:53     ` Matthieu Pignolet via pve-devel
2025-03-11 10:50       ` DERUMIER, Alexandre via pve-devel
2025-02-28 14:01 ` [pve-devel] [PATCH pve-network 2/5] api: add state standard option Stefan Hanreich
2025-02-28 14:01 ` [pve-devel] [PATCH pve-network 3/5] api: controllers: update schema of endpoints Stefan Hanreich
2025-02-28 14:01 ` Stefan Hanreich [this message]
2025-02-28 14:01 ` [pve-devel] [PATCH pve-network 5/5] api: zones: " 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=20250228140136.124286-5-s.hanreich@proxmox.com \
    --to=s.hanreich@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