client/tools/spacewalk-koan/spacewalkkoan/spacewalkkoan.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
New commits: commit f8924b4c4c71bfe851e3084b612f7e9934c9738f Author: Milan Zazrivec mzazrivec@redhat.com Date: Wed Nov 30 17:26:26 2011 +0100
fix TB during re-provisioning with static nic
This fix is to prevent exception in case no address/netmask was found:
<type 'exceptions.IndexError'> list index out of range File "/usr/share/rhn/spacewalkkoan/spacewalkkoan.py", line 100, in initiate update_static_device_records(kickstart_host, static_device) File "/usr/share/rhn/spacewalkkoan/spacewalkkoan.py", line 78, in update_static_device_records "ip": find_ip(static_device),\ File "/usr/share/rhn/spacewalkkoan/spacewalkkoan.py", line 52, in find_ip return execute("LANG=C ifconfig %s | perl -lne '/inet addr:([\d.]+)/ and print $1'" % device)[0]
diff --git a/client/tools/spacewalk-koan/spacewalkkoan/spacewalkkoan.py b/client/tools/spacewalk-koan/spacewalkkoan/spacewalkkoan.py index 281e594..1420580 100644 --- a/client/tools/spacewalk-koan/spacewalkkoan/spacewalkkoan.py +++ b/client/tools/spacewalk-koan/spacewalkkoan/spacewalkkoan.py @@ -46,7 +46,11 @@ def find_host_name(): return execute("hostname")[0]
def find_netmask(device): - return execute("LANG=C ifconfig %s | perl -lne '/Mask:([\d.]+)/ and print $1'" % device)[0] + nm = execute("LANG=C ifconfig %s | perl -lne '/Mask:([\d.]+)/ and print $1'" % device) + if nm: + return nm[0] + else: + return ""
def find_netmask6(device): nm6 = execute("LANG=C ifconfig %s | perl -lne '/inet6 addr: [[:xdigit:]:]+/([\d]+).+Scope:Global/ and print $1'" % device) @@ -56,7 +60,11 @@ def find_netmask6(device): return ""
def find_ip(device): - return execute("LANG=C ifconfig %s | perl -lne '/inet addr:([\d.]+)/ and print $1'" % device)[0] + ip = execute("LANG=C ifconfig %s | perl -lne '/inet addr:([\d.]+)/ and print $1'" % device) + if ip: + return ip[0] + else: + return ""
def find_ip6(device): ip6 = execute("LANG=C ifconfig %s | perl -lne '/inet6 addr: ([[:xdigit:]:]+).+Scope:Global/ and print $1'" % device)
spacewalk-commits@lists.fedorahosted.org