From a7083429020488390319e84dd003d80668154ae6 Mon Sep 17 00:00:00 2001 From: John Estabrook Date: Wed, 4 Dec 2019 16:08:01 -0600 Subject: [vyos.config] T1847: correctly set_level for path given as empty string --- python/vyos/config.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'python') diff --git a/python/vyos/config.py b/python/vyos/config.py index 13b2c107e..c677d3118 100644 --- a/python/vyos/config.py +++ b/python/vyos/config.py @@ -160,7 +160,10 @@ class Config(object): # and path supplied as method argument # XXX: for small strings in-place concatenation is not a problem if isinstance(path, str): - self._level = re.split(r'\s*', path) + if path: + self._level = re.split(r'\s*', path) + else: + self._level = [] elif isinstance(path, list): self._level = path else: -- cgit v1.2.3 From 242251ea50f1d26127effc140933cbdb1149a206 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Fri, 6 Dec 2019 19:07:51 +0100 Subject: ifconfig: T1793: remove dhcpv6 client debug output --- python/vyos/ifconfig.py | 2 -- 1 file changed, 2 deletions(-) (limited to 'python') diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py index f487e6a5b..2f2f05f74 100644 --- a/python/vyos/ifconfig.py +++ b/python/vyos/ifconfig.py @@ -615,8 +615,6 @@ class Interface: >>> j.set_dhcpv6() """ dhcpv6 = self.get_dhcpv6_options() - import pprint - pprint.pprint(dhcpv6) # better save then sorry .. should be checked in interface script # but if you missed it we are safe! -- cgit v1.2.3 From 3a16fb46a16f91557f6805e74aafb568f46fd1c0 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Fri, 6 Dec 2019 19:32:09 +0100 Subject: Python/VyOS validate: T1849: handle is_ipv6()/is_ipv6() exceptions --- python/vyos/validate.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'python') diff --git a/python/vyos/validate.py b/python/vyos/validate.py index 258f7f76a..3f3166022 100644 --- a/python/vyos/validate.py +++ b/python/vyos/validate.py @@ -29,10 +29,13 @@ def is_ipv4(addr): # With the below statement we can check for IPv4 networks and host # addresses at the same time - if ipaddress.ip_address(addr.split(r'/')[0]).version == 4: - return True - else: - return False + try: + if ipaddress.ip_address(addr.split(r'/')[0]).version == 4: + return True + except: + pass + + return False def is_ipv6(addr): """ @@ -41,10 +44,13 @@ def is_ipv6(addr): # With the below statement we can check for IPv4 networks and host # addresses at the same time - if ipaddress.ip_network(addr.split(r'/')[0]).version == 6: - return True - else: - return False + try: + if ipaddress.ip_network(addr.split(r'/')[0]).version == 6: + return True + except: + pass + + return False def is_intf_addr_assigned(intf, addr): """ -- cgit v1.2.3 From 6e2cf6e4515b2f143d1e2fdff6fe22fcc666ce18 Mon Sep 17 00:00:00 2001 From: Christian Poessinger Date: Fri, 6 Dec 2019 19:32:45 +0100 Subject: ifconfig: T1849: fix DHCPv6 startup --- python/vyos/ifconfig.py | 53 ++++++++++++++++++++++++------------------------- 1 file changed, 26 insertions(+), 27 deletions(-) (limited to 'python') diff --git a/python/vyos/ifconfig.py b/python/vyos/ifconfig.py index 2f2f05f74..72f11c04d 100644 --- a/python/vyos/ifconfig.py +++ b/python/vyos/ifconfig.py @@ -627,33 +627,32 @@ class Interface: with open(self._dhcpv6_cfg_file, 'w') as f: f.write(dhcpv6_text) - if self.get_state() == 'up': - # https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/1447715 - # - # wee need to wait for IPv6 DAD to finish once and interface is added - # this suxx :-( - sleep(5) - - # no longer accept router announcements on this interface - self._write_sysfs('/proc/sys/net/ipv6/conf/{}/accept_ra' - .format(self._ifname), 0) - - # assemble command-line to start DHCPv6 client (dhclient) - cmd = 'start-stop-daemon --start --quiet --pidfile ' + \ - self._dhcpv6_pid_file - cmd += ' --exec /sbin/dhclient --' - # now pass arguments to dhclient binary - cmd += ' -6 -nw -cf {} -pf {} -lf {}'.format( - self._dhcpv6_cfg_file, self._dhcpv6_pid_file, self._dhcpv6_lease_file) - - # add optional arguments - if dhcpv6['dhcpv6_prm_only']: - cmd += ' -S' - if dhcpv6['dhcpv6_temporary']: - cmd += ' -T' - - cmd += ' {}'.format(self._ifname) - return self._cmd(cmd) + # https://bugs.launchpad.net/ubuntu/+source/ifupdown/+bug/1447715 + # + # wee need to wait for IPv6 DAD to finish once and interface is added + # this suxx :-( + sleep(5) + + # no longer accept router announcements on this interface + self._write_sysfs('/proc/sys/net/ipv6/conf/{}/accept_ra' + .format(self._ifname), 0) + + # assemble command-line to start DHCPv6 client (dhclient) + cmd = 'start-stop-daemon --start --quiet --pidfile ' + \ + self._dhcpv6_pid_file + cmd += ' --exec /sbin/dhclient --' + # now pass arguments to dhclient binary + cmd += ' -6 -nw -cf {} -pf {} -lf {}'.format( + self._dhcpv6_cfg_file, self._dhcpv6_pid_file, self._dhcpv6_lease_file) + + # add optional arguments + if dhcpv6['dhcpv6_prm_only']: + cmd += ' -S' + if dhcpv6['dhcpv6_temporary']: + cmd += ' -T' + + cmd += ' {}'.format(self._ifname) + return self._cmd(cmd) def _del_dhcpv6(self): -- cgit v1.2.3