]>
git.proxmox.com Git - pve-network.git/blob - PVE/API2/Network/SDN.pm
38af7467e85de5fe6129fc0dd942a8d163761dfd
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
;
19 use base
qw(PVE::RESTHandler);
21 __PACKAGE__-
>register_method ({
22 subclass
=> "PVE::API2::Network::SDN::Vnets",
26 __PACKAGE__-
>register_method ({
27 subclass
=> "PVE::API2::Network::SDN::Zones",
31 __PACKAGE__-
>register_method ({
32 subclass
=> "PVE::API2::Network::SDN::Controllers",
33 path
=> 'controllers',
36 __PACKAGE__-
>register_method ({
37 subclass
=> "PVE::API2::Network::SDN::Subnets",
41 __PACKAGE__-
>register_method({
45 description
=> "Directory index.",
47 check
=> ['perm', '/', [ 'SDN.Audit' ]],
50 additionalProperties
=> 0,
58 id
=> { type
=> 'string' },
61 links
=> [ { rel
=> 'child', href
=> "{id}" } ],
69 { id
=> 'controllers' },
76 my $create_reload_network_worker = sub {
79 # FIXME: how to proxy to final node ?
81 run_command
(['pvesh', 'set', "/nodes/$nodename/network"], outfunc
=> sub {
83 if ($line =~ /^["']?(UPID:[^\s"']+)["']?$/) {
87 #my $upid = PVE::API2::Network->reload_network_config(node => $nodename});
88 my $res = PVE
::Tools
::upid_decode
($upid);
93 __PACKAGE__-
>register_method ({
98 description
=> "Apply sdn controller changes && reload.",
100 check
=> ['perm', '/sdn', ['SDN.Allocate']],
103 additionalProperties
=> 0,
111 my $rpcenv = PVE
::RPCEnvironment
::get
();
112 my $authuser = $rpcenv->get_user();
115 $rpcenv->{type
} = 'priv'; # to start tasks in background
116 PVE
::Cluster
::check_cfs_quorum
();
117 my $nodelist = PVE
::Cluster
::get_nodelist
();
118 for my $node (@$nodelist) {
119 my $pid = eval { $create_reload_network_worker->($node) };
123 # FIXME: use libpve-apiclient (like in cluster join) to create
124 # tasks and moitor the tasks.
129 return $rpcenv->fork_worker('reloadnetworkall', undef, $authuser, $code);