From 6be1e19d982ca87bee234e15ae159447d61013d5 Mon Sep 17 00:00:00 2001 From: Jeff Ahrenholz Date: Thu, 31 Oct 2019 13:20:28 -0700 Subject: [PATCH 1/3] don't flush IPv6 address if interface is absent --- daemon/core/nodes/netclient.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daemon/core/nodes/netclient.py b/daemon/core/nodes/netclient.py index b201493f..7a9cc2d8 100644 --- a/daemon/core/nodes/netclient.py +++ b/daemon/core/nodes/netclient.py @@ -126,7 +126,7 @@ class LinuxNetClient: :param str device: device to flush :return: nothing """ - self.run(f"{IP_BIN} -6 address flush dev {device}") + self.run(f"[ -e /sys/class/net/{device} ] && {IP_BIN} -6 address flush dev {device} || echo") def device_mac(self, device, mac): """ From ddcce82af4b5023651b9ac9736f56cf6e4f5a99f Mon Sep 17 00:00:00 2001 From: Jeff Ahrenholz Date: Thu, 7 Nov 2019 09:01:01 -0800 Subject: [PATCH 2/3] address PR comments and fix pre-commit --- daemon/core/nodes/netclient.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/daemon/core/nodes/netclient.py b/daemon/core/nodes/netclient.py index 7a9cc2d8..4a7250f0 100644 --- a/daemon/core/nodes/netclient.py +++ b/daemon/core/nodes/netclient.py @@ -126,7 +126,10 @@ class LinuxNetClient: :param str device: device to flush :return: nothing """ - self.run(f"[ -e /sys/class/net/{device} ] && {IP_BIN} -6 address flush dev {device} || echo") + self.run( + f"[ -e /sys/class/net/{device} ] && {IP_BIN} -6 address flush dev {device} || true", + shell=True, + ) def device_mac(self, device, mac): """ From 2d9cf81d0b980cf5788e6adeecff20f8a1b82234 Mon Sep 17 00:00:00 2001 From: Jeff Ahrenholz Date: Thu, 7 Nov 2019 11:38:31 -0800 Subject: [PATCH 3/3] remove shell=True from run command --- daemon/core/nodes/netclient.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/daemon/core/nodes/netclient.py b/daemon/core/nodes/netclient.py index 4a7250f0..4d568a64 100644 --- a/daemon/core/nodes/netclient.py +++ b/daemon/core/nodes/netclient.py @@ -127,8 +127,7 @@ class LinuxNetClient: :return: nothing """ self.run( - f"[ -e /sys/class/net/{device} ] && {IP_BIN} -6 address flush dev {device} || true", - shell=True, + f"[ -e /sys/class/net/{device} ] && {IP_BIN} -6 address flush dev {device} || true" ) def device_mac(self, device, mac):