]> git.proxmox.com Git - pve-network.git/blob - PVE/API2/Network/SDN/Content.pm
trailing whitespace cleanup
[pve-network.git] / PVE / API2 / Network / SDN / Content.pm
1 package PVE::API2::Network::SDN::Content;
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 ({
20 name => 'index',
21 path => '',
22 method => 'GET',
23 description => "List transportzone content.",
24 # permissions => {
25 # check => ['perm', '/sdn/{sdn}', ['SDN.Audit'], any => 1],
26 # },
27 protected => 1,
28 proxyto => 'node',
29 parameters => {
30 additionalProperties => 0,
31 properties => {
32 node => get_standard_option('pve-node'),
33 sdn => get_standard_option('pve-sdn-id', {
34 completion => \&PVE::Network::SDN::complete_sdn,
35 }),
36 },
37 },
38 returns => {
39 type => 'array',
40 items => {
41 type => "object",
42 properties => {
43 vnet => {
44 description => "Vnet identifier.",
45 type => 'string',
46 },
47 status => {
48 description => "Status.",
49 type => 'string',
50 optional => 1,
51 },
52 },
53 },
54 links => [ { rel => 'child', href => "{vnet}" } ],
55 },
56 code => sub {
57 my ($param) = @_;
58
59 my $rpcenv = PVE::RPCEnvironment::get();
60
61 my $authuser = $rpcenv->get_user();
62
63 my $transportid = $param->{sdn};
64
65 my $res = [];
66
67 my ($transport_status, $vnet_status) = PVE::Network::SDN::status();
68
69 foreach my $id (keys %{$vnet_status}) {
70 if ($vnet_status->{$id}->{transportzone} eq $transportid) {
71 my $item->{vnet} = $id;
72 $item->{status} = $vnet_status->{$id}->{'status'};
73 push @$res,$item;
74 }
75 }
76
77 return $res;
78 }});
79
80 1;