Commit 7bf4f8da authored by hardy's avatar hardy

tentative to improve Module control encapsulation

parent 8def7528
...@@ -56,7 +56,8 @@ class Module_UE: ...@@ -56,7 +56,8 @@ class Module_UE:
for k, v in Module.items(): for k, v in Module.items():
setattr(self, k, v) setattr(self, k, v)
self.UEIPAddress = "" self.UEIPAddress = ""
#dictionary linking command names and related module scripts
self.cmd_dict= {"wup": self.WakeupScript,"detach":self.DetachScript}#dictionary of function scripts
...@@ -80,23 +81,33 @@ class Module_UE: ...@@ -80,23 +81,33 @@ class Module_UE:
#Wakeup/Detach can probably be improved with encapsulation of the command such def Command(self, command) #Wakeup/Detach can probably be improved with encapsulation of the command such def Command(self, command)
#this method wakes up the module by calling the specified python script #this method wakes up the module by calling the specified python script
def WakeUp(self): # def WakeUp(self):
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.WakeupScript + ' ','\$',5) # mySSH.command('echo ' + self.HostPassword + ' | sudo -S python3 ' + self.WakeupScript + ' ','\$',5)
time.sleep(5) # time.sleep(5)
logging.debug("Module wake-up") # logging.debug("Module wake-up")
mySSH.close() # mySSH.close()
#this method detaches the module by calling the specified python script #this method detaches the module by calling the specified python script
def Detach(self): # def Detach(self):
# mySSH = sshconnection.SSHConnection()
# mySSH.open(self.HostIPAddress, self.HostUsername, self.HostPassword)
# mySSH.command('echo ' + self.HostPassword + ' | sudo -S python3 ' + self.DetachScript + ' ','\$',5)
# time.sleep(5)
# logging.debug("Module detach")
# mySSH.close()
#tentative: generic command function
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.DetachScript + ' ','\$',5) mySSH.command('echo ' + self.HostPassword + ' | sudo -S python3 ' + self.cmd_dict[cmd] + ' ','\$',5)
time.sleep(5) time.sleep(5)
logging.debug("Module detach") logging.debug("Module "+ cmd)
mySSH.close() mySSH.close()
#this method retrieves the Module IP address (not the Host IP address) #this method retrieves the Module IP address (not the Host IP address)
def GetModuleIPAddress(self): def GetModuleIPAddress(self):
HOST=self.HostIPAddress HOST=self.HostIPAddress
......
...@@ -388,7 +388,8 @@ class OaiCiTest(): ...@@ -388,7 +388,8 @@ 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.CheckIsModule() is_module=Module_UE.CheckIsModule()
if is_module: if is_module:
Module_UE.WakeUp() #Module_UE.WakeUp()
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)
self.UEIPAddresses.append(Module_UE.UEIPAddress) self.UEIPAddresses.append(Module_UE.UEIPAddress)
...@@ -1075,7 +1076,8 @@ class OaiCiTest(): ...@@ -1075,7 +1076,8 @@ 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.CheckIsModule() is_module=Module_UE.CheckIsModule()
if is_module: if is_module:
Module_UE.Detach() #Module_UE.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