Exemple #1
0
    def onPreInstall(self, data):
        """
        Handles the post install event

        @type  data: dict
        @param data: relevant arguments for that given event

        @rtype  : nothing
        @returns: nothing
        """
        try:

            self.__logger.info("Executing InstallAuto module (EVT_PRE_INSTALL).")
            # work on bootline command file.
            with open(CMD_FILE) as fd:
                # parser and store bootline command
                cmdLine = fd.read().rstrip().split()
            self.__logger.debug("Bootline:")
            for line in pprint.pformat(cmdLine).split('\n'):
                self.__logger.debug(line)

            # liveDVD parser
            for i in cmdLine:
                if i == "root=live:LABEL=POWERKVM_LIVECD":
                    self.__logger.debug("Boot from liveDVD, trying to start network...")
                    Network.startLiveDVDNetwork()
                    break

            # kickstart parser
            for i in cmdLine:
                if i.startswith('kvmp.inst.auto='):
                    self.__kickstartFile = i[i.find('=')+1:]
                    self.__logger.debug("Kickstart file from bootline: %s" % self.__kickstartFile)
                    self.__parserFile()
                    break

            self.__logger.debug("Data Structure:")
            for line in pprint.pformat(self.__data).split('\n'):
                self.__logger.debug(line)
            for key, value in self.__data.iteritems():
                data['model'].insert(key, value)
        except PKVMError:
            self.__logger.critical("Failed InstallAuto module")
            raise
        except Exception as e:
            self.__logger.critical("Failed InstallAuto module")
            self.__logger.critical("EXCEPTION:" + str(type(e)))
            self.__logger.critical(str(e))
            self.__logger.critical("Stacktrace:" + str(traceback.format_exc()))
            raise PKVMError("PREINSTALL", "INSTALLAUTO", "PRE_MODULES")