diff options
| author | Alexandre Derumier <aderumier@odiso.com> | 2020-10-05 17:08:38 +0200 |
|---|---|---|
| committer | Thomas Lamprecht <t.lamprecht@proxmox.com> | 2020-10-06 17:30:01 +0200 |
| commit | c33dd81818c4b04119b0dc43cbbf8548c58df047 (patch) | |
| tree | bc72777bfd687a181626c47b79ef52278e9b225d /PVE/Network/SDN/Subnets.pm | |
| parent | a5b8d7de4c7f6e9e6853e3d7e3f17a4cbf6aa6a6 (diff) | |
add subnet plugin
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Diffstat (limited to 'PVE/Network/SDN/Subnets.pm')
| -rw-r--r-- | PVE/Network/SDN/Subnets.pm | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/PVE/Network/SDN/Subnets.pm b/PVE/Network/SDN/Subnets.pm new file mode 100644 index 0000000..454a9cf --- /dev/null +++ b/PVE/Network/SDN/Subnets.pm @@ -0,0 +1,55 @@ +package PVE::Network::SDN::Subnets; + +use strict; +use warnings; + +use PVE::Cluster qw(cfs_read_file cfs_write_file cfs_lock_file); + +use PVE::Network::SDN::SubnetPlugin; +PVE::Network::SDN::SubnetPlugin->register(); +PVE::Network::SDN::SubnetPlugin->init(); + +sub sdn_subnets_config { + my ($cfg, $id, $noerr) = @_; + + die "no sdn subnet ID specified\n" if !$id; + + my $scfg = $cfg->{ids}->{$id}; + die "sdn subnet '$id' does not exist\n" if (!$noerr && !$scfg); + + return $scfg; +} + +sub config { + my $config = cfs_read_file("sdn/subnets.cfg"); +} + +sub write_config { + my ($cfg) = @_; + + cfs_write_file("sdn/subnets.cfg", $cfg); +} + +sub sdn_subnets_ids { + my ($cfg) = @_; + + return keys %{$cfg->{ids}}; +} + +sub complete_sdn_subnet { + my ($cmdname, $pname, $cvalue) = @_; + + my $cfg = PVE::Network::SDN::Subnets::config(); + + return $cmdname eq 'add' ? [] : [ PVE::Network::SDN::Subnets::sdn_subnets_ids($cfg) ]; +} + +sub get_subnet { + my ($subnetid) = @_; + + my $cfg = PVE::Network::SDN::Subnets::config(); + my $subnet = PVE::Network::SDN::Subnets::sdn_subnets_config($cfg, $subnetid, 1); + return $subnet; +} + +1; |
