Beispiel #1
0
    def loop(self):
        """
        Handles the main application loop

        @rtype:   nothing
        @returns: nothing
        """

        try:
            # Check if automated or not
            if self.__data['model'].get('action') in ['install', 'reinstall', 'upgrade']:
                self.automatedInstalls()

            self.__logger.info('Manual mode')
            language = choose_language(self.__viewer)

            # Check entitlement
            self.__logger.info("Checking entitlement...")
            if not isEntitled(self.__data):
                self.__logger.critical("Hardware is not entitled, aborting installation!")
                raise PKVMError("CONTROLLER", "INSTALLPROGRESS", "ENTITLEMENT")

            # obtain disk information and previous installs
            diskInfoWnd = self.__viewer.getMessageWindow()
            diskInfoWnd.show(GETTING_DISK_INFORMATION.localize())
            self.__partitioner.getDiskInfo()
            self.__partitioner.detectPreviousInstalls()
            diskInfoWnd.popWindow()

            licenseRet = self.license(language)
            while True:
                if not licenseRet:
                    language = choose_language(self.__viewer)
                    licenseRet = self.license(language)
                    continue

                # start the menu
                rc = self.menu()
                if rc == "back":
                    language = choose_language(self.__viewer)
                    licenseRet = self.license(language)

        except PKVMError as e:
            self.__logger.critical("PKVMError: %s" % e.getLogCode(e.args))
            self.__createLog()
            self.__viewer.getGeneralTopError().run(e.getCode(e.args))
            self.rebootSystem(True)
        except Exception as e:
            self.__logger.critical(STR_VERSION + ": Unexpected error (LOOP).")
            self.__logger.critical("EXCEPTION:" + str(type(e)))
            self.__logger.critical(str(e))
            self.__logger.critical("Stacktrace:" + str(traceback.format_exc()))
            pkvmError = PKVMError()
            unexpectedCode = pkvmError.getUnexpectedCode("CONTROLLER", "LOOP")
            self.__logger.critical("PKVMError: %s" % pkvmError.getLogCode(unexpectedCode[0]))
            self.__createLog()
            self.__viewer.getGeneralTopError().run(unexpectedCode)
            self.rebootSystem(True)
Beispiel #2
0
    def __init__(self, model, viewer):
        """
        Constructs the controller

        rtype:   nothing
        returns: nothing
        """
        # create logger
        logging.basicConfig(filename=LIVECD_INSTALLER_LOG,
                            level=logging.DEBUG,
                            format=LOG_FORMATTER)
        self.__logger = logging.getLogger(__name__)
        self.__logger.setLevel(logging.DEBUG)

        self.__model = model
        self.__viewer = viewer

        try:
            # validate log directory
            if not os.path.isdir(POWERKVM_LOG_DIR):
                os.makedirs(POWERKVM_LOG_DIR)

            self.__scriptController = ScriptFactory()

            # pack event data
            self.__data = {'model': model}

            self.__logger.info("Screen while detecting network")

            firstScreen = viewer.getFirstScreen()
            firstScreen.show()

            # notifies EVT_PRE_INSTALL
            self.__scriptController.notify(EVT_PRE_INSTALL, self.__data)

            # create partitioner instance
            self.__partitioner = Partitioner(self.__logger)
        except PKVMError as e:
            self.__logger.critical("PKVMError: %s" % e.getLogCode(e.args))
            self.__createLog()
            self.__viewer.getGeneralTopError().run(e.getCode(e.args))
            self.rebootSystem(True)
        except Exception as e:
            self.__logger.critical(STR_VERSION + ": Unexpected error (INIT).")
            self.__logger.critical("EXCEPTION:" + str(type(e)))
            self.__logger.critical(str(e))
            self.__logger.critical("Stacktrace:" + str(traceback.format_exc()))
            pkvmError = PKVMError()
            unexpectedCode = pkvmError.getUnexpectedCode("CONTROLLER", "INIT")
            self.__logger.critical("PKVMError: %s" % pkvmError.getLogCode(unexpectedCode[0]))
            self.__createLog()
            self.__viewer.getGeneralTopError().run(unexpectedCode)
            self.rebootSystem(True)