]>
git.proxmox.com Git - pve-network.git/blob - PVE/API2/Network/SDN.pm
1 package PVE
::API2
::Network
::SDN
;
6 use PVE
::Cluster
qw(cfs_lock_file cfs_read_file cfs_write_file);
7 use PVE
::Exception
qw(raise_param_exc);
8 use PVE
::JSONSchema
qw(get_standard_option);
10 use PVE
::RPCEnvironment
;
12 use PVE
::Tools
qw(run_command);
14 use PVE
::API2
::Network
::SDN
::Controllers
;
15 use PVE
::API2
::Network
::SDN
::Vnets
;
16 use PVE
::API2
::Network
::SDN
::Zones
;
17 use PVE
::API2
::Network
::SDN
::Ipams
;
18 use PVE
::API2
::Network
::SDN
::Dns
;
20 use base
qw(PVE::RESTHandler);
22 __PACKAGE__-
>register_method ({
23 subclass
=> "PVE::API2::Network::SDN::Vnets",
27 __PACKAGE__-
>register_method ({
28 subclass
=> "PVE::API2::Network::SDN::Zones",
32 __PACKAGE__-
>register_method ({
33 subclass
=> "PVE::API2::Network::SDN::Controllers",
34 path
=> 'controllers',
37 __PACKAGE__-
>register_method ({
38 subclass
=> "PVE::API2::Network::SDN::Ipams",
42 __PACKAGE__-
>register_method ({
43 subclass
=> "PVE::API2::Network::SDN::Dns",
47 __PACKAGE__-
>register_method({
51 description
=> "Directory index.",
53 check
=> ['perm', '/', [ 'SDN.Audit' ]],
56 additionalProperties
=> 0,
64 id
=> { type
=> 'string' },
67 links
=> [ { rel
=> 'child', href
=> "{id}" } ],
75 { id
=> 'controllers' },
83 my $create_reload_network_worker = sub {
86 # FIXME: how to proxy to final node ?
88 run_command
(['pvesh', 'set', "/nodes/$nodename/network"], outfunc
=> sub {
90 if ($line =~ /^["']?(UPID:[^\s"']+)["']?$/) {
94 #my $upid = PVE::API2::Network->reload_network_config(node => $nodename});
95 my $res = PVE
::Tools
::upid_decode
($upid);
100 __PACKAGE__-
>register_method ({
105 description
=> "Apply sdn controller changes && reload.",
107 check
=> ['perm', '/sdn', ['SDN.Allocate']],
110 additionalProperties
=> 0,
118 my $rpcenv = PVE
::RPCEnvironment
::get
();
119 my $authuser = $rpcenv->get_user();
122 $rpcenv->{type
} = 'priv'; # to start tasks in background
123 PVE
::Cluster
::check_cfs_quorum
();
124 my $nodelist = PVE
::Cluster
::get_nodelist
();
125 for my $node (@$nodelist) {
126 my $pid = eval { $create_reload_network_worker->($node) };
130 # FIXME: use libpve-apiclient (like in cluster join) to create
131 # tasks and moitor the tasks.
136 return $rpcenv->fork_worker('reloadnetworkall', undef, $authuser, $code);