diff options
| author | Alexandre Derumier <aderumier@odiso.com> | 2020-10-05 17:09:04 +0200 |
|---|---|---|
| committer | Thomas Lamprecht <t.lamprecht@proxmox.com> | 2020-10-08 11:05:28 +0200 |
| commit | 6f5f42e4435a4ec171f4634d3480208c271b39d5 (patch) | |
| tree | c5be67f1b30f43f7a5c96f33882cbf7fe7d05470 /PVE/API2/Network/SDN/Subnets.pm | |
| parent | 5d3e0248bb8112e467ddaa5807d98dff06de3dfa (diff) | |
api: add running/pending zones/vnets/subnets/controllers
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
Diffstat (limited to 'PVE/API2/Network/SDN/Subnets.pm')
| -rw-r--r-- | PVE/API2/Network/SDN/Subnets.pm | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/PVE/API2/Network/SDN/Subnets.pm b/PVE/API2/Network/SDN/Subnets.pm index e122ffd..82635f6 100644 --- a/PVE/API2/Network/SDN/Subnets.pm +++ b/PVE/API2/Network/SDN/Subnets.pm @@ -46,7 +46,17 @@ __PACKAGE__->register_method ({ additionalProperties => 0, properties => { vnet => get_standard_option('pve-sdn-vnet-id'), - }, + running => { + type => 'boolean', + optional => 1, + description => "Display running config.", + }, + pending => { + type => 'boolean', + optional => 1, + description => "Display pending config.", + }, + }, }, returns => { type => 'array', @@ -64,7 +74,17 @@ __PACKAGE__->register_method ({ my $vnetid = $param->{vnet}; - my $cfg = PVE::Network::SDN::Subnets::config(); + my $cfg = {}; + if($param->{pending}) { + my $running_cfg = PVE::Network::SDN::config(); + my $config = PVE::Network::SDN::Subnets::config(); + $cfg = PVE::Network::SDN::pending_config($running_cfg, $config, 'subnets'); + } elsif ($param->{running}) { + my $running_cfg = PVE::Network::SDN::config(); + $cfg = $running_cfg->{subnets}; + } else { + $cfg = PVE::Network::SDN::Subnets::config(); + } my @sids = PVE::Network::SDN::Subnets::sdn_subnets_ids($cfg); my $res = []; @@ -96,13 +116,34 @@ __PACKAGE__->register_method ({ subnet => get_standard_option('pve-sdn-subnet-id', { completion => \&PVE::Network::SDN::Subnets::complete_sdn_subnets, }), - }, + running => { + type => 'boolean', + optional => 1, + description => "Display running config.", + }, + pending => { + type => 'boolean', + optional => 1, + description => "Display pending config.", + }, + }, }, returns => { type => 'object' }, code => sub { my ($param) = @_; - my $cfg = PVE::Network::SDN::Subnets::config(); + my $cfg = {}; + if($param->{pending}) { + my $running_cfg = PVE::Network::SDN::config(); + my $config = PVE::Network::SDN::Subnets::config(); + $cfg = PVE::Network::SDN::pending_config($running_cfg, $config, 'subnets'); + } elsif ($param->{running}) { + my $running_cfg = PVE::Network::SDN::config(); + $cfg = $running_cfg->{subnets}; + } else { + $cfg = PVE::Network::SDN::Subnets::config(); + } + my $scfg = &$api_sdn_subnets_config($cfg, $param->{subnet}); raise_param_exc({ vnet => "wrong vnet"}) if $param->{vnet} ne $scfg->{vnet}; |
