]> git.proxmox.com Git - pve-network.git/blame - PVE/API2/Network/SDN/Zones/Content.pm
api2: fix vnet status
[pve-network.git] / PVE / API2 / Network / SDN / Zones / Content.pm
CommitLineData
4140be9e 1package PVE::API2::Network::SDN::Zones::Content;
903e2f5e
AD
2
3use strict;
4use warnings;
5use Data::Dumper;
6
7use PVE::SafeSyslog;
8use PVE::Cluster;
9use PVE::Storage;
10use PVE::INotify;
11use PVE::Exception qw(raise_param_exc);
12use PVE::RPCEnvironment;
13use PVE::RESTHandler;
14use PVE::JSONSchema qw(get_standard_option);
15use PVE::Network::SDN;
16
17use base qw(PVE::RESTHandler);
18
19__PACKAGE__->register_method ({
7d35eaf5 20 name => 'index',
903e2f5e
AD
21 path => '',
22 method => 'GET',
3fd3e917 23 description => "List zone content.",
3551b612
AD
24 permissions => {
25 check => ['perm', '/sdn/zones/{zone}', ['SDN.Audit'], any => 1],
26 },
903e2f5e
AD
27 protected => 1,
28 proxyto => 'node',
29 parameters => {
30 additionalProperties => 0,
7d35eaf5 31 properties => {
903e2f5e 32 node => get_standard_option('pve-node'),
4140be9e
AD
33 zone => get_standard_option('pve-sdn-zone-id', {
34 completion => \&PVE::Network::SDN::Zones::complete_sdn_zone,
903e2f5e
AD
35 }),
36 },
37 },
38 returns => {
39 type => 'array',
40 items => {
41 type => "object",
7d35eaf5 42 properties => {
903e2f5e
AD
43 vnet => {
44 description => "Vnet identifier.",
45 type => 'string',
46 },
47 status => {
48 description => "Status.",
49 type => 'string',
50 optional => 1,
51 },
3709a203
AD
52 statusmsg => {
53 description => "Status details",
54 type => 'string',
55 optional => 1,
56 },
903e2f5e
AD
57 },
58 },
59 links => [ { rel => 'child', href => "{vnet}" } ],
60 },
61 code => sub {
62 my ($param) = @_;
63
64 my $rpcenv = PVE::RPCEnvironment::get();
65
66 my $authuser = $rpcenv->get_user();
67
56cdcac9 68 my $zoneid = $param->{zone};
903e2f5e
AD
69
70 my $res = [];
71
56cdcac9 72 my ($zone_status, $vnet_status) = PVE::Network::SDN::status();
903e2f5e
AD
73
74 foreach my $id (keys %{$vnet_status}) {
56cdcac9 75 if ($vnet_status->{$id}->{zone} eq $zoneid) {
903e2f5e
AD
76 my $item->{vnet} = $id;
77 $item->{status} = $vnet_status->{$id}->{'status'};
f84d09f2 78 $item->{statusmsg} = $vnet_status->{$id}->{'statusmsg'};
903e2f5e
AD
79 push @$res,$item;
80 }
81 }
82
7d35eaf5 83 return $res;
903e2f5e
AD
84 }});
85
861;