From: Daniel Hokka Zakrisson Date: Tue, 27 Nov 2007 22:05:24 +0000 (+0000) Subject: Make DNS optional as well for non-primary static networks. X-Git-Tag: PLCAPI-4.2-0~19 X-Git-Url: http://git.onelab.eu/?a=commitdiff_plain;h=c3d34f43f41f2aceb6e73dc5d2fc00b9ca96582d;p=plcapi.git Make DNS optional as well for non-primary static networks. --- diff --git a/PLC/NodeNetworks.py b/PLC/NodeNetworks.py index 75dddf67..f63ca23f 100644 --- a/PLC/NodeNetworks.py +++ b/PLC/NodeNetworks.py @@ -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]