summaryrefslogtreecommitdiff
path: root/src/conf_mode/service_ipoe-server.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-04-18 18:38:05 +0200
committerChristian Poessinger <christian@poessinger.com>2020-04-18 18:38:05 +0200
commitb81a37d19abfac0dbc1f49860dbe75a4f8caed61 (patch)
treeb5bebcd15390f418185412ed0eb25b0e5cdcbd35 /src/conf_mode/service_ipoe-server.py
parente9a2c4b96edc52ea114451ece6884845ad18ba6f (diff)
downloadvyos-1x-b81a37d19abfac0dbc1f49860dbe75a4f8caed61.tar.gz
vyos-1x-b81a37d19abfac0dbc1f49860dbe75a4f8caed61.zip
ipoe-server: T2324: migrate IPv4/IPv6 name-servers to common node
Diffstat (limited to 'src/conf_mode/service_ipoe-server.py')
-rwxr-xr-xsrc/conf_mode/service_ipoe-server.py30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/conf_mode/service_ipoe-server.py b/src/conf_mode/service_ipoe-server.py
index e0a607629..25c33cc6d 100755
--- a/src/conf_mode/service_ipoe-server.py
+++ b/src/conf_mode/service_ipoe-server.py
@@ -22,9 +22,10 @@ from stat import S_IRUSR, S_IWUSR, S_IRGRP
from sys import exit
from vyos.config import Config
-from vyos import ConfigError
-from vyos.util import call, get_half_cpus
from vyos.template import render
+from vyos.util import call, get_half_cpus
+from vyos.validate import is_ipv4
+from vyos import ConfigError
ipoe_conf = '/run/accel-pppd/ipoe.conf'
ipoe_chap_secrets = '/run/accel-pppd/ipoe.chap-secrets'
@@ -94,15 +95,13 @@ def get_config():
ipoe['interfaces'].append(tmp)
conf.set_level(base_path)
- for server in ['server-1', 'server-2']:
- if conf.exists(['dns-server', server]):
- tmp = conf.return_value(['dns-server', server])
- ipoe['dnsv4'].append(tmp)
- for server in ['server-1', 'server-2', 'server-3']:
- if conf.exists(['dnsv6-server', server]):
- tmp = conf.return_value(['dnsv6-server', server])
- ipoe['dnsv6'].append(tmp)
+ if conf.exists(['name-server']):
+ for name_server in conf.return_values(['name-server']):
+ if is_ipv4(name_server):
+ ipoe['dnsv4'].append(name_server)
+ else:
+ ipoe['dnsv6'].append(name_server)
if conf.exists(['authentication', 'mode']):
ipoe['auth_mode'] = conf.return_value(['authentication', 'mode'])
@@ -215,9 +214,6 @@ def verify(ipoe):
if not ipoe:
return None
- import pprint
- pprint.pprint(ipoe)
-
if not ipoe['interfaces']:
raise ConfigError('No IPoE interface configured')
@@ -225,6 +221,12 @@ def verify(ipoe):
if not interface['range']:
raise ConfigError(f'No IPoE client subnet defined on interface "{{ interface }}"')
+ if len(ipoe['dnsv4']) > 2:
+ raise ConfigError('Not more then two IPv4 DNS name-servers can be configured')
+
+ if len(ipoe['dnsv6']) > 3:
+ raise ConfigError('Not more then three IPv6 DNS name-servers can be configured')
+
if ipoe['auth_mode'] == 'radius':
if len(ipoe['radius_server']) == 0:
raise ConfigError('RADIUS authentication requires at least one server')
@@ -272,8 +274,6 @@ def apply(ipoe):
call('systemctl restart accel-ppp@ipoe.service')
- raise ConfigError("faslkdjfhaslkjdfhklsjahdf")
-
if __name__ == '__main__':
try:
c = get_config()