def processEventFromQueueToExecuteScenario(executionQueue, resultsFromExecution):
	while True:
		executionTask = executionQueue.get()

		executionDetails = executionTask.getDetails()
		dictionaryWithScenarioDetails = executionTask.getConfig()

		logger.debug('Openning session to %s, with %s user', enmUrl, enmUser)
		try:
			session = enmscripting.open(enmUrl,enmUser,enmPass)
		except:
			logger.error("Session was not open on [%s].", enmUrl)
			executionQueue.task_done()
			break;
		executionTime=time.strftime("%d/%b/%Y %H:%M:%S")

		config = executionDetails.split(DELIMITER)
		nodeName=config[0]
		nodeIp=config[1]
		scenario=config[2].replace("\n","")
		steps=scenario.split(",")

		useCaseResultList = []

		scenarioName=""
		for scenarioStep in steps:
			try:
				if not scenarioName:
					scenarioName+=scenarioStep
				else:
					scenarioName+=" + " + scenarioStep
				logger.info('Working on %s', scenarioStep)
				useCaseResults = executeUseCase(session, scenarioStep, nodeName, nodeIp, executionTime, dictionaryWithScenarioDetails)
				useCaseResultList.append(useCaseResults)
			except support.TimeoutProblem,e:
				logger.error("Error: [%s].", str(e))
				break;
		enmscripting.close(session)

		result = support.ScenarioExecutionResults(executionTime, executionDetails, useCaseResultList, nodeName, current_thread().getName())

		resultsFromExecution.put(result)
		executionQueue.task_done()

		try:
			publishResults(scenarioName, result, nodeName, nodeIp, executionTime, useCaseResultList)
		except:
			e = sys.exc_info()
			logger.warn("Rest service is down [%s].", str(e))
示例#2
0
    def __exit__(self, exc_type, exc_val, exc_tb):
        """
        It tries to close the session after exiting the "with" statement.
        In case of failures, the proper exception is raised.

        Arguments:
            exc_type {[type]} -- [description]
            exc_val {[type]} -- [description]
            exc_tb {[type]} -- [description]
        """
        enmscripting.close(self._session)
        if exc_type:
            args = exc_val if isinstance(exc_val, tuple) else \
                 ((exc_val,) if isinstance(exc_val, str) else exc_val.args)
            raise (exc_type(*args), None, exc_tb)
示例#3
0
 def do_secadm(self, variable1):
     "ENM CLI secadm parancs te feregnovendek, Te sivatagi hollokutya teee"
     if variable1 and variable1 in self.cmedit_opt:
         command = 'secadm %s!' % variable1
     elif variable1:
         command = "secadm " + variable1
     else:
         command = 'hello baby'
     print(command)
     session = enmscripting.open('<ENM Launcher URL>').with_credentials(
         enmscripting.UsernameAndPassword('<user name>', '<password>'))
     terminal = session.terminal()
     response = terminal.execute(command)
     for line in response.get_output():
         print(line)
     enmscripting.close(session)
示例#4
0
 def do_cmedit(self, variable1):
     "ENM CLI cmedit parancs te pondro, ha ennyit se tudsz szopjal falovat"
     if variable1 and variable1 in self.cmedit_opt:
         command = 'cmedit %s!' % variable1
     elif variable1:
         command = "cmedit " + variable1
     else:
         command = 'hello baby'
     print(command)
     session = enmscripting.open('<ENM Launcher URL>').with_credentials(
         enmscripting.UsernameAndPassword('<user name>', '<password>'))
     terminal = session.terminal()
     response = terminal.execute(command)
     for line in response.get_output():
         print(line)
     enmscripting.close(session)
示例#5
0
 def do_MozoKedvence(self, variable1):
     "Elore definialt ENM CLI parancsok a'la cmedit"
     if variable1 and variable1 in self.cmedit_collection:
         command = '%s' % variable1
     elif variable1:
         command = variable1
     else:
         command = 'hello baby'
     print(command)
     command = command[0:0:] + command[3::]
     print(command)
     session = enmscripting.open('<ENM Launcher URL>').with_credentials(
         enmscripting.UsernameAndPassword('<user name>', '<password>'))
     terminal = session.terminal()
     response = terminal.execute(command)
     for line in response.get_output():
         print(line)
     enmscripting.close(session)
示例#6
0
文件: cfg.py 项目: vvsviridov/moenm
def exec_batch(filename):
    try:
        session = enmscripting.open()
        terminal = session.terminal()
        for full_cmd in read_file(filename):
            cmd_prefix = " ".join(full_cmd.split()[0:2])
            output = get_output(terminal, full_cmd)
            if "Error" not in " ".join(output).split():
                if re.match(r"[\w\s]+job\s+ID[\w\s]+", output[-1]) is not None:
                    jobid = output[-1].split()[-1]
                    wait_for_completed_status(terminal, jobid, cmd_prefix)
                cfg_str = "Command <%s> has been executed!" % full_cmd
                print_red(cfg_str)
    except Exception as e:
        print e
    finally:
        try:
            enmscripting.close(session)
        except Exception:
            print "Can't close session"
            #print(inputt)
            response = session.terminal().execute(inputt)
            print(response.get_output()) 

def idlemoderel(user_input):
    response = session.terminal().execute(user_input)
    for line in response.get_output():
        if "FDN" in line:
            user_input = 'cmedit set '+line.replace("FDN : ","")+' idleModePrioAtReleaseRef=""'
            #print(user_input)
            response = session.terminal().execute(user_input)
            print(response.get_output())

def idelmodedel(user_input2):
    response=session.terminal().execute(user_input2)
    for line in response.get_output():
        if "FDN" in line:
            user_input2='cmedit delete ' +line.replace("FDN : ","")
            #print(user_input2)
            response = session.terminal().execute(user_input2)
            print(response.get_output())
            

#idlemoderel('cmedit get '+str(coll_or_node)+' EUtranCellFDD.idleModePrioAtReleaseRef')
#idelmodedel('cmedit get '+str(coll_or_node)+' IdleModePrioAtRelease')
freq_del('cmedit get '+str(coll_or_node)+' EUtranFreqRelation='+str(channel))
freq_del('cmedit get '+str(coll_or_node)+' ExternalEUtranCell'+str(channel_type)+'.eutranFrequencyRef==*'+str(channel))
freq_del('cmedit get '+str(coll_or_node)+' EUtranFrequency='+str(channel))

enmscripting.close(session)