summaryrefslogtreecommitdiff
path: root/python/vyos
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2020-05-17 20:42:03 +0200
committerChristian Poessinger <christian@poessinger.com>2020-05-17 20:42:03 +0200
commitdd6d46f7a60fcc196172e8a7278d7f91e9a63dda (patch)
tree1eb17f8aaed85cae44f859bbca68ace5d913a302 /python/vyos
parentca2f7e5e62efa163843b45a4f89c1e66d40a9a4a (diff)
parent8f1fd7ce8e9202a20913fe2f9c701af7a0b9fc72 (diff)
downloadvyos-1x-dd6d46f7a60fcc196172e8a7278d7f91e9a63dda.tar.gz
vyos-1x-dd6d46f7a60fcc196172e8a7278d7f91e9a63dda.zip
Merge branch 'ipv6-pd' of github.com:c-po/vyos-1x into current
* 'ipv6-pd' of github.com:c-po/vyos-1x: pppoe: dhcpv6-pd: T421: change system type to forking pppoe: dhcpv6-pd: T421: stop service when config is removed pppoe: dhcpv6-pd: T421: start/stop delegation with interface status pppoe: dhcpv6-pd: T421: initial support dhcpv6-pd: T421: migrate from ISC dhclient to wide-dhcpv6-client
Diffstat (limited to 'python/vyos')
-rw-r--r--python/vyos/ifconfig/dhcp.py26
1 files changed, 8 insertions, 18 deletions
diff --git a/python/vyos/ifconfig/dhcp.py b/python/vyos/ifconfig/dhcp.py
index 57e488cc7..f8fdeb6a9 100644
--- a/python/vyos/ifconfig/dhcp.py
+++ b/python/vyos/ifconfig/dhcp.py
@@ -19,11 +19,10 @@ from vyos.dicts import FixedDict
from vyos.ifconfig.control import Control
from vyos.template import render
-config_base = r'/var/lib/dhcp/dhclient_'
-
class _DHCPv4 (Control):
def __init__(self, ifname):
super().__init__()
+ config_base = r'/var/lib/dhcp/dhclient_'
self.options = FixedDict(**{
'ifname': ifname,
'hostname': '',
@@ -85,13 +84,11 @@ class _DHCPv6 (Control):
super().__init__()
self.options = FixedDict(**{
'ifname': ifname,
- 'conf_file': config_base + f'v6_{ifname}.conf',
- 'options_file': config_base + f'v6_{ifname}.options',
- 'pid_file': config_base + f'v6_{ifname}.pid',
- 'lease_file': config_base + f'v6_{ifname}.leases',
'dhcpv6_prm_only': False,
'dhcpv6_temporary': False,
+ 'dhcpv6_pd': [],
})
+ self._conf_file = f'/run/dhcp6c/dhcp6c.{ifname}.conf'
def set(self):
"""
@@ -111,10 +108,8 @@ class _DHCPv6 (Control):
raise Exception(
'DHCPv6 temporary and parameters-only options are mutually exclusive!')
- render(self.options['options_file'], 'dhcp-client/daemon-options.tmpl', self.options)
- render(self.options['conf_file'], 'dhcp-client/ipv6.tmpl', self.options)
-
- return self._cmd('systemctl restart dhclient6@{ifname}.service'.format(**self.options))
+ render(self._conf_file, 'dhcp-client/ipv6.tmpl', self.options, trim_blocks=True)
+ return self._cmd('systemctl restart dhcp6c@{ifname}.service'.format(**self.options))
def delete(self):
"""
@@ -127,16 +122,11 @@ class _DHCPv6 (Control):
>>> j = Interface('eth0')
>>> j.dhcp.v6.delete()
"""
- if not os.path.isfile(self.options['pid_file']):
- self._debug_msg('No DHCPv6 client PID found')
- return None
-
- self._cmd('systemctl stop dhclient6@{ifname}.service'.format(**self.options))
+ self._cmd('systemctl stop dhcp6c@{ifname}.service'.format(**self.options))
# cleanup old config files
- for name in ('conf_file', 'options_file', 'pid_file', 'lease_file'):
- if os.path.isfile(self.options[name]):
- os.remove(self.options[name])
+ if os.path.isfile(self._conf_file):
+ os.remove(self._conf_file)
class DHCP(object):