def PingStatus(self, IpAddress): """ #------------------------------------------------------------------------------------------------------------------- # Name: PingStatus # Input: IpAddress # Description:Pings the machine (with IpAddress provided as an argument) # Return: StatusResult() object #------------------------------------------------------------------------------------------------------------------- """ result = CommandLine.RunCommand('ping ' + IpAddress, 30) if result.Status.HasError(): logger.error("Error in pinging host {0} . {1}".format( IpAddress, result.CmdResult.Output)) return StatusResult.Error("Error in pinging host {0} . {1}".format( IpAddress, result.CmdResult.Output)) logger.info(result.CmdResult.Output) if ('unreachable.' in result.CmdResult.Output): #No route from the local system. Packets sent were never put on the wire. return StatusResult.Error('IpAddress is unreacheable. ' + result.CmdResult.Output) elif ('Ping request could not find host' in result.CmdResult.Output): return StatusResult.Error('host_not_found. ' + result.CmdResult.Output) elif ('Request timed out.' in result.CmdResult.Output): return StatusResult.Error('Connection time out' + result.CmdResult.Output) return StatusResult.Success()
def SendCommandAndGetResponse(self, methodStrings, timeout=120): """ #------------------------------------------------------------------------------------------------------------------- # Name: SendCommandAndGetResponse # Input: Takes argument: # methodStrings: methods name followed by their parameters. # For example : -m methodName-param1,param2 # Description: check If it is Qualcomm Root Build # Return: StatusResult() object #------------------------------------------------------------------------------------------------------------------- """ cptfInterfaceExecutable = CommonApplicationUtilities._ResourcesProgramPath + "CPTF_LibraryInterface\\Qualcomm.CPTF.LibraryInterface.exe" dllPath = CommonApplicationUtilities._ResourcesProgramPath + "CPTF_LibraryInterface\\Qualcomm.CPT.Automation.Plugins.HW.Kratos.dll" className = 'Qualcomm.CPT.Automation.Plugins.HW.Kratos.KratosRecovery' executionString = cptfInterfaceExecutable + " -a " + dllPath + " -c " + className + methodStrings logger.debug("Executing Command :" + executionString) result = CommandLine.RunCommand(executionString, timeout) return result
def StopClientIperf(): """ #------------------------------------------------------------------------------------------------------------------- # Name: StopClientIperf # Input: Takes no arguments # Description: Function used to Stop iPerf Client # Return: StatusResult result #------------------------------------------------------------------------------------------------------------------- """ logger.info("Calling StopClientIperf function") logger.info("TBS: Stopping Iperf Client") command = TbsIPerfActions.plinkstr + "pkill miperf" logger.info("TBS: " + str(command)) result = CommandLine.RunCommand(command, 10) if result.Status.HasError(): logger.error("Unable to kill miperf") return StatusResult.Error("Unable to kill miperf") logger.info("StopClientIperf function worked fine") return StatusResult.Success()
def GetUeIpAddress(): """ #------------------------------------------------------------------------------------------------------------------- # Name: GetUeIpAddress # Input: Takes no arguments # Description: Function used to get UE IP Address # Return: UE IP Address #------------------------------------------------------------------------------------------------------------------- """ logger.info("Calling GetUeIpAddress function") logger.info("TBS: Detecting MME State") str1 = "/opt/lte/bin/appTestability.py -s localhost -p 15004 \\\"MME COMMAND GET MME_QUERY_STATE\\\"" command = TbsTestabilityActions.plinkstr + "\"" + str1 + "\"" logger.debug("Command is: " + str(command)) result = CommandLine.RunCommand(command, 15) matched = 0 OutputLines = str(result.CmdResult.OutputLines) OutputLines = OutputLines.split("\\n") logger.info("OutputLines: " + str(OutputLines) + "\n") for line in OutputLines: #logger.debug("Line contains: " + str(line)) if matched == 1: if "IPV4_ADDRESS" in line: match = re.search(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', line).group() if "10.1.1" in match: ipAddress = match logger.info("TBS: UE IP Address: " + str(ipAddress)) return ipAddress if ipAddress == "": logger.error("Failed to detect UE IP Address") return None else: match = re.search(r"\"IP_TYPE\" : \"IPV4\",", line) if match != None: matched = 1 logger.debug("Line contains: " + str(line))
def SendCommandAndGetResponse(self, methodStrings, timeout=120): """ #------------------------------------------------------------------------------------------------------------------- # Name: SendCommandAndGetResponse # Input: Takes argument : # methodStrings: methods name followed by their parameters. # For example : -m methodName-param1,param2 # Description: check If it is Qualcomm Root Build # Return: StatusResult() object #------------------------------------------------------------------------------------------------------------------- """ #cptfInterfaceExecutable = 'C:\\Automation\\PTAS_Engine\\CPTF_Lib_Interface\\CPTF_LibraryInterface.exe' cptfInterfaceExecutable = CommonApplicationUtilities._ResourcesProgramPath + "CPTF_LibraryInterface\\Qualcomm.CPTF.LibraryInterface.exe" dllPath = CommonApplicationUtilities._ResourcesProgramPath + "CPTF_LibraryInterface\\Qualcomm.CPT.Automation.Plugins.HW.Kratos.dll" className = 'Qualcomm.CPT.Automation.Plugins.HW.Kratos.KratosApi' executionString = cptfInterfaceExecutable + " -a " + dllPath + " -c " + className + " -m SetupKratos-" + self.kratosPcIpAddress + " " + methodStrings logger.debug("Executing Command :" + executionString) result = CommandLine.RunCommand(executionString, timeout) if result.Status.HasError() or 'Error' in result.CmdResult.Output: logger.error(result.CmdResult.Output) result.Status.AddError(result.CmdResult.Output) return result
def SendCommandAndGetResponse(self, methodStrings, timeout=30): """ #------------------------------------------------------------------------------------------------------------------- # Name: SendCommandAndGetResponse # Input: Takes 2 arguments # methodStrings: method names followed by their parameters # timeout: default value is 30 seconds # Description: Sends execution command to TEC dll # Return: StatusResult() object #------------------------------------------------------------------------------------------------------------------- """ cptfInterfaceExecutable = CommonApplicationUtilities._ResourcesProgramPath + "CPTF_LibraryInterface\\Qualcomm.CPTF.LibraryInterface.exe" dllPath = CommonApplicationUtilities._ResourcesProgramPath + "CPTF_LibraryInterface\\Qualcomm.CPT.Automation.TEC.dll" className = 'Qualcomm.CPT.Automation.TEC.ThermalController' executionString = cptfInterfaceExecutable + " -a " + dllPath + " -c " + className + " " + " -s " + " " + methodStrings logger.debug("Executing Command :" + executionString) result = CommandLine.RunCommand(executionString, timeout) logger.debug("Result contains: " + result.CmdResult.Output) if result.Status.HasError(): logger.error(result.CmdResult.Output) result.Status.AddError(result.CmdResult.Output) return result