]>
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
::Subnets
;
18 use PVE
::API2
::Network
::SDN
::Ipams
;
19 use PVE
::API2
::Network
::SDN
::Dns
;
21 use base
qw(PVE::RESTHandler);
23 __PACKAGE__-
>register_method ({
24 subclass
=> "PVE::API2::Network::SDN::Vnets",
28 __PACKAGE__-
>register_method ({
29 subclass
=> "PVE::API2::Network::SDN::Zones",
33 __PACKAGE__-
>register_method ({
34 subclass
=> "PVE::API2::Network::SDN::Controllers",
35 path
=> 'controllers',
38 __PACKAGE__-
>register_method ({
39 subclass
=> "PVE::API2::Network::SDN::Subnets",
43 __PACKAGE__-
>register_method ({
44 subclass
=> "PVE::API2::Network::SDN::Ipams",
48 __PACKAGE__-
>register_method ({
49 subclass
=> "PVE::API2::Network::SDN::Dns",
53 __PACKAGE__-
>register_method({
57 description
=> "Directory index.",
59 check
=> ['perm', '/', [ 'SDN.Audit' ]],
62 additionalProperties
=> 0,
70 id
=> { type
=> 'string' },
73 links
=> [ { rel
=> 'child', href
=> "{id}" } ],
81 { id
=> 'controllers' },
90 my $create_reload_network_worker = sub {
93 # FIXME: how to proxy to final node ?
95 run_command
(['pvesh', 'set', "/nodes/$nodename/network"], outfunc
=> sub {
97 if ($line =~ /^["']?(UPID:[^\s"']+)["']?$/) {
101 #my $upid = PVE::API2::Network->reload_network_config(node => $nodename});
102 my $res = PVE
::Tools
::upid_decode
($upid);
107 __PACKAGE__-
>register_method ({
112 description
=> "Apply sdn controller changes && reload.",
114 check
=> ['perm', '/sdn', ['SDN.Allocate']],
117 additionalProperties
=> 0,
125 my $rpcenv = PVE
::RPCEnvironment
::get
();
126 my $authuser = $rpcenv->get_user();
129 $rpcenv->{type
} = 'priv'; # to start tasks in background
130 PVE
::Cluster
::check_cfs_quorum
();
131 my $nodelist = PVE
::Cluster
::get_nodelist
();
132 for my $node (@$nodelist) {
133 my $pid = eval { $create_reload_network_worker->($node) };
137 # FIXME: use libpve-apiclient (like in cluster join) to create
138 # tasks and moitor the tasks.
143 return $rpcenv->fork_worker('reloadnetworkall', undef, $authuser, $code);