]>
git.proxmox.com Git - pve-network.git/blob - src/PVE/API2/Network/SDN.pm
d216e4878b611b338e3ed6ec3a092148e3f6713d
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', [ '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 print "$nodename: reloading network config\n";
90 run_command
(['pvesh', 'set', "/nodes/$nodename/network"], outfunc
=> sub {
92 if ($line =~ /["']?(UPID:[^\s"']+)["']?$/) {
96 #my $upid = PVE::API2::Network->reload_network_config(node => $nodename});
97 my $res = PVE
::Tools
::upid_decode
($upid);
102 __PACKAGE__-
>register_method ({
107 description
=> "Apply sdn controller changes && reload.",
109 check
=> ['perm', '/sdn', ['SDN.Allocate']],
112 additionalProperties
=> 0,
120 my $rpcenv = PVE
::RPCEnvironment
::get
();
121 my $authuser = $rpcenv->get_user();
123 PVE
::Network
::SDN
::commit_config
();
126 $rpcenv->{type
} = 'priv'; # to start tasks in background
127 PVE
::Cluster
::check_cfs_quorum
();
128 my $nodelist = PVE
::Cluster
::get_nodelist
();
129 for my $node (@$nodelist) {
130 my $pid = eval { $create_reload_network_worker->($node) };
134 # FIXME: use libpve-apiclient (like in cluster join) to create
135 # tasks and moitor the tasks.
140 return $rpcenv->fork_worker('reloadnetworkall', undef, $authuser, $code);