Make DNS optional as well for non-primary static networks.
authorDaniel Hokka Zakrisson <dhokka@cs.princeton.edu>
Tue, 27 Nov 2007 22:05:24 +0000 (22:05 +0000)
committerDaniel Hokka Zakrisson <dhokka@cs.princeton.edu>
Tue, 27 Nov 2007 22:05:24 +0000 (22:05 +0000)
PLC/NodeNetworks.py

index 75dddf6..f63ca23 100644 (file)
@@ -182,10 +182,12 @@ class NodeNetwork(Row):
             # DHCP!
 
         elif method == "static":
-           if 'gateway' not in self or self['gateway'] is None:
-               if 'is_primary' in self and self['is_primary'] is True:
-                   raise PLCInvalidArgument, "For static method primary network, gateway is required"
-            for key in ['ip', 'network', 'broadcast', 'netmask', 'dns1']:
+            if 'is_primary' in self and self['is_primary'] is True:
+                for key in ['gateway', 'dns1']:
+                    if key not in self or not self[key]:
+                        raise PLCInvalidArgument, "For static method primary network, %s is required" % key
+                    globals()[key] = self[key]
+            for key in ['ip', 'network', 'broadcast', 'netmask']:
                 if key not in self or not self[key]:
                     raise PLCInvalidArgument, "For static method, %s is required" % key
                 globals()[key] = self[key]