summaryrefslogtreecommitdiff
path: root/src/PVE/API2/Network/SDN.pm
diff options
context:
space:
mode:
authorThomas Lamprecht <t.lamprecht@proxmox.com>2025-06-16 22:28:00 +0200
committerThomas Lamprecht <t.lamprecht@proxmox.com>2025-06-16 22:39:01 +0200
commitd6ca483c5bde56367dde0a9715a55e0a3a1de4d9 (patch)
treee380fbdd93f1589a70bcb9d8a6638e53ef138ef1 /src/PVE/API2/Network/SDN.pm
parent33aab51365bffc21b840c121a7673c9a2a30921a (diff)
auto-format code using perltidy with Proxmox style guide
using the new top-level `make tidy` target, which calls perltidy via our wrapper to enforce the desired style as closely as possible. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Diffstat (limited to 'src/PVE/API2/Network/SDN.pm')
-rw-r--r--src/PVE/API2/Network/SDN.pm96
1 files changed, 50 insertions, 46 deletions
diff --git a/src/PVE/API2/Network/SDN.pm b/src/PVE/API2/Network/SDN.pm
index d216e48..b514803 100644
--- a/src/PVE/API2/Network/SDN.pm
+++ b/src/PVE/API2/Network/SDN.pm
@@ -20,27 +20,27 @@ use PVE::API2::Network::SDN::Dns;
use base qw(PVE::RESTHandler);
-__PACKAGE__->register_method ({
+__PACKAGE__->register_method({
subclass => "PVE::API2::Network::SDN::Vnets",
path => 'vnets',
});
-__PACKAGE__->register_method ({
+__PACKAGE__->register_method({
subclass => "PVE::API2::Network::SDN::Zones",
path => 'zones',
});
-__PACKAGE__->register_method ({
+__PACKAGE__->register_method({
subclass => "PVE::API2::Network::SDN::Controllers",
path => 'controllers',
});
-__PACKAGE__->register_method ({
+__PACKAGE__->register_method({
subclass => "PVE::API2::Network::SDN::Ipams",
path => 'ipams',
});
-__PACKAGE__->register_method ({
+__PACKAGE__->register_method({
subclass => "PVE::API2::Network::SDN::Dns",
path => 'dns',
});
@@ -51,35 +51,36 @@ __PACKAGE__->register_method({
method => 'GET',
description => "Directory index.",
permissions => {
- check => ['perm', '/sdn', [ 'SDN.Audit' ]],
+ check => ['perm', '/sdn', ['SDN.Audit']],
},
parameters => {
- additionalProperties => 0,
- properties => {},
+ additionalProperties => 0,
+ properties => {},
},
returns => {
- type => 'array',
- items => {
- type => "object",
- properties => {
- id => { type => 'string' },
- },
- },
- links => [ { rel => 'child', href => "{id}" } ],
+ type => 'array',
+ items => {
+ type => "object",
+ properties => {
+ id => { type => 'string' },
+ },
+ },
+ links => [{ rel => 'child', href => "{id}" }],
},
code => sub {
- my ($param) = @_;
+ my ($param) = @_;
- my $res = [
- { id => 'vnets' },
- { id => 'zones' },
- { id => 'controllers' },
- { id => 'ipams' },
- { id => 'dns' },
- ];
+ my $res = [
+ { id => 'vnets' },
+ { id => 'zones' },
+ { id => 'controllers' },
+ { id => 'ipams' },
+ { id => 'dns' },
+ ];
- return $res;
- }});
+ return $res;
+ },
+});
my $create_reload_network_worker = sub {
my ($nodename) = @_;
@@ -87,26 +88,29 @@ my $create_reload_network_worker = sub {
# FIXME: how to proxy to final node ?
my $upid;
print "$nodename: reloading network config\n";
- run_command(['pvesh', 'set', "/nodes/$nodename/network"], outfunc => sub {
- my $line = shift;
- if ($line =~ /["']?(UPID:[^\s"']+)["']?$/) {
- $upid = $1;
- }
- });
+ run_command(
+ ['pvesh', 'set', "/nodes/$nodename/network"],
+ outfunc => sub {
+ my $line = shift;
+ if ($line =~ /["']?(UPID:[^\s"']+)["']?$/) {
+ $upid = $1;
+ }
+ },
+ );
#my $upid = PVE::API2::Network->reload_network_config(node => $nodename});
my $res = PVE::Tools::upid_decode($upid);
return $res->{pid};
};
-__PACKAGE__->register_method ({
+__PACKAGE__->register_method({
name => 'reload',
protected => 1,
path => '',
method => 'PUT',
description => "Apply sdn controller changes && reload.",
permissions => {
- check => ['perm', '/sdn', ['SDN.Allocate']],
+ check => ['perm', '/sdn', ['SDN.Allocate']],
},
parameters => {
additionalProperties => 0,
@@ -120,26 +124,26 @@ __PACKAGE__->register_method ({
my $rpcenv = PVE::RPCEnvironment::get();
my $authuser = $rpcenv->get_user();
- PVE::Network::SDN::commit_config();
+ PVE::Network::SDN::commit_config();
my $code = sub {
$rpcenv->{type} = 'priv'; # to start tasks in background
- PVE::Cluster::check_cfs_quorum();
- my $nodelist = PVE::Cluster::get_nodelist();
- for my $node (@$nodelist) {
- my $pid = eval { $create_reload_network_worker->($node) };
- warn $@ if $@;
- }
+ PVE::Cluster::check_cfs_quorum();
+ my $nodelist = PVE::Cluster::get_nodelist();
+ for my $node (@$nodelist) {
+ my $pid = eval { $create_reload_network_worker->($node) };
+ warn $@ if $@;
+ }
- # FIXME: use libpve-apiclient (like in cluster join) to create
- # tasks and moitor the tasks.
+ # FIXME: use libpve-apiclient (like in cluster join) to create
+ # tasks and moitor the tasks.
- return;
+ return;
};
return $rpcenv->fork_worker('reloadnetworkall', undef, $authuser, $code);
- }});
-
+ },
+});
1;