From 84028c2339bfdffd50626d694207c1a273f373ef Mon Sep 17 00:00:00 2001 From: Stephen Fromm Date: Sat, 11 Aug 2012 10:41:50 -0700 Subject: [PATCH 1/2] Tweak invocation of ip in LinuxNetwork Specify full path to ip and add third argument 'show' to be explicit about requested action. This goes from 'ip addr' to '/sbin/ip addr show'. --- library/setup | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/setup b/library/setup index a20bbc662c4..9020012ff71 100755 --- a/library/setup +++ b/library/setup @@ -454,7 +454,7 @@ class LinuxNetwork(Network): ipv6_address = None ) - output = subprocess.Popen(['ip','addr'], stdout=subprocess.PIPE).communicate()[0] + output = subprocess.Popen(['/sbin/ip','addr', 'show'], stdout=subprocess.PIPE).communicate()[0] for line in output.split('\n'): if line: words = line.split() From c4ce5f9497ff10b0735875bf0d2d716c84386ddb Mon Sep 17 00:00:00 2001 From: Stephen Fromm Date: Sat, 11 Aug 2012 12:05:08 -0700 Subject: [PATCH 2/2] Try to find ip command in either /sbin or /usr/sbin If ip is not found in either /sbin or /usr/sbin, this will return an empty result. It seems extremely unlikely that a linux system will not have iproute2 installed --- library/setup | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/library/setup b/library/setup index 9020012ff71..37cf5daf2d7 100755 --- a/library/setup +++ b/library/setup @@ -453,8 +453,13 @@ class LinuxNetwork(Network): ipv4_address = None, ipv6_address = None ) - - output = subprocess.Popen(['/sbin/ip','addr', 'show'], stdout=subprocess.PIPE).communicate()[0] + ipbin = '/sbin/ip' + if not os.path.exists(ipbin): + if os.path.exists('/usr/sbin/ip'): + ipbin = '/usr/sbin/ip' + else: + return interfaces, ips + output = subprocess.Popen([ipbin, 'addr', 'show'], stdout=subprocess.PIPE).communicate()[0] for line in output.split('\n'): if line: words = line.split()