def available(self): ksdevice = None if flags.cmdline.has_key('ksdevice'): ksdevice = flags.cmdline['ksdevice'] for dev in isys.getDeviceProperties().keys(): if not self.netdevices.has_key(dev): self.netdevices[dev] = NetworkDevice(dev) hwaddr = isys.getMacAddress(dev) if hwaddr is None: # not a valid device log.warning("invalid hwaddr for: %s" % (dev,)) continue self.netdevices[dev].set(('HWADDR', hwaddr)) self.netdevices[dev].set(('DESC', isys.getNetDevDesc(dev))) if not ksdevice: continue if ksdevice == 'link' and isys.getLinkStatus(dev): self.ksdevice = dev elif ksdevice == dev: self.ksdevice = dev elif ksdevice.find(':') != -1: if ksdevice.upper() == hwaddr: self.ksdevice = dev return self.netdevices
def available(self): ksdevice = None if flags.cmdline.has_key("ksdevice"): ksdevice = flags.cmdline["ksdevice"] f = open("/proc/net/dev") lines = f.readlines() f.close() # skip first two lines, they are header lines = lines[2:] for line in lines: dev = string.strip(line[0:6]) if dev != "lo" and dev[0:3] != "sit" and not self.netdevices.has_key(dev): if self.firstnetdevice is None: self.firstnetdevice = dev self.netdevices[dev] = NetworkDevice(dev) try: hwaddr = isys.getMacAddress(dev) if rhpl.getArch() != "s390" and hwaddr and hwaddr != "00:00:00:00:00:00" and hwaddr != "ff:ff:ff:ff:ff:ff": self.netdevices[dev].set(("hwaddr", hwaddr)) if not ksdevice: continue if ksdevice == 'link' and isys.getLinkStatus(dev): self.ksdevice = dev elif ksdevice == dev: self.ksdevice = dev elif ksdevice.find(':') != -1: if ksdevice.upper() == hwaddr: self.ksdevice = dev except Exception, e: log.error("exception getting mac addr: %s" %(e,))
def available(self): ksdevice = None if flags.cmdline.has_key('ksdevice'): ksdevice = flags.cmdline['ksdevice'] for dev in isys.getDeviceProperties().keys(): if not self.netdevices.has_key(dev): self.netdevices[dev] = NetworkDevice(dev) hwaddr = isys.getMacAddress(dev) if hwaddr is None: # not a valid device log.warning("invalid hwaddr for: %s" % (dev, )) continue self.netdevices[dev].set(('HWADDR', hwaddr)) self.netdevices[dev].set(('DESC', isys.getNetDevDesc(dev))) if not ksdevice: continue if ksdevice == 'link' and isys.getLinkStatus(dev): self.ksdevice = dev elif ksdevice == dev: self.ksdevice = dev elif ksdevice.find(':') != -1: if ksdevice.upper() == hwaddr: self.ksdevice = dev return self.netdevices
def available(self): ksdevice = None if flags.cmdline.has_key("ksdevice"): ksdevice = flags.cmdline["ksdevice"] f = open("/proc/net/dev") lines = f.readlines() f.close() # skip first two lines, they are header lines = lines[2:] for line in lines: dev = string.strip(line[0:6]) if dev != "lo" and dev[ 0:3] != "sit" and not self.netdevices.has_key(dev): if self.firstnetdevice is None: self.firstnetdevice = dev self.netdevices[dev] = NetworkDevice(dev) try: hwaddr = isys.getMacAddress(dev) if rhpl.getArch( ) != "s390" and hwaddr and hwaddr != "00:00:00:00:00:00" and hwaddr != "ff:ff:ff:ff:ff:ff": self.netdevices[dev].set(("hwaddr", hwaddr)) except Exception, e: log.error("exception getting mac addr: %s" % (e, ))
def lookupHostname(self): # can't look things up if they don't exist! if not self.hostname or self.hostname == "localhost": return None if not self.primaryNS: return myns = self.primaryNS if not self.isConfigured: for dev in self.netdevices.values(): usemethod = dev.get('bootproto').lower() while True: if (usemethod == "ibft" and dev.get('onboot') == "yes"): try: if anaconda.id.iscsi.fwinfo["iface.bootproto"].lower() == "dhcp": usemethod = "dhcp" continue else: hwaddr = isys.getMacAddress(dev) if hwaddr != anaconda.id.iscsi.fwinfo["iface.hwaddress"]: log.error("The iBFT configuration does not belong to device %s," "falling back to dhcp", dev.get('device')) usemethod = "dhcp" continue isys.configNetDevice(dev.get('device'), anaconda.id.iscsi.fwinfo["iface.ipaddress"], anaconda.id.iscsi.fwinfo["iface.subnet_mask"], anaconda.id.iscsi.fwinfo["iface.gateway"]) self.isConfigured = 1 except: log.error("failed to configure network device %s using " "iBFT information, falling back to dhcp", dev.get('device')) usemethod = "dhcp" continue elif (usemethod == "dhcp" and dev.get('onboot') == "yes"): ret = isys.dhcpNetDevice(dev.get('device'), dev.get('dhcpclass')) # if ret is None: # continue # myns = ret self.isConfigured = 1 break elif (dev.get('ipaddr') and dev.get('netmask') and self.gateway is not None and dev.get('onboot') == "yes"): try: isys.configNetDevice(dev.get('device'), dev.get('ipaddr'), dev.get('netmask'), self.gateway) self.isConfigured = 1 break except SystemError: log.error("failed to configure network device %s when " "looking up host name", dev.get('device')) #try it only once break if self.isConfigured and not flags.rootpath: f = open("/etc/resolv.conf", "w") f.write("nameserver %s\n" % myns) f.close() isys.resetResolv() isys.setResolvRetry(1) if not self.isConfigured: log.warning("no network devices were available to look up host name") return None try: (family, socktype, proto, canonname, sockaddr) = \ socket.getaddrinfo(self.hostname, None, socket.AF_INET)[0] (ip, port) = sockaddr except: try: (family, socktype, proto, canonname, sockaddr) = \ socket.getaddrinfo(self.hostname, None, socket.AF_INET6)[0] (ip, port, flowinfo, scopeid) = sockaddr except: return None return ip
def __init__(self): self.ksdevice = None self.firstnetdevice = None self.netdevices = {} self.gateway = "" self.primaryNS = "" self.secondaryNS = "" self.domains = [] self.isConfigured = 0 self.hostname = "localhost" self.query = False self.dve_dvelist = [] self.br0_ip = "" self.br0_pr = "" self.r_button_dhcp = False # if we specify a hostname and are using dhcp, do an override # originally used by the gui but overloaded now # we also test in places if the hostname is localhost.localdomain # to see if its been override. Need some consolidation in future. self.overrideDHCPhostname = 0 self.hostname_dhcp=True if flags.rootpath: self.isConfigured = 1 try: f = open("/tmp/netinfo", "r") except: pass else: lines = f.readlines() f.close() info = {} self.isConfigured = 1 for line in lines: netinf = string.splitfields(line, '=') if len(netinf) >= 3: info[netinf[0]] = '='.join([string.strip(s) for s in netinf[1:]]) elif len(netinf) >= 2: info [netinf[0]] = string.strip(netinf[1]) self.netdevices [info["DEVICE"]] = NetworkDevice(info["DEVICE"]) self.firstnetdevice = info["DEVICE"] for key in ("IPADDR", "NETMASK", "BOOTPROTO", "ONBOOT", "MTU", "NETTYPE", "SUBCHANNELS", "PORTNAME", "CTCPROT", "PEERID", "ESSID", "KEY", "IPV6ADDR", "IPV6_AUTOCONF", "OPTIONS", "ARP", "MACADDR"): if info.has_key(key): self.netdevices [info["DEVICE"]].set((key, info[key])) self.netdevices [info["DEVICE"]].set(('useIPv4', flags.useIPv4)) self.netdevices [info["DEVICE"]].set(('useIPv6', flags.useIPv6)) if info.has_key("GATEWAY"): self.gateway = info["GATEWAY"] if info.has_key("DOMAIN"): self.domains.append(info["DOMAIN"]) if info.has_key("HOSTNAME"): self.hostname = info["HOSTNAME"] if not info.has_key("BOOTPROTO"): if not info.has_key("IPADDR"): self.netdevices [info["DEVICE"]].set(('useIPv4', False)) if not (info.has_key("IPV6ADDR") and info.has_key("IPV6_AUTOCONF")): self.netdevices [info["DEVICE"]].set(('useIPv6', False)) try: f = open("/etc/resolv.conf", "r") except: pass else: lines = f.readlines() f.close() for line in lines: resolv = string.split(line) if resolv and resolv[0] == 'nameserver': if self.primaryNS == "": self.primaryNS = resolv[1] elif self.secondaryNS == "": self.secondaryNS = resolv[1] # now initialize remaining devices # XXX we just throw return away, the method initialize a # object member so we dont need to available_devices = self.available() if len(available_devices) > 0: # set first device to start up onboot oneactive = 0 for dev in available_devices.keys(): try: if available_devices[dev].get("onboot") == "yes": oneactive = 1 break except: continue if not oneactive: self.netdevices[self.firstnetdevice].set(("onboot", "yes")) for device in self.netdevices.keys(): hwaddr = isys.getMacAddress(device) if hwaddr and hwaddr != "00:00:00:00:00:00" and hwaddr != "ff:ff:ff:ff:ff:ff": self.netdevices[device].set(("hwaddr", hwaddr))
def startNetworking(network, intf, anaconda): # do lo first try: os.system("/usr/sbin/ifconfig lo 127.0.0.1") except: log.error("Error trying to start lo in rescue.py::startNetworking()") # start up dhcp interfaces first dhcpGotNS = 0 devs = network.netdevices.keys() devs.sort() for devname in devs: dev = network.netdevices[devname] waitwin = intf.waitWindow(_("Starting Interface"), _("Attempting to start %s") % (dev.get('device'),)) log.info("Attempting to start %s", dev.get('device')) method = dev.get('bootproto') while True: if method == "ibft": try: if anaconda.id.iscsi.fwinfo["iface.bootproto"].lower() == "dhcp": method = "dhcp" continue else: hwaddr = isys.getMacAddress(dev) if hwaddr != anaconda.id.iscsi.fwinfo["iface.hwaddress"]: log.error("The iBFT configuration does not belong to device %s," "falling back to dhcp", dev.get('device')) method = "dhcp" continue isys.configNetDevice(dev.get('device'), anaconda.id.iscsi.fwinfo["iface.ipaddress"], anaconda.id.iscsi.fwinfo["iface.subnet_mask"], anaconda.id.iscsi.fwinfo["iface.gateway"]) except: log.error("failed to configure network device %s using " "iBFT information, falling back to dhcp", dev.get('device')) usemethod = "dhcp" continue elif method == "dhcp": try: ns = isys.dhcpNetDevice(dev.get('device')) if ns: if not dhcpGotNS: dhcpGotNS = 1 f = open("/etc/resolv.conf", "w") f.write("nameserver %s\n" % ns) f.close() except: log.error("Error trying to start %s in rescue.py::startNetworking()", dev.get('device')) elif dev.get('ipaddr') and dev.get('netmask') and network.gateway is not None: try: isys.configNetDevice(dev.get('device'), dev.get('ipaddr'), dev.get('netmask'), network.gateway) except: log.error("Error trying to start %s in rescue.py::startNetworking()", dev.get('device')) #do that only once break waitwin.pop() # write out resolv.conf if dhcp didnt get us one if not dhcpGotNS: f = open("/etc/resolv.conf", "w") if network.domains != ['localdomain'] and network.domains: f.write("search %s\n" % (string.joinfields(network.domains, ' '),)) for ns in network.nameservers(): if ns: f.write("nameserver %s\n" % (ns,)) f.close()
def __init__(self): self.firstnetdevice = None self.netdevices = {} self.gateway = "" self.primaryNS = "" self.secondaryNS = "" self.domains = [] self.isConfigured = 0 self.hostname = "localhost.localdomain" self.query = False # if we specify a hostname and are using dhcp, do an override # originally used by the gui but overloaded now # we also test in places if the hostname is localhost.localdomain # to see if its been override. Need some consolidation in future. self.overrideDHCPhostname = 0 if flags.rootpath: self.isConfigured = 1 try: f = open("/tmp/netinfo", "r") except: pass else: lines = f.readlines() f.close() info = {} self.isConfigured = 1 for line in lines: netinf = string.splitfields(line, '=') if len(netinf) >= 3: info[netinf[0]] = '='.join([string.strip(s) for s in netinf[1:]]) elif len(netinf) >= 2: info [netinf[0]] = string.strip(netinf[1]) self.netdevices [info["DEVICE"]] = NetworkDevice(info["DEVICE"]) self.firstnetdevice = info["DEVICE"] for key in ("IPADDR", "NETMASK", "BOOTPROTO", "ONBOOT", "MTU", "NETTYPE", "SUBCHANNELS", "PORTNAME", "CTCPROT", "PEERID", "ESSID", "KEY", "IPV6ADDR", "IPV6_AUTOCONF", "OPTIONS", "ARP", "MACADDR"): if info.has_key(key): self.netdevices [info["DEVICE"]].set((key, info[key])) osa_opts = [] for key in ("LAYER2", "PORTNO"): if info.has_key(key) and info[key] == "1": osa_opts.append(key.lower() + "=" + info[key]) if osa_opts: self.netdevices[info["DEVICE"]].set(("OPTIONS", " ".join(osa_opts))) self.netdevices [info["DEVICE"]].set(('useIPv4', flags.useIPv4)) self.netdevices [info["DEVICE"]].set(('useIPv6', flags.useIPv6)) if info.has_key("GATEWAY"): self.gateway = info["GATEWAY"] if info.has_key("DOMAIN"): self.domains.append(info["DOMAIN"]) if info.has_key("HOSTNAME"): self.hostname = info["HOSTNAME"] if not info.has_key("BOOTPROTO"): if not info.has_key("IPADDR"): self.netdevices [info["DEVICE"]].set(('useIPv4', False)) if not (info.has_key("IPV6ADDR") and info.has_key("IPV6_AUTOCONF")): self.netdevices [info["DEVICE"]].set(('useIPv6', False)) try: f = open("/etc/resolv.conf", "r") except: pass else: lines = f.readlines() f.close() for line in lines: resolv = string.split(line) if resolv and resolv[0] == 'nameserver': if self.primaryNS == "": self.primaryNS = resolv[1] elif self.secondaryNS == "": self.secondaryNS = resolv[1] # now initialize remaining devices # XXX we just throw return away, the method initialize a # object member so we dont need to available_devices = self.available() if len(available_devices) > 0: # set first device to start up onboot oneactive = 0 for dev in available_devices.keys(): try: if available_devices[dev].get("onboot") == "yes": oneactive = 1 break except: continue if not oneactive: self.netdevices[self.firstnetdevice].set(("onboot", "yes")) # assign description to each device based on kudzu information probedevs = kudzu.probe(kudzu.CLASS_NETWORK, kudzu.BUS_UNSPEC, 0) for netdev in probedevs: device = netdev.device if device in self.netdevices.keys(): desc = netdev.desc if desc is not None and len(desc) > 0: self.netdevices[device].set(("desc", desc)) # hwaddr for qeth doesn't make sense (#135023) if netdev.driver == "qeth": continue # add hwaddr hwaddr = isys.getMacAddress(device) if hwaddr and hwaddr != "00:00:00:00:00:00" and hwaddr != "ff:ff:ff:ff:ff:ff": self.netdevices[device].set(("hwaddr", hwaddr))
def startNetworking(network, intf, anaconda): # do lo first try: os.system("/usr/sbin/ifconfig lo 127.0.0.1") except: log.error("Error trying to start lo in rescue.py::startNetworking()") # start up dhcp interfaces first dhcpGotNS = 0 devs = network.netdevices.keys() devs.sort() for devname in devs: dev = network.netdevices[devname] waitwin = intf.waitWindow( _("Starting Interface"), _("Attempting to start %s") % (dev.get('device'), )) log.info("Attempting to start %s", dev.get('device')) method = dev.get('bootproto') while True: if method == "ibft": try: if anaconda.id.iscsi.fwinfo["iface.bootproto"].lower( ) == "dhcp": method = "dhcp" continue else: hwaddr = isys.getMacAddress(dev) if hwaddr != anaconda.id.iscsi.fwinfo[ "iface.hwaddress"]: log.error( "The iBFT configuration does not belong to device %s," "falling back to dhcp", dev.get('device')) method = "dhcp" continue isys.configNetDevice( dev.get('device'), anaconda.id.iscsi.fwinfo["iface.ipaddress"], anaconda.id.iscsi.fwinfo["iface.subnet_mask"], anaconda.id.iscsi.fwinfo["iface.gateway"]) except: log.error( "failed to configure network device %s using " "iBFT information, falling back to dhcp", dev.get('device')) usemethod = "dhcp" continue elif method == "dhcp": try: ns = isys.dhcpNetDevice(dev.get('device')) if ns: if not dhcpGotNS: dhcpGotNS = 1 f = open("/etc/resolv.conf", "w") f.write("nameserver %s\n" % ns) f.close() except: log.error( "Error trying to start %s in rescue.py::startNetworking()", dev.get('device')) elif dev.get('ipaddr') and dev.get( 'netmask') and network.gateway is not None: try: isys.configNetDevice(dev.get('device'), dev.get('ipaddr'), dev.get('netmask'), network.gateway) except: log.error( "Error trying to start %s in rescue.py::startNetworking()", dev.get('device')) #do that only once break waitwin.pop() # write out resolv.conf if dhcp didnt get us one if not dhcpGotNS: f = open("/etc/resolv.conf", "w") if network.domains != ['localdomain'] and network.domains: f.write("search %s\n" % (string.joinfields(network.domains, ' '), )) for ns in network.nameservers(): if ns: f.write("nameserver %s\n" % (ns, )) f.close()
def lookupHostname(self): # can't look things up if they don't exist! if not self.hostname or self.hostname == "localhost.localdomain": return None if not self.primaryNS: return myns = self.primaryNS if not self.isConfigured: for dev in self.netdevices.values(): usemethod = dev.get('bootproto').lower() while True: if (usemethod == "ibft" and dev.get('onboot') == "yes"): try: if anaconda.id.iscsi.fwinfo[ "iface.bootproto"].lower() == "dhcp": usemethod = "dhcp" continue else: hwaddr = isys.getMacAddress(dev) if hwaddr != anaconda.id.iscsi.fwinfo[ "iface.hwaddress"]: log.error( "The iBFT configuration does not belong to device %s," "falling back to dhcp", dev.get('device')) usemethod = "dhcp" continue isys.configNetDevice( dev.get('device'), anaconda.id.iscsi. fwinfo["iface.ipaddress"], anaconda.id. iscsi.fwinfo["iface.subnet_mask"], anaconda.id.iscsi.fwinfo["iface.gateway"]) self.isConfigured = 1 except: log.error( "failed to configure network device %s using " "iBFT information, falling back to dhcp", dev.get('device')) usemethod = "dhcp" continue elif (usemethod == "dhcp" and dev.get('onboot') == "yes"): ret = isys.dhcpNetDevice(dev.get('device'), dev.get('dhcpclass')) if ret is None: continue myns = ret self.isConfigured = 1 break elif (dev.get('ipaddr') and dev.get('netmask') and self.gateway is not None and dev.get('onboot') == "yes"): try: isys.configNetDevice(dev.get('device'), dev.get('ipaddr'), dev.get('netmask'), self.gateway) self.isConfigured = 1 break except SystemError: log.error( "failed to configure network device %s when " "looking up host name", dev.get('device')) #try it only once break if self.isConfigured and not flags.rootpath: f = open("/etc/resolv.conf", "w") f.write("nameserver %s\n" % myns) f.close() isys.resetResolv() isys.setResolvRetry(1) if not self.isConfigured: log.warning( "no network devices were available to look up host name") return None try: (family, socktype, proto, canonname, sockaddr) = \ socket.getaddrinfo(self.hostname, None, socket.AF_INET)[0] (ip, port) = sockaddr except: try: (family, socktype, proto, canonname, sockaddr) = \ socket.getaddrinfo(self.hostname, None, socket.AF_INET6)[0] (ip, port, flowinfo, scopeid) = sockaddr except: return None return ip
def __init__(self): self.firstnetdevice = None self.netdevices = {} self.gateway = "" self.primaryNS = "" self.secondaryNS = "" self.domains = [] self.isConfigured = 0 self.hostname = "localhost.localdomain" self.query = False # if we specify a hostname and are using dhcp, do an override # originally used by the gui but overloaded now # we also test in places if the hostname is localhost.localdomain # to see if its been override. Need some consolidation in future. self.overrideDHCPhostname = 0 if flags.rootpath: self.isConfigured = 1 try: f = open("/tmp/netinfo", "r") except: pass else: lines = f.readlines() f.close() info = {} self.isConfigured = 1 for line in lines: netinf = string.splitfields(line, '=') if len(netinf) >= 3: info[netinf[0]] = '='.join( [string.strip(s) for s in netinf[1:]]) elif len(netinf) >= 2: info[netinf[0]] = string.strip(netinf[1]) self.netdevices[info["DEVICE"]] = NetworkDevice(info["DEVICE"]) self.firstnetdevice = info["DEVICE"] for key in ("IPADDR", "NETMASK", "BOOTPROTO", "ONBOOT", "MTU", "NETTYPE", "SUBCHANNELS", "PORTNAME", "CTCPROT", "PEERID", "ESSID", "KEY", "IPV6ADDR", "IPV6_AUTOCONF", "OPTIONS", "ARP", "MACADDR"): if info.has_key(key): self.netdevices[info["DEVICE"]].set((key, info[key])) osa_opts = [] for key in ("LAYER2", "PORTNO"): if info.has_key(key) and info[key] == "1": osa_opts.append(key.lower() + "=" + info[key]) if osa_opts: self.netdevices[info["DEVICE"]].set( ("OPTIONS", " ".join(osa_opts))) self.netdevices[info["DEVICE"]].set(('useIPv4', flags.useIPv4)) self.netdevices[info["DEVICE"]].set(('useIPv6', flags.useIPv6)) if info.has_key("GATEWAY"): self.gateway = info["GATEWAY"] if info.has_key("DOMAIN"): self.domains.append(info["DOMAIN"]) if info.has_key("HOSTNAME"): self.hostname = info["HOSTNAME"] if not info.has_key("BOOTPROTO"): if not info.has_key("IPADDR"): self.netdevices[info["DEVICE"]].set(('useIPv4', False)) if not (info.has_key("IPV6ADDR") and info.has_key("IPV6_AUTOCONF")): self.netdevices[info["DEVICE"]].set(('useIPv6', False)) try: f = open("/etc/resolv.conf", "r") except: pass else: lines = f.readlines() f.close() for line in lines: resolv = string.split(line) if resolv and resolv[0] == 'nameserver': if self.primaryNS == "": self.primaryNS = resolv[1] elif self.secondaryNS == "": self.secondaryNS = resolv[1] # now initialize remaining devices # XXX we just throw return away, the method initialize a # object member so we dont need to available_devices = self.available() if len(available_devices) > 0: # set first device to start up onboot oneactive = 0 for dev in available_devices.keys(): try: if available_devices[dev].get("onboot") == "yes": oneactive = 1 break except: continue if not oneactive: self.netdevices[self.firstnetdevice].set(("onboot", "yes")) # assign description to each device based on kudzu information probedevs = kudzu.probe(kudzu.CLASS_NETWORK, kudzu.BUS_UNSPEC, 0) for netdev in probedevs: device = netdev.device if device in self.netdevices.keys(): self.netdevices[device].set(("useIPv4", flags.useIPv4)) self.netdevices[device].set(("useIPv6", flags.useIPv6)) desc = netdev.desc if desc is not None and len(desc) > 0: self.netdevices[device].set(("desc", desc)) # hwaddr for qeth doesn't make sense (#135023) if netdev.driver == "qeth": continue # add hwaddr hwaddr = isys.getMacAddress(device) if hwaddr and hwaddr != "00:00:00:00:00:00" and hwaddr != "ff:ff:ff:ff:ff:ff": self.netdevices[device].set(("hwaddr", hwaddr))
def __init__(self): self.firstnetdevice = None self.netdevices = {} self.gateway = "" self.primaryNS = "" self.secondaryNS = "" self.ternaryNS = "" self.domains = [] self.isConfigured = 0 self.hostname = "localhost.localdomain" # if we specify a hostname and are using dhcp, do an override # originally used by the gui but overloaded now # we also test in places if the hostname is localhost.localdomain # to see if its been override. Need some consolidation in future. self.overrideDHCPhostname = 0 try: f = open("/tmp/netinfo", "r") except: pass else: lines = f.readlines() f.close() info = {} self.isConfigured = 1 for line in lines: 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", "REMIP"): if info.has_key(key): self.netdevices[info["DEVICE"]].set((key, info[key])) if info.has_key("GATEWAY"): self.gateway = info["GATEWAY"] if info.has_key("DOMAIN"): self.domains.append(info["DOMAIN"]) if info.has_key("HOSTNAME"): self.hostname = info["HOSTNAME"] try: f = open("/etc/resolv.conf", "r") except: pass else: lines = f.readlines() f.close() for line in lines: resolv = string.split(line) if resolv and resolv[0] == 'nameserver': if self.primaryNS == "": self.primaryNS = resolv[1] elif self.secondaryNS == "": self.secondaryNS = resolv[1] elif self.ternaryNS == "": self.ternaryNS = resolv[1] # now initialize remaining devices # XXX we just throw return away, the method initialize a # object member so we dont need to available_devices = self.available() if len(available_devices) > 0: # set first device to start up onboot oneactive = 0 for dev in available_devices.keys(): try: if available_devices[dev].get("onboot") == "yes": oneactive = 1 break except: continue if not oneactive: self.netdevices[self.firstnetdevice].set(("onboot", "yes")) # assign description to each device based on kudzu information probedevs = kudzu.probe(kudzu.CLASS_NETWORK, kudzu.CLASS_UNSPEC, 0) for netdev in probedevs: device = netdev.device if device in self.netdevices.keys(): desc = netdev.desc if desc is not None and len(desc) > 0: self.netdevices[device].set(("desc", desc)) # add hwaddr hwaddr = isys.getMacAddress(device) if hwaddr and hwaddr != "00:00:00:00:00:00": self.netdevices[device].set(("hwaddr", hwaddr))