]>
Commit | Line | Data |
---|---|---|
4140be9e | 1 | package PVE::API2::Network::SDN::Zones::Content; |
903e2f5e AD |
2 | |
3 | use strict; | |
4 | use warnings; | |
5 | use Data::Dumper; | |
6 | ||
7 | use PVE::SafeSyslog; | |
8 | use PVE::Cluster; | |
9 | use PVE::Storage; | |
10 | use PVE::INotify; | |
11 | use PVE::Exception qw(raise_param_exc); | |
12 | use PVE::RPCEnvironment; | |
13 | use PVE::RESTHandler; | |
14 | use PVE::JSONSchema qw(get_standard_option); | |
15 | use PVE::Network::SDN; | |
16 | ||
17 | use 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.", |
7d35eaf5 | 24 | # permissions => { |
903e2f5e AD |
25 | # check => ['perm', '/sdn/{sdn}', ['SDN.Audit'], any => 1], |
26 | # }, | |
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 | ||
4140be9e | 68 | my $transportid = $param->{zone}; |
903e2f5e AD |
69 | |
70 | my $res = []; | |
71 | ||
72 | my ($transport_status, $vnet_status) = PVE::Network::SDN::status(); | |
73 | ||
74 | foreach my $id (keys %{$vnet_status}) { | |
3fd3e917 | 75 | if ($vnet_status->{$id}->{zone} eq $transportid) { |
903e2f5e AD |
76 | my $item->{vnet} = $id; |
77 | $item->{status} = $vnet_status->{$id}->{'status'}; | |
3709a203 | 78 | $item->{status} = $vnet_status->{$id}->{'statusmsg'}; |
903e2f5e AD |
79 | push @$res,$item; |
80 | } | |
81 | } | |
82 | ||
7d35eaf5 | 83 | return $res; |
903e2f5e AD |
84 | }}); |
85 | ||
86 | 1; |