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

fixes and improvements

parent 78f04b80
......@@ -76,18 +76,32 @@ class Module_UE:
if len(result)!=0:
logging.debug(self.Process['Name'] + " process found")
return True
else:
else:#start process and check again
logging.debug(self.Process['Name'] + " process NOT found")
#starting the process
logging.debug('Starting ' + self.Process['Name'])
logging.debug(self.Process['Cmd'])
ssh = subprocess.Popen(["ssh", "%s" % HOST, self.Process['Cmd']],shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
return False
mySSH = sshconnection.SSHConnection()
mySSH.open(self.HostIPAddress, self.HostUsername, self.HostPassword)
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
def Command(self,cmd):
mySSH = sshconnection.SSHConnection()
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)
logging.debug("Module "+ cmd)
mySSH.close()
......@@ -104,17 +118,20 @@ class Module_UE:
ssh = subprocess.Popen(["ssh", "%s" % HOST, COMMAND],shell=False,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
response = ssh.stdout.readlines()
tentative-=1
sleep(10)
time.sleep(10)
if (tentative==0) and (len(response)==0):
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") )
if result is not None:
if result.group('moduleipaddress') is not None:
self.UEIPAddress = result.group('moduleipaddress')
logging.debug('\u001B[1mUE Module IP Address is ' + self.UEIPAddress + '\u001B[0m')
return 0
else:
logging.debug('\u001B[1;37;41m Module IP Address Not Found! \u001B[0m')
return -1
......
......@@ -388,7 +388,6 @@ class OaiCiTest():
Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra[self.ue_id])
is_module=Module_UE.CheckCMProcess()
if is_module:
#Module_UE.WakeUp()
Module_UE.Command("wup")
Module_UE.GetModuleIPAddress()
HTML.CreateHtmlTestRow(Module_UE.UEIPAddress, 'OK', CONST.ALL_PROCESSES_OK)
......@@ -1040,7 +1039,7 @@ class OaiCiTest():
except:
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.ADBIPAddress == '' or self.ADBUserName == '' or self.ADBPassword == '':
HELP.GenericHelp(CONST.Version)
......@@ -1076,7 +1075,6 @@ class OaiCiTest():
Module_UE = cls_module_ue.Module_UE(InfraUE.ci_ue_infra[self.ue_id])
is_module=Module_UE.CheckCMProcess()
if is_module:
#Module_UE.Detach()
Module_UE.Command("detach")
Module_UE.GetModuleIPAddress()
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