- if method == "proxy" or method == "tap":
- if 'mac' in self and self['mac']:
- raise PLCInvalidArgument, "For %s method, mac should not be specified" % method
- if 'ip' not in self or not self['ip']:
- raise PLCInvalidArgument, "For %s method, ip is required" % method
- if method == "tap" and ('gateway' not in self or not self['gateway']):
- raise PLCInvalidArgument, "For tap method, gateway is required and should be " \
- "the IP address of the node that proxies for this address"
- # Should check that the proxy address is reachable, but
- # there's no way to tell if the only primary interface is
- # DHCP!
-
- elif method == "static":
- for key in ['gateway', 'dns1']:
- if key not in self or not self[key]:
- if 'is_primary' in self and self['is_primary'] is True:
- raise PLCInvalidArgument, "For static method primary network, %s is required" % key
- else:
- 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]
- if not in_same_network(ip, network, netmask):
- raise PLCInvalidArgument, "IP address %s is inconsistent with network %s/%s" % \
- (ip, network, netmask)
- if not in_same_network(broadcast, network, netmask):
- raise PLCInvalidArgument, "Broadcast address %s is inconsistent with network %s/%s" % \
- (broadcast, network, netmask)
- if 'gateway' in globals() and not in_same_network(ip, gateway, netmask):
- raise PLCInvalidArgument, "Gateway %s is not reachable from %s/%s" % \
- (gateway, ip, netmask)
-
- elif method == "ipmi":
- if 'ip' not in self or not self['ip']:
- raise PLCInvalidArgument, "For ipmi method, ip is required"
-