Exemplo n.º 1
0
def hasActiveNetDev():
    # try to load /tmp/netinfo and see if we can sniff out network info
    netinfo = Network()
    for dev in netinfo.netdevices.keys():
        try:
            ip = isys.getIPAddress(dev)
        except Exception, e:
            log.error("Got an exception trying to get the ip addr of %s: " "%s" % (dev, e))
            continue
        if ip == "127.0.0.1" or ip is None:
            continue
        if isys.getLinkStatus(dev):
            return True
Exemplo n.º 2
0
def hasActiveNetDev():
    # try to load /tmp/netinfo and see if we can sniff out network info
    netinfo = Network()
    for dev in netinfo.netdevices.keys():
        try:
            ip = isys.getIPAddress(dev)
        except Exception, e:
            log.error("Got an exception trying to get the ip addr of %s: "
                      "%s" % (dev, e))
            continue
        if ip == '127.0.0.1' or ip is None:
            continue
        if isys.getLinkStatus(dev):
            return True
Exemplo n.º 3
0
    def initialize(self):
        """Here is were all the relative vars get initialized. """

        # see if we can sniff out network info
        netinfo = network.Network()

        devices = netinfo.netdevices
        active_devs = network.getActiveNetDevs()

        if active_devs != []:
            dev = devices[active_devs[0]]

            try:
                self.ip = isys.getIPAddress(dev.get("DEVICE"))
                log.info("ip of %s is %s" % (dev.get("DEVICE"), self.ip))

                if self.ip == "127.0.0.1" or self.ip == "::1":
                    self.ip = None
            except Exception, e:
                log.warning("Got an exception trying to get the self.ip addr "
                            "of %s: %s" % (dev.get("DEVICE"), e))
Exemplo n.º 4
0
        # try to load /tmp/netinfo and see if we can sniff out network info
        netinfo = network.Network()
        srvname = None

        # If we have a real hostname that resolves against configured DNS
        # servers, use that for the name to connect to.
        if netinfo.hostname != "localhost.localdomain" and netinfo.lookupHostname(
        ) is not None:
            srvname = netinfo.hostname
        else:
            # Otherwise, look for the first configured interface and use its
            # IP address for the name to connect to.
            dev = netinfo.getFirstDeviceName()

            try:
                ip = isys.getIPAddress(dev)
                log.info("ip of %s is %s" % (dev, ip))
            except Exception, e:
                log.warning("Got an exception trying to get the ip addr "
                            "of %s: %s" % (dev, e))

            if ip != "127.0.0.1" and ip is not None:
                srvname = ip
            else:
                # If we get here and there's no valid IP address, just use the
                # hostname and hope for the best (better than displaying nothing)
                srvname = netinfo.hostname

        if srvname is not None:
            connxinfo = "%s:1" % (srvname, )
Exemplo n.º 5
0
	# try to load /tmp/netinfo and see if we can sniff out network info
	netinfo = network.Network()
	srvname = None

        # If we have a real hostname that resolves against configured DNS
        # servers, use that for the name to connect to.
        if netinfo.hostname != "localhost.localdomain" and netinfo.lookupHostname() is not None:
	    srvname = netinfo.hostname
	else:
            # Otherwise, look for the first configured interface and use its
            # IP address for the name to connect to.
            dev = netinfo.getFirstDeviceName()

            try:
                ip = isys.getIPAddress(dev)
                log.info("ip of %s is %s" % (dev, ip))
            except Exception, e:
                log.warning("Got an exception trying to get the ip addr "
                            "of %s: %s" % (dev, e))

            if ip != "127.0.0.1" and ip is not None:
                srvname = ip
            else:
                # If we get here and there's no valid IP address, just use the
                # hostname and hope for the best (better than displaying nothing)
                srvname = netinfo.hostname

	if srvname is not None:
	    connxinfo = "%s:1" % (srvname,)