]> git.proxmox.com Git - pve-network.git/commitdiff
api2: add networkconfig
authorAlexandre Derumier <aderumier@odiso.com>
Tue, 2 Apr 2019 22:19:11 +0000 (00:19 +0200)
committerDietmar Maurer <dietmar@proxmox.com>
Wed, 3 Apr 2019 04:20:56 +0000 (06:20 +0200)
/cluster/network/vnet
/cluster/network/transport

PVE/API2/Makefile
PVE/API2/NetworkConfig.pm [new file with mode: 0644]

index 5bc7988bfecabebdcc567c05577427228c41da61..3e0ae7e17c58802ef362b5b04c1225435c7c4897 100644 (file)
@@ -1,5 +1,8 @@
+SOURCES=NetworkConfig.pm
 
+PERL5DIR=${DESTDIR}/usr/share/perl5
 
 .PHONY: install
 install:
+       for i in ${SOURCES}; do install -D -m 0644 $$i ${PERL5DIR}/PVE/API2/$$i; done
        make -C Network install
diff --git a/PVE/API2/NetworkConfig.pm b/PVE/API2/NetworkConfig.pm
new file mode 100644 (file)
index 0000000..91b7699
--- /dev/null
@@ -0,0 +1,62 @@
+package PVE::API2::NetworkConfig;
+
+use strict;
+use warnings;
+
+use PVE::SafeSyslog;
+use PVE::Tools;
+use PVE::Cluster qw(cfs_lock_file cfs_read_file cfs_write_file);
+use PVE::RESTHandler;
+use PVE::RPCEnvironment;
+use PVE::JSONSchema qw(get_standard_option);
+use PVE::Exception qw(raise_param_exc);
+use PVE::API2::Network::Transport;
+use PVE::API2::Network::Vnet;
+
+use base qw(PVE::RESTHandler);
+
+__PACKAGE__->register_method ({
+    subclass => "PVE::API2::Network::Transport",  
+    path => 'transport',
+                             });
+
+__PACKAGE__->register_method ({
+    subclass => "PVE::API2::Network::Vnet",  
+    path => 'vnet',
+                             });
+
+__PACKAGE__->register_method({
+    name => 'index', 
+    path => '', 
+    method => 'GET',
+    description => "Directory index.",
+    permissions => {
+       check => ['perm', '/', [ 'Sys.Audit' ]],
+    },
+    parameters => {
+       additionalProperties => 0,
+       properties => {},
+    },
+    returns => {
+       type => 'array',
+       items => {
+           type => "object",
+           properties => {
+               id => { type => 'string' },
+           },
+       },
+       links => [ { rel => 'child', href => "{id}" } ],
+    },
+    code => sub {
+       my ($param) = @_;
+
+       my $res = [ 
+           { id => 'transport' },
+           { id => 'vnet' },
+       ];
+
+       return $res;
+    }});
+
+
+1;