]> git.proxmox.com Git - pve-network.git/blame - PVE/API2/Network/SDN/Zones/Status.pm
add permissions
[pve-network.git] / PVE / API2 / Network / SDN / Zones / Status.pm
CommitLineData
4140be9e 1package PVE::API2::Network::SDN::Zones::Status;
0022a918
AD
2
3use strict;
4use warnings;
5
6use File::Path;
7use File::Basename;
8use PVE::Tools;
9use PVE::INotify;
10use PVE::Cluster;
4140be9e 11use PVE::API2::Network::SDN::Zones::Content;
0022a918
AD
12use PVE::RESTHandler;
13use PVE::RPCEnvironment;
14use PVE::JSONSchema qw(get_standard_option);
15use PVE::Exception qw(raise_param_exc);
16
17use base qw(PVE::RESTHandler);
18
19__PACKAGE__->register_method ({
4140be9e
AD
20 subclass => "PVE::API2::Network::SDN::Zones::Content",
21 path => '{zone}/content',
0022a918
AD
22});
23
24__PACKAGE__->register_method ({
7d35eaf5 25 name => 'index',
0022a918
AD
26 path => '',
27 method => 'GET',
3fd3e917 28 description => "Get status for all zones.",
7d35eaf5 29 permissions => {
0022a918
AD
30 description => "Only list entries where you have 'SDN.Audit'",
31 user => 'all',
32 },
33 protected => 1,
34 proxyto => 'node',
35 parameters => {
36 additionalProperties => 0,
37 properties => {
38 node => get_standard_option('pve-node')
39 },
40 },
41 returns => {
42 type => 'array',
43 items => {
44 type => "object",
45 properties => {
4140be9e 46 zone => get_standard_option('pve-sdn-zone-id'),
0022a918 47 status => {
3fd3e917 48 description => "Status of zone",
0022a918
AD
49 type => 'string',
50 },
51 },
52 },
4140be9e 53 links => [ { rel => 'child', href => "{zone}" } ],
0022a918
AD
54 },
55 code => sub {
56 my ($param) = @_;
57
58 my $rpcenv = PVE::RPCEnvironment::get();
59 my $authuser = $rpcenv->get_user();
60
61 my $localnode = PVE::INotify::nodename();
62
63 my $res = [];
64
65 my ($transport_status, $vnet_status) = PVE::Network::SDN::status();
66
67 foreach my $id (keys %{$transport_status}) {
4140be9e 68 my $item->{zone} = $id;
0022a918
AD
69 $item->{status} = $transport_status->{$id}->{'status'};
70 push @$res,$item;
71 }
72
73 return $res;
74 }});
75
76__PACKAGE__->register_method ({
77 name => 'diridx',
4140be9e 78 path => '{zone}',
0022a918
AD
79 method => 'GET',
80 description => "",
3551b612
AD
81 permissions => {
82 check => ['perm', '/sdn/zones/{zone}', ['SDN.Audit'], any => 1],
83 },
0022a918
AD
84 parameters => {
85 additionalProperties => 0,
86 properties => {
87 node => get_standard_option('pve-node'),
4140be9e 88 zone => get_standard_option('pve-sdn-zone-id'),
0022a918
AD
89 },
90 },
91 returns => {
92 type => 'array',
93 items => {
94 type => "object",
95 properties => {
96 subdir => { type => 'string' },
97 },
98 },
99 links => [ { rel => 'child', href => "{subdir}" } ],
100 },
101 code => sub {
102 my ($param) = @_;
103 my $res = [
104 { subdir => 'content' },
105 ];
7d35eaf5 106
0022a918
AD
107 return $res;
108 }});
109
1101;