]>
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);
13 use PVE
::Network
::SDN
;
15 use PVE
::API2
::Network
::SDN
::Controllers
;
16 use PVE
::API2
::Network
::SDN
::Vnets
;
17 use PVE
::API2
::Network
::SDN
::Zones
;
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::Ipams",
43 __PACKAGE__-
>register_method ({
44 subclass
=> "PVE::API2::Network::SDN::Dns",
48 __PACKAGE__-
>register_method({
52 description
=> "Directory index.",
54 check
=> ['perm', '/', [ 'SDN.Audit' ]],
57 additionalProperties
=> 0,
65 id
=> { type
=> 'string' },
68 links
=> [ { rel
=> 'child', href
=> "{id}" } ],
76 { id
=> 'controllers' },
84 my $create_reload_network_worker = sub {
87 # FIXME: how to proxy to final node ?
89 run_command
(['pvesh', 'set', "/nodes/$nodename/network"], outfunc
=> sub {
91 if ($line =~ /^["']?(UPID:[^\s"']+)["']?$/) {
95 #my $upid = PVE::API2::Network->reload_network_config(node => $nodename});
96 my $res = PVE
::Tools
::upid_decode
($upid);
101 __PACKAGE__-
>register_method ({
106 description
=> "Apply sdn controller changes && reload.",
108 check
=> ['perm', '/sdn', ['SDN.Allocate']],
111 additionalProperties
=> 0,
119 my $rpcenv = PVE
::RPCEnvironment
::get
();
120 my $authuser = $rpcenv->get_user();
122 PVE
::Network
::SDN
::commit_config
();
125 $rpcenv->{type
} = 'priv'; # to start tasks in background
126 PVE
::Cluster
::check_cfs_quorum
();
127 my $nodelist = PVE
::Cluster
::get_nodelist
();
128 for my $node (@$nodelist) {
129 my $pid = eval { $create_reload_network_worker->($node) };
133 # FIXME: use libpve-apiclient (like in cluster join) to create
134 # tasks and moitor the tasks.
139 return $rpcenv->fork_worker('reloadnetworkall', undef, $authuser, $code);