From: Daniel Kral <d.kral@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [PATCH network 2/2] api: vnets: assert vnet zone exists on create and update
Date: Fri, 3 Jul 2026 12:47:50 +0200 [thread overview]
Message-ID: <20260703104750.117988-3-d.kral@proxmox.com> (raw)
In-Reply-To: <20260703104750.117988-1-d.kral@proxmox.com>
If a VNet is created or updated with an empty zone '' or a non-existing
zone identifier, the API handler will die with a slighly confusing error
message:
create sdn vnet object failed: cannot lookup undefined type! at
/usr/share/perl5/PVE/API2/Network/SDN/Vnets.pm line 326.
Therefore, use the helper sdn_zones_config(), which asserts whether the
zone identifier is non-empty and existing.
Signed-off-by: Daniel Kral <d.kral@proxmox.com>
---
src/PVE/API2/Network/SDN/Vnets.pm | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/src/PVE/API2/Network/SDN/Vnets.pm b/src/PVE/API2/Network/SDN/Vnets.pm
index b8faeac..3f1cb1b 100644
--- a/src/PVE/API2/Network/SDN/Vnets.pm
+++ b/src/PVE/API2/Network/SDN/Vnets.pm
@@ -322,8 +322,8 @@ __PACKAGE__->register_method({
my $zone_cfg = PVE::Network::SDN::Zones::config();
my $zoneid = $cfg->{ids}->{$id}->{zone};
- my $plugin_config = $zone_cfg->{ids}->{$zoneid};
- my $plugin = PVE::Network::SDN::Zones::Plugin->lookup($plugin_config->{type});
+ my $zone_scfg = PVE::Network::SDN::Zones::sdn_zones_config($zone_cfg, $zoneid);
+ my $plugin = PVE::Network::SDN::Zones::Plugin->lookup($zone_scfg->{type});
$plugin->vnet_update_hook($cfg, $id, $zone_cfg);
PVE::Network::SDN::VnetPlugin->on_update_hook($id, $cfg);
@@ -398,8 +398,8 @@ __PACKAGE__->register_method({
my $zone_cfg = PVE::Network::SDN::Zones::config();
my $zoneid = $cfg->{ids}->{$id}->{zone};
- my $plugin_config = $zone_cfg->{ids}->{$zoneid};
- my $plugin = PVE::Network::SDN::Zones::Plugin->lookup($plugin_config->{type});
+ my $zone_scfg = PVE::Network::SDN::Zones::sdn_zones_config($zone_cfg, $zoneid);
+ my $plugin = PVE::Network::SDN::Zones::Plugin->lookup($zone_scfg->{type});
$plugin->vnet_update_hook($cfg, $id, $zone_cfg);
PVE::Network::SDN::VnetPlugin->on_update_hook($id, $cfg);
--
2.47.3
prev parent reply other threads:[~2026-07-03 10:48 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-03 10:47 [PATCH-SERIES network 0/2] assert vnet zone exists on create and update Daniel Kral
2026-07-03 10:47 ` [PATCH network 1/2] prefix specific sdn resource type to existence assertion string Daniel Kral
2026-07-03 10:47 ` Daniel Kral [this message]
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=20260703104750.117988-3-d.kral@proxmox.com \
--to=d.kral@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox