Commit 8b56606a authored by Remi Hardy's avatar Remi Hardy

fixes and improvements

parent 78f04b80
...@@ -76,18 +76,32 @@ class Module_UE: ...@@ -76,18 +76,32 @@ class Module_UE:
if len(result)!=0: if len(result)!=0:
logging.debug(self.Process['Name'] + " process found") logging.debug(self.Process['Name'] + " process found")
return True return True
else: else:#start process and check again
logging.debug(self.Process['Name'] + " process NOT found") logging.debug(self.Process['Name'] + " process NOT found")
#starting the process
logging.debug('Starting ' + self.Process['Name']) logging.debug('Starting ' + self.Process['Name'])
logging.debug(self.Process['Cmd']) mySSH = sshconnection.SSHConnection()
ssh = subprocess.Popen(["ssh", "%s" % HOST, self.Process['Cmd']],shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE) mySSH.open(self.HostIPAddress, self.HostUsername, self.HostPassword)
return False mySSH.command('echo ' + self.HostPassword + ' | sudo -S ' + self.Process['Cmd'] + ' &','\$',5)
mySSH.close()
#checking the process
HOST=self.HostIPAddress
COMMAND="ps aux | grep " + self.Process['Name'] + " | grep -v grep "
logging.debug(COMMAND)
ssh = subprocess.Popen(["ssh", "%s" % HOST, COMMAND],shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
result = ssh.stdout.readlines()
if len(result)!=0:
logging.debug(self.Process['Name'] + " process found")
return True
else:
logging.debug(self.Process['Name'] + " process NOT found")
return False
#Generic command function, using function pointers dictionary #Generic command function, using function pointers dictionary
def Command(self,cmd): def Command(self,cmd):
mySSH = sshconnection.SSHConnection() mySSH = sshconnection.SSHConnection()
mySSH.open(self.HostIPAddress, self.HostUsername, self.HostPassword) mySSH.open(self.HostIPAddress, self.HostUsername, self.HostPassword)
mySSH.command('echo ' + self.HostPassword + ' | sudo -S python3 ' + self.cmd_dict[cmd] + ' ','\$',5) mySSH.command('echo ' + self.HostPassword + ' | sudo -S python3 ' + self.cmd_dict[cmd],'\$',5)
time.sleep(5) time.sleep(5)
logging.debug("Module "+ cmd) logging.debug("Module "+ cmd)
mySSH.close() mySSH.close()
...@@ -104,17 +118,20 @@ class Module_UE: ...@@ -104,17 +118,20 @@ class Module_UE:
ssh = subprocess.Popen(["ssh", "%s" % HOST, COMMAND],shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE) ssh = subprocess.Popen(["ssh", "%s" % HOST, COMMAND],shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
response = ssh.stdout.readlines() response = ssh.stdout.readlines()
tentative-=1 tentative-=1
sleep(10) time.sleep(10)
if (tentative==0) and (len(response)==0): if (tentative==0) and (len(response)==0):
logging.debug('\u001B[1;37;41m Module IP Address Not Found! Time expired \u001B[0m') logging.debug('\u001B[1;37;41m Module IP Address Not Found! Time expired \u001B[0m')
else #check response return -1
else: #check response
result = re.search('inet (?P<moduleipaddress>[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)', response[0].decode("utf-8") ) result = re.search('inet (?P<moduleipaddress>[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)', response[0].decode("utf-8") )
if result is not None: if result is not None:
if result.group('moduleipaddress') is not None: if result.group('moduleipaddress') is not None:
self.UEIPAddress = result.group('moduleipaddress') self.UEIPAddress = result.group('moduleipaddress')
logging.debug('\u001B[1mUE Module IP Address is ' + self.UEIPAddress + '\u001B[0m') logging.debug('\u001B[1mUE Module IP Address is ' + self.UEIPAddress + '\u001B[0m')
return 0
else: else:
logging.debug('\u001B[1;37;41m Module IP Address Not Found! \u001B[0m') logging.debug('\u001B[1;37;41m Module IP Address Not Found! \u001B[0m')
return -1
......
...@@ -388,7 +388,6 @@ class OaiCiTest(): ...@@ -388,7 +388,6 @@ class OaiCiTest():
Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra[self.ue_id]) Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra[self.ue_id])
is_module=Module_UE.CheckCMProcess() is_module=Module_UE.CheckCMProcess()
if is_module: if is_module:
#Module_UE.WakeUp()
Module_UE.Command("wup") Module_UE.Command("wup")
Module_UE.GetModuleIPAddress() Module_UE.GetModuleIPAddress()
HTML.CreateHtmlTestRow(Module_UE.UEIPAddress, 'OK', CONST.ALL_PROCESSES_OK) HTML.CreateHtmlTestRow(Module_UE.UEIPAddress, 'OK', CONST.ALL_PROCESSES_OK)
...@@ -1040,7 +1039,7 @@ class OaiCiTest(): ...@@ -1040,7 +1039,7 @@ class OaiCiTest():
except: except:
os.kill(os.getppid(),signal.SIGUSR1) os.kill(os.getppid(),signal.SIGUSR1)
def DetachUE(self,HTML,RAN,EPC,COTS_UE): def DetachUE(self,HTML,RAN,EPC,COTS_UE,InfraUE):
if self.ue_id=='':#no ID specified, then it is a COTS controlled by ADB if self.ue_id=='':#no ID specified, then it is a COTS controlled by ADB
if self.ADBIPAddress == '' or self.ADBUserName == '' or self.ADBPassword == '': if self.ADBIPAddress == '' or self.ADBUserName == '' or self.ADBPassword == '':
HELP.GenericHelp(CONST.Version) HELP.GenericHelp(CONST.Version)
...@@ -1076,7 +1075,6 @@ class OaiCiTest(): ...@@ -1076,7 +1075,6 @@ class OaiCiTest():
Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra[self.ue_id]) Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra[self.ue_id])
is_module=Module_UE.CheckCMProcess() is_module=Module_UE.CheckCMProcess()
if is_module: if is_module:
#Module_UE.Detach()
Module_UE.Command("detach") Module_UE.Command("detach")
Module_UE.GetModuleIPAddress() Module_UE.GetModuleIPAddress()
HTML.CreateHtmlTestRow(Module_UE.UEIPAddress, 'OK', CONST.ALL_PROCESSES_OK) HTML.CreateHtmlTestRow(Module_UE.UEIPAddress, 'OK', CONST.ALL_PROCESSES_OK)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment