From 1170627c76832513faf152af5bf1d4ffaf588c02 Mon Sep 17 00:00:00 2001 From: Marc Fiuczynski Date: Thu, 20 Nov 2008 14:00:32 +0000 Subject: [PATCH] Bail more gracefully when "data" from GetSlivers() does not contain the fields needed by the various Init*() functions. --- net.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/net.py b/net.py index 394c9d7..9fb4bce 100644 --- a/net.py +++ b/net.py @@ -17,6 +17,8 @@ def GetSlivers(plc, data): InitNAT(plc, data) def InitNodeLimit(data): + if not 'networks' in data: return + # query running network interfaces devs = sioc.gifconf() ips = dict(zip(devs.values(), devs.keys())) @@ -60,6 +62,8 @@ def InitNodeLimit(data): # again, or vice-versa. def InitI2(plc, data): + if not 'groups' in data: return + if "Internet2" in data['groups']: logger.log("This is an Internet2 node. Setting rules.") i2nodes = [] @@ -83,6 +87,8 @@ def InitI2(plc, data): os.popen("/sbin/iptables -t mangle " + cmd) def InitNAT(plc, data): + if not 'networks' in data: return + # query running network interfaces devs = sioc.gifconf() ips = dict(zip(devs.values(), devs.keys())) @@ -131,6 +137,8 @@ def InitNAT(plc, data): ipt.commit() def InitInterfaces(plc, data): + if not 'networks' in data: return + sysconfig = "/etc/sysconfig/network-scripts" # query running network interfaces @@ -144,7 +152,7 @@ def InitInterfaces(plc, data): interfaces = {} interface = 1 hostname = data.get('hostname',socket.gethostname()) - networks = data.get('networks',()) + networks = data['networks'] failedToGetSettings = False for network in networks: logger.log('interface %d: %s'%(interface,network)) -- 2.43.0