From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id C5B821FF17C for ; Wed, 3 Sep 2025 18:36:47 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 5631D132B2; Wed, 3 Sep 2025 18:37:02 +0200 (CEST) From: Stefan Hanreich To: pdm-devel@lists.proxmox.com Date: Wed, 3 Sep 2025 18:35:56 +0200 Message-ID: <20250903163621.530823-9-s.hanreich@proxmox.com> X-Mailer: git-send-email 2.47.2 In-Reply-To: <20250903163621.530823-1-s.hanreich@proxmox.com> References: <20250903163621.530823-1-s.hanreich@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.189 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_LAZY_DOMAIN_SECURITY 1 Sending domain does not have any anti-forgery methods RDNS_NONE 0.793 Delivered to internal network by a host with no rDNS SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_NONE 0.001 SPF: sender does not publish an SPF Record Subject: [pdm-devel] [PATCH pve-network v4 5/6] api: vnets: update schema of endpoints X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Proxmox Datacenter Manager development discussion Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" 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 --- src/PVE/API2/Network/SDN/Vnets.pm | 92 ++++++++++++++++++++++++++++++- src/PVE/Network/SDN/VnetPlugin.pm | 21 +++++-- 2 files changed, 105 insertions(+), 8 deletions(-) diff --git a/src/PVE/API2/Network/SDN/Vnets.pm b/src/PVE/API2/Network/SDN/Vnets.pm index e6eb5d4..1d9e500 100644 --- a/src/PVE/API2/Network/SDN/Vnets.pm +++ b/src/PVE/API2/Network/SDN/Vnets.pm @@ -74,6 +74,40 @@ 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 => '', @@ -103,7 +137,33 @@ __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}" }], }, @@ -171,7 +231,35 @@ __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 035aaca..717438c 100644 --- a/src/PVE/Network/SDN/VnetPlugin.pm +++ b/src/PVE/Network/SDN/VnetPlugin.pm @@ -60,30 +60,39 @@ sub properties { return { zone => { type => 'string', - description => "zone id", + description => 'Name of the zone this VNet belongs to.', }, type => { - description => "Type", + type => 'string', + enum => ['vnet'], + description => 'Type of the VNet.', optional => 1, }, tag => { type => 'integer', - description => "vlan or vxlan id", + 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", + 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.47.2 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel