Bail more gracefully when "data" from GetSlivers() does not contain
authorMarc Fiuczynski <mef@cs.princeton.edu>
Thu, 20 Nov 2008 14:00:32 +0000 (14:00 +0000)
committerMarc Fiuczynski <mef@cs.princeton.edu>
Thu, 20 Nov 2008 14:00:32 +0000 (14:00 +0000)
the fields needed by the various Init*() functions.

net.py

diff --git a/net.py b/net.py
index 394c9d7..9fb4bce 100644 (file)
--- 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))