Helpful for subnet options that are only available for specific zones.

Signed-off-by: Hannes Laimer <[email protected]>
---
 src/PVE/API2/Network/SDN/Vnets.pm | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/PVE/API2/Network/SDN/Vnets.pm 
b/src/PVE/API2/Network/SDN/Vnets.pm
index b8faeac..e0b8607 100644
--- a/src/PVE/API2/Network/SDN/Vnets.pm
+++ b/src/PVE/API2/Network/SDN/Vnets.pm
@@ -155,6 +155,12 @@ __PACKAGE__->register_method({
                     optional => 0,
                     description => 'Name of the VNet.',
                 },
+                'zone-type' => {
+                    type => 'string',
+                    description => 'Type of the zone this VNet belongs to.',
+                    enum => PVE::Network::SDN::Zones::Plugin->lookup_types(),
+                    optional => 1,
+                },
                 pending => {
                     type => 'object',
                     description =>
@@ -174,15 +180,20 @@ __PACKAGE__->register_method({
         my $authuser = $rpcenv->get_user();
 
         my $cfg = {};
+        my $zone_cfg = {};
         if ($param->{pending}) {
             my $running_cfg = PVE::Network::SDN::running_config();
             my $config = PVE::Network::SDN::Vnets::config();
+            my $zone_config = PVE::Network::SDN::Zones::config();
             $cfg = PVE::Network::SDN::pending_config($running_cfg, $config, 
'vnets');
+            $zone_cfg = PVE::Network::SDN::pending_config($running_cfg, 
$zone_config, 'zones');
         } elsif ($param->{running}) {
             my $running_cfg = PVE::Network::SDN::running_config();
             $cfg = $running_cfg->{vnets};
+            $zone_cfg = $running_cfg->{zones};
         } else {
             $cfg = PVE::Network::SDN::Vnets::config();
+            $zone_cfg = PVE::Network::SDN::Zones::config();
         }
 
         my @sids = PVE::Network::SDN::Vnets::sdn_vnets_ids($cfg);
@@ -192,6 +203,8 @@ __PACKAGE__->register_method({
             my $scfg = &$api_sdn_vnets_config($cfg, $id);
             my $zoneid = $scfg->{zone} // $scfg->{pending}->{zone};
             next if !$rpcenv->check_any($authuser, "/sdn/zones/$zoneid/$id", 
$privs, 1);
+            $scfg->{'zone-type'} = $zone_cfg->{ids}->{$zoneid}->{type}
+                if $zone_cfg->{ids}->{$zoneid};
 
             push @$res, $scfg;
         }
-- 
2.47.3




Reply via email to