public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: "Daniel Kral" <d.kral@proxmox.com>
To: "David Riley" <d.riley@proxmox.com>, <pve-devel@lists.proxmox.com>
Subject: Re: [PATCH pve-network v2 06/10] fix #7294: sdn: register api formats for zones and vnets
Date: Mon, 06 Jul 2026 14:21:22 +0200	[thread overview]
Message-ID: <DJRHFVHII0W5.1XMJ31I3BDO7H@proxmox.com> (raw)
In-Reply-To: <20260626131035.112374-7-d.riley@proxmox.com>

On Fri Jun 26, 2026 at 3:10 PM CEST, David Riley wrote:
> Register JSONSchema format validators for both SDN zones and VNets,
> enabling the pool members API to verify these network identifiers.
>
> Link: https://bugzilla.proxmox.com/show_bug.cgi?id=7294
> Signed-off-by: David Riley <d.riley@proxmox.com>
> ---
>  src/PVE/Network/SDN/VnetPlugin.pm   | 25 ++++++++++++++++++++++---
>  src/PVE/Network/SDN/Zones/Plugin.pm | 25 ++++++++++++++++++++++---
>  2 files changed, 44 insertions(+), 6 deletions(-)
>
> diff --git a/src/PVE/Network/SDN/VnetPlugin.pm b/src/PVE/Network/SDN/VnetPlugin.pm
> index e041575..fbddc06 100644
> --- a/src/PVE/Network/SDN/VnetPlugin.pm
> +++ b/src/PVE/Network/SDN/VnetPlugin.pm
> @@ -16,17 +16,36 @@ PVE::Cluster::cfs_register_file(
>      sub { __PACKAGE__->write_config(@_); },
>  );
>  
> +my $sdn_vnet_id_pattern = '[a-zA-Z][a-zA-Z0-9]*[a-zA-Z0-9]';
> +my $vnet_min_length = 2;
> +my $vnet_max_length = 8;
> +
>  PVE::JSONSchema::register_standard_option(
>      'pve-sdn-vnet-id',
>      {
>          description => "The SDN vnet object identifier.",
>          type => 'string',
> -        pattern => '[a-zA-Z][a-zA-Z0-9]*[a-zA-Z0-9]',
> -        minLength => 2,
> -        maxLength => 8,
> +        pattern => $sdn_vnet_id_pattern,
> +        minLength => $vnet_min_length,
> +        maxLength => $vnet_max_length,

nit: might be overkill, but add a:  format => 'pve-sdn-vnet-id'

>      },
>  );
>  
> +sub pve_verify_sdn_vnet_id {
> +    my ($vnet, $noerr) = @_;
> +
> +    my $len = length($vnet);
> +
> +    if ($vnet !~ m/^$sdn_vnet_id_pattern$/ || $len < $vnet_min_length || $len > $vnet_max_length) {
> +        return undef if $noerr;
> +        die "invalid SDN VNet '$vnet', must be $vnet_min_length-$vnet_max_length characters"
> +            . " long, start with a letter, and contain only alphanumeric characters\n";
> +    }
> +    return $vnet;
> +}
> +
> +PVE::JSONSchema::register_format('pve-sdn-vnet-id', \&pve_verify_sdn_vnet_id);
> +
>  my $defaultData = {
>  
>      propertyList => {
> diff --git a/src/PVE/Network/SDN/Zones/Plugin.pm b/src/PVE/Network/SDN/Zones/Plugin.pm
> index 74a3384..81bcf86 100644
> --- a/src/PVE/Network/SDN/Zones/Plugin.pm
> +++ b/src/PVE/Network/SDN/Zones/Plugin.pm
> @@ -19,17 +19,36 @@ PVE::Cluster::cfs_register_file(
>      sub { __PACKAGE__->write_config(@_); },
>  );
>  
> +my $sdn_zone_id_pattern = '[a-zA-Z][a-zA-Z0-9]*[a-zA-Z0-9]';
> +my $zone_min_length = 2;
> +my $zone_max_length = 8;
> +
>  PVE::JSONSchema::register_standard_option(
>      'pve-sdn-zone-id',
>      {
>          description => "The SDN zone object identifier.",
>          type => 'string',
> -        pattern => '[a-zA-Z][a-zA-Z0-9]*[a-zA-Z0-9]',
> -        minLength => 2,
> -        maxLength => 8,
> +        pattern => $sdn_zone_id_pattern,
> +        minLength => $zone_min_length,
> +        maxLength => $zone_max_length,

nit: might be overkill, but add a:  format => 'pve-sdn-zone-id'

>      },
>  );
>  
> +sub pve_verify_sdn_zone_id {
> +    my ($zone, $noerr) = @_;
> +
> +    my $len = length($zone);
> +
> +    if ($zone !~ m/^$sdn_zone_id_pattern$/ || $len < $zone_min_length || $len > $zone_max_length) {
> +        return undef if $noerr;
> +        die "invalid SDN zone '$zone', must be $zone_min_length-$zone_max_length characters long,"
> +            . " start with a letter, and contain only alphanumeric characters\n";
> +    }
> +    return $zone;
> +}
> +
> +PVE::JSONSchema::register_format('pve-sdn-zone-id', \&pve_verify_sdn_zone_id);
> +
>  my $defaultData = {
>  
>      propertyList => {

Modulo the nits, consider this:

Reviewed-by: Daniel Kral <d.kral@proxmox.com>




  reply	other threads:[~2026-07-06 12:21 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-26 13:10 [PATCH access-control/cluster/common/manager/network/proxmox-widget-toolkit/qemu-server v2 00/10] fix #7294: pool: add SDN VNets as pool members David Riley
2026-06-26 13:10 ` [PATCH pve-manager v2 01/10] ui: replace var with let to match style guide for variable declaration David Riley
2026-07-03 13:14   ` Daniel Kral
2026-06-26 13:10 ` [PATCH pve-manager v2 02/10] fix #7294: api: pool: add SDN VNets as pool members David Riley
2026-07-03 13:19   ` Daniel Kral
2026-06-26 13:10 ` [PATCH pve-manager v2 03/10] fix #7294: ui: " David Riley
2026-07-06 14:17   ` Daniel Kral
2026-06-26 13:10 ` [PATCH proxmox-widget-toolkit v2 04/10] fix #7294: css: theme: add opacity override for pool VNet icon David Riley
2026-07-03 13:30   ` Daniel Kral
2026-06-26 13:10 ` [PATCH pve-access-control v2 05/10] fix #7294: acl: pool: add SDN VNets as pool members David Riley
2026-07-03 14:35   ` Daniel Kral
2026-07-06 11:56   ` Daniel Kral
2026-06-26 13:10 ` [PATCH pve-network v2 06/10] fix #7294: sdn: register api formats for zones and vnets David Riley
2026-07-06 12:21   ` Daniel Kral [this message]
2026-06-26 13:10 ` [PATCH pve-network v2 07/10] fix #7294: sdn: vnet: update pool members on vnet migration and deletion David Riley
2026-07-06 12:29   ` Daniel Kral
2026-06-26 13:10 ` [PATCH pve-common v2 08/10] tools: add helpers for version comparison David Riley
2026-07-06 13:02   ` Daniel Kral
2026-06-26 13:10 ` [PATCH pve-cluster v2 09/10] fix #7294: cluster: helpers: add cluster-wide version assertion David Riley
2026-07-06 13:00   ` Daniel Kral
2026-06-26 13:10 ` [PATCH qemu-server v2 10/10] fix #7294: helpers: use cluster-wide version helper David Riley
2026-07-06 13:20   ` Daniel Kral
2026-07-06 14:07 ` [PATCH access-control/cluster/common/manager/network/proxmox-widget-toolkit/qemu-server v2 00/10] fix #7294: pool: add SDN VNets as pool members Daniel Kral

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=DJRHFVHII0W5.1XMJ31I3BDO7H@proxmox.com \
    --to=d.kral@proxmox.com \
    --cc=d.riley@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
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal