]>
git.proxmox.com Git - pve-network.git/blob - PVE/API2/Network/SDN.pm
65c8d5270fcb63ce8f9a2440aadb6ada385e435a
1 package PVE
::API2
::Network
::SDN
;
8 use PVE
::Cluster
qw(cfs_lock_file cfs_read_file cfs_write_file);
10 use PVE
::RPCEnvironment
;
11 use PVE
::JSONSchema
qw(get_standard_option);
12 use PVE
::Exception
qw(raise_param_exc);
13 use PVE
::API2
::Network
::SDN
::Vnets
;
14 use PVE
::API2
::Network
::SDN
::Zones
;
15 use PVE
::API2
::Network
::SDN
::Controllers
;
17 use base
qw(PVE::RESTHandler);
19 __PACKAGE__-
>register_method ({
20 subclass
=> "PVE::API2::Network::SDN::Vnets",
24 __PACKAGE__-
>register_method ({
25 subclass
=> "PVE::API2::Network::SDN::Zones",
29 __PACKAGE__-
>register_method ({
30 subclass
=> "PVE::API2::Network::SDN::Controllers",
31 path
=> 'controllers',
34 __PACKAGE__-
>register_method({
38 description
=> "Directory index.",
40 check
=> ['perm', '/', [ 'SDN.Audit' ]],
43 additionalProperties
=> 0,
51 id
=> { type
=> 'string' },
54 links
=> [ { rel
=> 'child', href
=> "{id}" } ],
62 { id
=> 'controllers' },
68 my $create_reload_network_worker = sub {
71 #fixme: how to proxy to final node ?
72 my $upid = PVE
::Tools
::run_command
(['pvesh', 'set', "/nodes/$nodename/network"]);
73 #my $upid = PVE::API2::Network->reload_network_config(node => $nodename});
74 my $res = PVE
::Tools
::upid_decode
($upid);
79 __PACKAGE__-
>register_method ({
84 description
=> "Apply sdn controller changes && reload.",
86 check
=> ['perm', '/sdn', ['SDN.Allocate']],
89 additionalProperties
=> 0,
97 my $rpcenv = PVE
::RPCEnvironment
::get
();
98 my $authuser = $rpcenv->get_user();
100 if (-e
"/etc/pve/sdn/controllers.cfg.new") {
101 rename("/etc/pve/sdn/controllers.cfg.new", "/etc/pve/sdn/controllers.cfg")
102 || die "applying sdn/controllers.cfg changes failed - $!\n";
105 if (-e
"/etc/pve/sdn/zones.cfg.new") {
106 rename("/etc/pve/sdn/zones.cfg.new", "/etc/pve/sdn/zones.cfg")
107 || die "applying sdn/zones.cfg changes failed - $!\n";
110 if (-e
"/etc/pve/sdn/vnets.cfg.new") {
111 rename("/etc/pve/sdn/vnets.cfg.new", "/etc/pve/sdn/vnets.cfg")
112 || die "applying sdn/vnets.cfg changes failed - $!\n";
116 $rpcenv->{type
} = 'priv'; # to start tasks in background
117 PVE
::Cluster
::check_cfs_quorum
();
118 my $nodelist = PVE
::Cluster
::get_nodelist
();
119 foreach my $node (@$nodelist) {
122 eval { $pid = &$create_reload_network_worker($node); };
129 return $rpcenv->fork_worker('reloadnetworkall', undef, $authuser, $code);