示例#1
0
def startNetworking(network, intf):

    # do lo first
    try:
	os.system("/usr/bin/ifconfig lo 127.0.0.1")
    except:
	log("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("Attempting to start %s", dev.get('device'))
	if dev.get('bootproto') == "dhcp":
	    try:
		ns = isys.pumpNetDevice(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 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 trying to start %s in rescue.py::startNetworking()", dev.get('device'))

	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()
示例#2
0
    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():
                if (dev.get('bootproto') == "dhcp"
                        and dev.get('onboot') == "yes"):
                    ret = isys.pumpNetDevice(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(
                            "failed to configure network device %s when "
                            "looking up host name", dev.get('device'))

        if not self.isConfigured:
            log("no network devices were available to look up host name")
            return None

        f = open("/etc/resolv.conf", "w")
        f.write("nameserver %s\n" % myns)
        f.close()
        isys.resetResolv()
        isys.setResolvRetry(1)

        try:
            ip = socket.gethostbyname(self.hostname)
        except:
            return None

        return ip
示例#3
0
    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
示例#4
0
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()
示例#5
0
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()
示例#6
0
    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
示例#7
0
            try:
                if gateway:
                    network.sanityCheckIPString(gateway)
            except network.IPError, msg:
                self._handleIPError(_("Gateway"), msg)
                return

            try:
                if ns:
                    network.sanityCheckIPString(ns)
            except network.IPError, msg:
                self._handleIPError(_("Nameserver"), msg)
                return

            try:
                isys.configNetDevice(netdev.get("device"),
                                     ipv4addr, ipv4nm, gateway)
            except Exception, e:
                log.error("Error configuring network device: %s" %(e,))

            self.rc = gtk.RESPONSE_OK
            if ns:
                f = open("/etc/resolv.conf", "w")
                f.write("nameserver %s\n" %(ns,))
                f.close()
                isys.resetResolv()
                isys.setResolvRetry(1)

        if self.rc != gtk.RESPONSE_OK:
            gui.MessageWindow(_("Error"),
                              _("Error configuring network device"),
                              type = "ok", custom_icon="error")
            try:
                if gateway:
                    network.sanityCheckIPString(gateway)
            except network.IPError, msg:
                self._handleIPError(_("Gateway"), msg)
                return

            try:
                if ns:
                    network.sanityCheckIPString(ns)
            except network.IPError, msg:
                self._handleIPError(_("Nameserver"), msg)
                return

            try:
                isys.configNetDevice(netdev.get("device"), ipv4addr, ipv4nm,
                                     gateway)
            except Exception, e:
                log.error("Error configuring network device: %s" % (e, ))

            self.rc = gtk.RESPONSE_OK
            if ns:
                f = open("/etc/resolv.conf", "w")
                f.write("nameserver %s\n" % (ns, ))
                f.close()
                isys.resetResolv()
                isys.setResolvRetry(1)

        if self.rc != gtk.RESPONSE_OK:
            gui.MessageWindow(_("Error"),
                              _("Error configuring network device"),
                              type="ok",