From c29f0955045cdd02965a14300ce5e99364db2d1b Mon Sep 17 00:00:00 2001 From: Jeremy Katz Date: Fri, 21 Mar 2003 00:09:53 +0000 Subject: merge taroon branch up until now. tagged as before-taroon-merge before and will be tagged after-taroon-merge after. taroon at this point is tagged taroon-merge-point for where to base merges from in the future --- network.py | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) (limited to 'network.py') diff --git a/network.py b/network.py index 53e3e83ca..b59c947f0 100644 --- a/network.py +++ b/network.py @@ -20,6 +20,7 @@ import string import isys import socket import os +import re from rhpl.log import log from rhpl.translate import _, N_ @@ -51,6 +52,44 @@ def networkDeviceCheck(network, dispatch): if not devs: dispatch.skipStep("network") + +# return if the device is of a type that requires a ptpaddr to be specified +def isPtpDev(devname): + if (devname.startswith("ctc") or devname.startswith("escon") or + devname.startswith("iucv")): + return 1 + return 0 + +# determine whether any active at boot devices are using dhcp +def anyUsingDHCP(devices): + for dev in devices.keys(): + bootproto = devices[dev].get("bootproto") + if bootproto and bootproto == "dhcp": + onboot = devices[dev].get("onboot") + if onboot and onboot != "no": + return 1 + return 0 + +# sanity check an IP string. if valid, returns octets, if invalid, return None +def sanityCheckIPString(ip_string): + ip_re = re.compile('^([0-2]?[0-9]?[0-9])\\.([0-2]?[0-9]?[0-9])\\.([0-2]?[0-9]?[0-9])\\.([0-2]?[0-9]?[0-9])$') + + #Sanity check the string + m = ip_re.match (ip_string) + try: + if not m: + return None + octets = m.groups() + if len(octets) != 4: + return None + for octet in octets: + if (int(octet) < 0) or (int(octet) > 255): + return None + except TypeError: + return None + + return octets + class NetworkDevice(SimpleConfigFile): def __str__(self): s = "" @@ -113,7 +152,8 @@ class Network: netinf = string.splitfields(line, '=') info [netinf[0]] = string.strip(netinf[1]) self.netdevices [info["DEVICE"]] = NetworkDevice(info["DEVICE"]) - for key in ("IPADDR", "NETMASK", "BOOTPROTO", "ONBOOT", "MTU"): + for key in ("IPADDR", "NETMASK", "BOOTPROTO", "ONBOOT", "MTU", + "REMIP"): if info.has_key(key): self.netdevices [info["DEVICE"]].set((key, info[key])) if info.has_key("GATEWAY"): -- cgit