예제 #1
0
    def __init__(self, server=None, username=None, password=None):
        """
        It requires the connection arguments.

        Keyword Arguments:
            server {[str]} -- server url name (default: {None})
            username {[str]} -- username (default: {None})
            password {[str]} -- password (default: {None})
        """
        self._session = enmscripting.open(server, username, password)
        self._terminal = self._session.terminal()
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))
예제 #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"
#Author - Sumanth Govind ([email protected])
#DO NOT EDIT THIS FILE

import enmscripting
from getpass import getpass
import sys

user_name = input('ENM User Name: ')
user_password = getpass('ENM User Password: '******'https://syl9launcher.syl9enm1.mgmt/').with_credentials(enmscripting.UsernameAndPassword(str(user_name),str(user_password)))
except (NameError,ValueError):
    sys.exit("Invalid Login/Connectivity to ENM failed")
channel = input("Enter Frequency to be deleted: ")
#channel_type = input("Is the above channel FDD or TDD: ").upper()
if int(channel)<10000:
    channel_type ='FDD'
else:
    channel_type='TDD'

coll_or_node = input("Enter Collection name or Node name: ")

#coll_or_node='TPA'

def freq_del(inputt):
    response = session.terminal().execute(inputt)
    for line in response.get_output():
        if "FDN" in line:
            inputt='cmedit delete ' +line.replace("FDN : ","")+ ' -ALL'
            #print(inputt)
예제 #8
0
enm_pass = '******'

#################
# Logging
#################

logging.basicConfig(level=logging.INFO,
                    format='%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
                    datefmt='%a, %d %b %Y %H:%M:%S',
                    filename=log_dir + 'Delete_OSS_NodeCredential_' + str(time.strftime('%Y%m%d%H%M%S')) + '.log',
                    filemode='a')

logging.info('Program started!')

logging.info('establish ENM terminal session:')
session = enmscripting.open(enm_url, enm_user, enm_pass)
terminal = session.terminal()
logging.info('ENM terminal session established!')


#################
# FUNCTIONS
#################


# get current NodeCredentialId
def getEnmNodeCredId(node_name):
    _NodeCredentialId = 0  # type: int
    _ossNodeCredentialId = 0
    _enmNodeCredentialId = 0
    isEnmCredential = False
예제 #9
0
#Simple python script to execute ENM CLI commands in script server by toja
#This script uses the ENM CLI api: enmscriptiong

import enmscripting
import sys

session = enmscripting.open('<ENM Launcher URL>').with_credentials(
    enmscripting.UsernameAndPassword('<user name>', '<password>'))
print '*********** Delete ENM Radionode by TOJA **************'

command = 'cmedit set NetworkElement=%s,PmFunction=1 pmEnabled=false' % (
    sys.argv[1])
terminal = session.terminal()
response = terminal.execute(command)
for line in response.get_output():
    print(line)

command = 'cmedit set NetworkElement=%s,InventorySupervision=1 active=false' % (
    sys.argv[1])
response = terminal.execute(command)
for line in response.get_output():
    print(line)

command = 'cmedit set NetworkElement=%s,CmNodeHeartbeatSupervision=1 active=false' % (
    sys.argv[1])
response = terminal.execute(command)
for line in response.get_output():
    print(line)

command = 'alarm disable %s' % (sys.argv[1])
response = terminal.execute(command)