summaryrefslogtreecommitdiff
path: root/PVE/Network/SDN/SubnetPlugin.pm
diff options
context:
space:
mode:
authorAlexandre Derumier <aderumier@odiso.com>2020-10-05 17:09:06 +0200
committerThomas Lamprecht <t.lamprecht@proxmox.com>2020-10-08 11:05:28 +0200
commit4ad7844283c42ac05ac9c771645fc74a0fd108ce (patch)
treed871c8244cb928ec05a3aca7deddcdf65e0f1a54 /PVE/Network/SDN/SubnetPlugin.pm
parent6f5f42e4435a4ec171f4634d3480208c271b39d5 (diff)
move dns options from subnets to zone
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
Diffstat (limited to 'PVE/Network/SDN/SubnetPlugin.pm')
-rw-r--r--PVE/Network/SDN/SubnetPlugin.pm41
1 files changed, 7 insertions, 34 deletions
diff --git a/PVE/Network/SDN/SubnetPlugin.pm b/PVE/Network/SDN/SubnetPlugin.pm
index 8a216b6..f57a5e9 100644
--- a/PVE/Network/SDN/SubnetPlugin.pm
+++ b/PVE/Network/SDN/SubnetPlugin.pm
@@ -71,22 +71,6 @@ sub properties {
# type => 'string',
# description => "static routes [network=<network>:gateway=<ip>,network=<network>:gateway=<ip>,... ]",
# },
- dns => {
- type => 'string',
- description => "dns api server",
- },
- reversedns => {
- type => 'string',
- description => "reverse dns api server",
- },
- dnszone => {
- type => 'string', format => 'dns-name',
- description => "dns domain zone ex: mydomain.com",
- },
- reversednszone => {
- type => 'string', format => 'dns-name',
- description => "reverse dns zone ex: 0.168.192.in-addr.arpa",
- },
dnszoneprefix => {
type => 'string', format => 'dns-name',
description => "dns domain zone prefix ex: 'adm' -> <hostname>.adm.mydomain.com",
@@ -104,17 +88,13 @@ sub options {
gateway => { optional => 1 },
# routes => { optional => 1 },
snat => { optional => 1 },
- dns => { optional => 1 },
- reversedns => { optional => 1 },
- dnszone => { optional => 1 },
- reversednszone => { optional => 1 },
dnszoneprefix => { optional => 1 },
ipam => { optional => 0 },
};
}
sub on_update_hook {
- my ($class, $subnetid, $subnet, $old_subnet) = @_;
+ my ($class, $zone, $subnetid, $subnet, $old_subnet) = @_;
my $cidr = $subnetid =~ s/-/\//r;
my $subnet_matcher = subnet_matcher($cidr);
@@ -122,10 +102,9 @@ sub on_update_hook {
my $vnetid = $subnet->{vnet};
my $gateway = $subnet->{gateway};
my $ipam = $subnet->{ipam};
- my $dns = $subnet->{dns};
- my $dnszone = $subnet->{dnszone};
- my $reversedns = $subnet->{reversedns};
- my $reversednszone = $subnet->{reversednszone};
+ my $dns = $zone->{dns};
+ my $dnszone = $zone->{dnszone};
+ my $reversedns = $zone->{reversedns};
my $old_gateway = $old_subnet->{gateway} if $old_subnet;
@@ -139,12 +118,6 @@ sub on_update_hook {
#for /32 pointopoint, we allow gateway outside the subnet
raise_param_exc({ gateway => "$gateway is not in subnet $subnetid"}) if $gateway && !$subnet_matcher->($gateway) && $mask != 32;
- raise_param_exc({ dns => "missing dns provider"}) if $dnszone && !$dns;
- raise_param_exc({ dnszone => "missing dns zone"}) if $dns && !$dnszone;
- raise_param_exc({ reversedns => "missing dns provider"}) if $reversednszone && !$reversedns;
- raise_param_exc({ reversednszone => "missing dns zone"}) if $reversedns && !$reversednszone;
- raise_param_exc({ reversedns => "missing forward dns zone"}) if $reversednszone && !$dnszone;
-
if ($ipam) {
my $ipam_cfg = PVE::Network::SDN::Ipams::config();
my $plugin_config = $ipam_cfg->{ids}->{$ipam};
@@ -155,18 +128,18 @@ sub on_update_hook {
#delete on removal
if (!defined($gateway) && $old_gateway) {
eval {
- PVE::Network::SDN::Subnets::del_ip($subnetid, $old_subnet, $old_gateway);
+ PVE::Network::SDN::Subnets::del_ip($zone, $subnetid, $old_subnet, $old_gateway);
};
warn if $@;
}
if(!$old_gateway || $gateway && $gateway ne $old_gateway) {
- PVE::Network::SDN::Subnets::add_ip($subnetid, $subnet, $gateway);
+ PVE::Network::SDN::Subnets::add_ip($zone, $subnetid, $subnet, $gateway);
}
#delete old ip after update
if($gateway && $old_gateway && $gateway ne $old_gateway) {
eval {
- PVE::Network::SDN::Subnets::del_ip($subnetid, $old_subnet, $old_gateway);
+ PVE::Network::SDN::Subnets::del_ip($zone, $subnetid, $old_subnet, $old_gateway);
};
warn if $@;
}