Beispiel #1
0
    def __initLogging(self):
        try:
            '''
            @Desc : 1. Initializes the logging for marvin and so provides
                    various log features for automation run.
                    2. Initializes all logs to be available under
                    given Folder Path,where all test run logs
                    are available for a given run.
                    3. All logging like exception log,results, run info etc
                     for a given test run are available under a given
                     timestamped folder
            '''
            temp_path = "".join(str(time.time()).split("."))
            if self.__logFolderPath is None:
                log_config = self.__parsedConfig.logger
                if log_config is not None:
                    if log_config.LogFolderPath is not None:
                        self.logFolderPath = log_config.LogFolderPath + '/' \
                            + temp_path
                    else:
                        self.logFolderPath = temp_path
                else:
                    self.logFolderPath = temp_path
            else:
                self.logFolderPath = self.__logFolderPath + '/' + temp_path
            if os.path.exists(self.logFolderPath):
                self.logFolderPath += ''.join(
                    random.choice(string.ascii_uppercase + string.digits
                                  for x in range(3)))
            os.makedirs(self.logFolderPath)
            '''
            Log File Paths
            '''
            tc_failed_exceptionlog = self.logFolderPath + "/failed_" \
                                                          "plus_" \
                                                          "exceptions.txt"
            tc_run_log = self.logFolderPath + "/runinfo.txt"
            self.__tcRunDebugFile = open(self.logFolderPath + "/results.txt",
                                         "w")

            log_obj = MarvinLog("CSLog")
            self.__tcRunLogger = log_obj.setLogHandler(tc_run_log)
            log_obj.setLogHandler(tc_failed_exceptionlog,
                                  log_level=logging.FATAL)
            return SUCCESS
        except Exception, e:
            print "\n Exception Occurred Under __initLogging :%s" % str(e)
            return None
Beispiel #2
0
    def __initLogging(self):
        try:
            '''
            @Desc : 1. Initializes the logging for marvin and so provides
                    various log features for automation run.
                    2. Initializes all logs to be available under
                    given Folder Path,where all test run logs
                    are available for a given run.
                    3. All logging like exception log,results, run info etc
                     for a given test run are available under a given
                     timestamped folder
            '''
            temp_path = "".join(str(time.time()).split("."))
            if self.__logFolderPath is None:
                log_config = self.__parsedConfig.logger
                if log_config is not None:
                    if log_config.LogFolderPath is not None:
                        self.logFolderPath = log_config.LogFolderPath + '/' \
                            + temp_path
                    else:
                        self.logFolderPath = temp_path
                else:
                    self.logFolderPath = temp_path
            else:
                self.logFolderPath = self.__logFolderPath + '/' + temp_path
            if os.path.exists(self.logFolderPath):
                self.logFolderPath += ''.join(random.choice(
                    string.ascii_uppercase +
                    string.digits for x in range(3)))
            os.makedirs(self.logFolderPath)
            '''
            Log File Paths
            '''
            tc_failed_exceptionlog = self.logFolderPath + "/failed_" \
                                                          "plus_" \
                                                          "exceptions.txt"
            tc_run_log = self.logFolderPath + "/runinfo.txt"
            self.__tcRunDebugFile = open(self.logFolderPath +
                                         "/results.txt", "w")

            log_obj = MarvinLog("CSLog")
            self.__tcRunLogger = log_obj.setLogHandler(tc_run_log)
            log_obj.setLogHandler(tc_failed_exceptionlog,
                                  log_level=logging.FATAL)
            return SUCCESS
        except Exception, e:
            print "\n Exception Occurred Under __initLogging :%s" % str(e)
            return None
        self.updateConfiguration(self.config.globalConfig)
        self.createZones(self.config.zones)
        self.configureS3(self.config.s3)

if __name__ == "__main__":
    parser = OptionParser()
    parser.add_option("-i", "--input", action="store",
                      default="./datacenterCfg", dest="input", help="the path \
                      where the json config file generated, by default is \
                      ./datacenterCfg")

    (options, args) = parser.parse_args()
    from marvin.marvinLog import MarvinLog
    cfg = configGenerator.getSetupConfig(options.input)
    log_obj = MarvinLog("CSLog")
    tcRunLogger = log_obj.setLogHandler("/tmp/debug.log")
    deploy = deployDataCenters(cfg, tcRunLogger)
    deploy.deploy()

    """
    create = createStoragePool.createStoragePoolCmd()
    create.clusterid = 1
    create.podid = 2
    create.name = "fdffdf"
    create.url = "nfs://jfkdjf/fdkjfkd"
    create.zoneid = 2

    deploy = deployDataCenters("./datacenterCfg")
    deploy.loadCfg()
    deploy.apiClient.createStoragePool(create)
    """
if __name__ == "__main__":
    parser = OptionParser()
    parser.add_option("-i",
                      "--input",
                      action="store",
                      default="./datacenterCfg",
                      dest="input",
                      help="the path \
                      where the json config file generated, by default is \
                      ./datacenterCfg")

    (options, args) = parser.parse_args()
    from marvin.marvinLog import MarvinLog
    cfg = configGenerator.getSetupConfig(options.input)
    log_obj = MarvinLog("CSLog")
    tcRunLogger = log_obj.setLogHandler("/tmp/debug.log")
    deploy = deployDataCenters(cfg, tcRunLogger)
    deploy.deploy()
    """
    create = createStoragePool.createStoragePoolCmd()
    create.clusterid = 1
    create.podid = 2
    create.name = "fdffdf"
    create.url = "nfs://jfkdjf/fdkjfkd"
    create.zoneid = 2

    deploy = deployDataCenters("./datacenterCfg")
    deploy.loadCfg()
    deploy.apiClient.createStoragePool(create)
    """