Exemple #1
0
    def onPreInstall(self, data):
        """
        Handles the pre install event
        @type  data: dict
        @param data: relevant arguments for that given event
        @rtype: None
        @returns: Nothing
        """
        try:
            self.__logger.info("Executing NetworkTopology module (EVT_PRE_INSTALL).")
            # NIC status
            interfaces = Network.getAvailableInterfaces(False)
            activeLinkInterfaces = Network.getLinkedInterfaces(False)
            activeInterfaces = Network.getActiveInterfaces(False)
            udevInterfaces = Network.getAvailableInterfaces()
            udevActiveLinkInterfaces = Network.getLinkedInterfaces()
            udevActiveInterfaces = Network.getActiveInterfaces()
            self.__logger.debug("Network interfaces:")
            for line in pprint.pformat(interfaces).split('\n'):
                self.__logger.debug(line)
            self.__logger.debug("Network interfaces with link:")
            self.__logger.debug("%s" % activeLinkInterfaces)
            self.__logger.debug("Network interfaces with network configured:")
            self.__logger.debug("%s" % activeInterfaces)
            self.__logger.debug("Network interfaces (UDEV):")
            for line in pprint.pformat(udevInterfaces).split('\n'):
                self.__logger.debug(line)
            self.__logger.debug("Network interfaces with link (UDEV):")
            self.__logger.debug("%s" % udevActiveLinkInterfaces)
            self.__logger.debug("Network interfaces with network configured (UDEV):")
            self.__logger.debug("%s" % udevActiveInterfaces)

            # Configure network interfaces and bridges
            devDict = udevInterfaces
            devActiveList = udevActiveInterfaces
            if devDict:
                self.__fixDracutIfcfgFiles(devDict)
                for dev, mac in devDict.iteritems():
                    ifcfgFile = "/etc/sysconfig/network-scripts/ifcfg-%s" % dev
                    if not os.path.isfile(ifcfgFile):
                        self.__setEthConfigFile(dev, mac, devActiveList)
                        self.__logger.debug("Writing on ISO image ifcfg file:")
                        self.__logger.debug("%s" % ifcfgFile)
                        for line in pprint.pformat(self.__configFile).split('\n'):
                            self.__logger.debug(line)
                        Network.writeConfigFile(self.__configFile)
            else:
                self.__logger.debug("No NIC available!")
        except Exception as e:
            self.__logger.critical("Failed NetworkTopology module")
            self.__logger.critical("EXCEPTION:" + str(type(e)))
            self.__logger.critical(str(e))
            self.__logger.critical("Stacktrace:" + str(traceback.format_exc()))
            raise PKVMError("PREINSTALL", "NETWORKTOPOLOGY", "PRE_MODULES")
Exemple #2
0
    def __activeInterfaces(self):
        """
        Active link (ifconfig nic up) for the NICs with no link

        @rtype  : list
        @returns: list of NICs with link
        """
        interfaces = self.__devices
        activeInterfaces = Network.getLinkedInterfaces(False)
        deactiveInterfaces = [f for f in interfaces.keys() if not f in activeInterfaces]
        Network.activeLinkInterfaces(deactiveInterfaces)
        activeInterfaces = Network.getLinkedInterfaces(False)
        return activeInterfaces
Exemple #3
0
    def __hasLink(self):
        """
        Return the link status of the NIC

        @rtype: boolean
        @returns: True if NIC has link
        """
        activeLinkInterfaces = Network.getLinkedInterfaces(False)
        link = False
        if self.__interface in activeLinkInterfaces:
            link = True
        return link
Exemple #4
0
    def run(self):
        """
        Draws the screen

        @rtype: integer
        @returns: status of operation
        """
        devicesUp = Network.getLinkedInterfaces()
        #sortedDevices = sorted(self.__devices, key=self.__devices.get)
        sortedDevices = sorted(self.__devices)
        for dev in sortedDevices:
            bridge = "br%s" % dev
            if dev in devicesUp:
                active = UP.localize()
            elif bridge in devicesUp:
                active = UP.localize() + ' - %s' % bridge
            else:
                active = DOWN.localize()
            display = "%s [ %s ] (%s)" % (dev, self.__devices.get(dev), active)
            self.__list.append(display, dev)

        return self.__show()