def check_testability(made_ips, time_out=30): PORT = 22 USERNAME = "******" CHECK_TESTABILITY_COMMAND = "ps | grep lib" testability_count = 0 repeat = 0 while repeat < time_out: for ip in made_ips: time.sleep(3) ssh = _SSH_Shell() ssh.open(hostname=ip, port=PORT, username=USERNAME, password=None) stdout, stderr = ssh.command(CHECK_TESTABILITY_COMMAND) if "testability" in stdout: testability_count += 1 logger.info(f'{ip} testability readiness status is True') else: logger.info(f'{ip} testability readiness status is False') ssh.close() if testability_count == len(made_ips): logger.info('Testability is ready!') return else: logger.info('Testability not ready!') testability_count = 0 repeat += 1 raise DUTNotReadyException
def cpri_check(time_out=30): logger = logging.getLogger("main") CHECK_CPRI_SYNC_COMMAND = "/sbin/devmem 0x80301004" BEAMER_IP = "192.168.101.1" PORT = 22 USER_NAME = "toor4nsn" PASSWORD = "******" ssh = _SSH_Shell() ssh.open(hostname=BEAMER_IP, port=PORT, username=USER_NAME, password=PASSWORD) repeat = 0 while repeat < time_out: stdin, stdout, stderr = ssh.write(CHECK_CPRI_SYNC_COMMAND) logger.info("send command => " + CHECK_CPRI_SYNC_COMMAND) for line in stdout: line = line.strip() logger.info("get output => " + line) if line == "0x00000010": logger.info("CPRI LINK sync successfully!") ssh.close() return else: logger.info("CPRI LINK sync fail!") repeat += 1 time.sleep(5) ssh.close() raise CpriSyncFailException
def check_uoam(time_out=30): BEAMER_IP = '192.168.101.1' PORT = 22 USERNAME = "******" PASSWORD = "******" CHECK_UOAM_COMMAND = "ps | grep lib" repeat = 0 ssh = _SSH_Shell() ssh.open(hostname=BEAMER_IP, port=PORT, username=USERNAME, password=PASSWORD) while repeat < time_out: time.sleep(3) stdout, stderr = ssh.command(CHECK_UOAM_COMMAND) # print(stdout) # for line in stdout.split('\n'): # logging.info(line) if "uoamapp" in stdout: logger.info('uoam readiness status is true') ssh.close() return True else: logger.info('uoam readiness status is false') repeat += 1 ssh.close() raise DUTNotReadyException
def check_testability(self): port = 22 username = "******" command = "ps | grep lib" testability = False testability_count = 0 repeat = 0 while repeat < 30: for dut_ip in self.dut_ips: time.sleep(3) ssh = _SSH_Shell() ssh.open(hostname=dut_ip, port=port, username=username, password=None) stdout, stderr = ssh.command(command) # print(stdout) # logging.info('get output =>') # for line in stdout.split('\n'): # logging.info(line) testability = "testability" in stdout if testability: testability_count += 1 self.logger.info(f'{dut_ip} testability readiness status is ' + str(testability)) ssh.close() if testability_count == len(self.dut_ips): self.logger.info('Testability is ready!') return True else: self.logger.info('Testability not ready!') testability_count = 0 repeat += 1 return False
def _product_key_check(self): ssh = _SSH_Shell() ssh.open(self.beamer_ip, 22, username='******', password='******') stdout = ssh.command( "cd /mnt/factory/configs/unit && cat module_product_code.txt") product_code = stdout[0].strip().split('.')[0] self.logger.info("get product code => " + product_code) print("get product code => " + product_code) ssh.close() product_code_pairs = { 'AEQZ': "475444A", 'AENB': "475728A", 'AEQE': "474750A", 'AEQY': "475538A", 'AEQB': "474413A", 'AEQC': "475431A" } if product_code == product_code_pairs[self.product_type]: return True else: self.logger.error("product code NOT match!") print("product code NOT match!") raise ProductKeyNotMatchException
def check_uoam(self): port = 22 username = "******" password = "******" command = "ps | grep lib" uoam_readiness = False repeat = 0 ssh = _SSH_Shell() ssh.open(hostname=self.beamer_ip, port=port, username=username, password=password) while repeat < 6: time.sleep(3) stdout, stderr = ssh.command(command) # print(stdout) # for line in stdout.split('\n'): # logging.info(line) uoam_readiness = "uoamapp" in stdout self.logger.info('uoam readiness status is ' + str(uoam_readiness)) if uoam_readiness: ssh.close() return True repeat += 1 ssh.close() return False
def get_made_power(self, power, made_ip): """power = {**power, **power_line}""" power_line = {} now = datetime.datetime.now() power_line['time'] = now power_line['MADE'] = made_ip port = 22 username = "******" command = "dapd -sq" ssh = _SSH_Shell() ssh.open(hostname=made_ip, port=port, username=username, password=None) stdout, stderr = ssh.command(command) self.logger.info(f"send command to {made_ip}=> {command}") for line in stdout.split('\n'): self.logger.info(line) if line.strip().startswith('DPD IN:'): dpdin_values = [ float(value) for value in line.split() if value != 'DPD' and value != 'IN:' and '(' not in value and ')' not in value ] if line.strip().startswith('DPD OUT:'): dpdout_values = [ float(value) for value in line.split() if value != 'DPD' and value != 'OUT:' and '(' not in value and ')' not in value ] if line.strip().startswith('FB:'): fb_values = [ float(value) for value in line.split() if value != 'FB:' and '(' not in value and ')' not in value ] for pipe_num in range(len(dpdin_values)): power_line['DPDIN_' + str(pipe_num)] = dpdin_values[pipe_num] if not (-11.3 - self.limit['dpdin'] <= dpdin_values[pipe_num] <= -11.3 + self.limit['dpdin']): self.logger.error("dpdin value out of limit") self.fail_flag = True for pipe_num in range(len(dpdout_values)): power_line['DPDOUT_' + str[pipe_num]] = dpdout_values[pipe_num] if not (-11.3 - self.limit['dpdout'] <= dpdout_values[pipe_num] <= -11.3 + self.limit['dpdout']): self.logger.error("dpdout value out of limit") self.fail_flag = True for pipe_num in range(len(fb_values)): power_line['FB_' + str[pipe_num]] = fb_values[pipe_num] if not (-11.3 - self.limit['fb'] <= dpdout_values[pipe_num] <= -11.3 + self.limit['fb']): self.logger.error("fbt value out of limit") self.fail_flag = True self.lock.aquire() power = {**power, **power_line} self.lock.release()
def check_product_key(product_type, product_code_pairs=None): if product_code_pairs is None: product_code_pairs = {'AEQZ': "475444A", 'AENB': "475728A", 'AEQE': "474750A", 'AEQY': "475538A", 'AEQC': "475431A"} BEAMER_IP = "192.168.101.1" USER_NAME = "toor4nsn" PASSWORD = "******" CHECK_PRODUCT_CODE_COMMAND = "cd /mnt/factory/configs/unit && cat module_product_code.txt" ssh = _SSH_Shell() ssh.open(BEAMER_IP, 22, username=USER_NAME, password=PASSWORD) stdout = ssh.command(CHECK_PRODUCT_CODE_COMMAND) product_code = stdout[0].strip().split('.')[0] logger.info("get product code => " + product_code) ssh.close() if not product_code == product_code_pairs[product_type]: logger.error("product code NOT match!") raise ProductKeyNotMatchException
def Cpri_test(self, REPEAT=30): command = "/sbin/devmem 0x80301004" ssh = _SSH_Shell() ssh.open(hostname=self.host, port=self.port, username=self.username, password=self.password) test_pass = False for i in range(REPEAT): stdin, stdout, stderr = ssh.write(command) self.logger.info("send command => " + command) for line in stdout: line = line.strip() self.logger.info("get output => " + line) if line == "0x00000010": self.logger.info("CPRI LINK sync successully!") ssh.close() return True else: self.logger.info("CPRI LINK sync fail!") time.sleep(5) ssh.close() return False
def DPDIN_test_singleIP(self, host, res, repeat, row, col): col_origin = col count = 0 port = 22 username = "******" command = "dapd -sq" ssh = _SSH_Shell() ssh.open(hostname=host, port=port, username=username, password=None) while count < repeat: stdout, stderr = ssh.command(command) self.logger.info(f"sendind command to {host}=> {command}") for line in stdout.split('\n'): self.logger.info(line) if line.strip().startswith('DPD IN:'): dpdin_values = [float(value) for value in line.split() if value != 'DPD' and value != 'IN:' and '(' not in value and ')' not in value] if line.strip().startswith('DPD OUT:'): dpdout_values = [float(value) for value in line.split() if value != 'DPD' and value != 'OUT:' and '(' not in value and ')' not in value] if line.strip().startswith('FB:'): fb_values = [float(value) for value in line.split() if value != 'FB:' and '(' not in value and ')' not in value] try: print("res", dpdin_values) self.logger.info(f"get DPDIN values from {host}=> " + str(dpdin_values)) self.logger.info(f"get DPDOUT values from {host}=> " + str(dpdout_values)) self.logger.info(f"get FB values from {host}=> " + str(fb_values)) self.ws.cell(row=row, column=col, value=time.strftime("%Y%m%d%H%M%S")) col += 1 self.ws.cell(row=row, column=col, value=host) col += 1 # write dpdin values dpdin_pass_flag = True for value in dpdin_values: _ = self.ws.cell(row=row, column=col, value=value) col += 1 if not (-11.3 - self.limit['dpdin'] <= value <= -11.3 + self.limit['dpdin']): # print("value ot of limit!") _.font = Font(color='00FF0000') dpdin_pass_flag = False self.fail_flag = True if not dpdin_pass_flag: self.logger.info("DPDIN Value out of limit!") res[host]["DPDIN Value out of limit"] += 1 # write dpdout values dpdout_pass_flag = True for value in dpdout_values: _ = self.ws.cell(row=row, column=col, value=value) col += 1 if not (-14.3 - self.limit['dpdout'] <= value <= -14.3 + self.limit['dpdout']): # print("value ot of limit!") _.font = Font(color='00FF0000') dpdin_pass_flag = False self.fail_flag = True if not dpdout_pass_flag: self.logger.info("DPDOUT Value out of limit!") res[host]["DPDOUT Value out of limit"] += 1 # write fb values fb_pass_flag = True for value in fb_values: _ = self.ws.cell(row=row, column=col, value=value) col += 1 if not (-11.3 - self.limit['fb'] <= value <= -11.3 + self.limit['fb']): # print("value ot of limit!") _.font = Font(color='00FF0000') fb_pass_flag = False self.fail_flag = True if not fb_pass_flag: self.logger.info("FB Value out of limit!") res[host]["FB Value out of limit"] += 1 if dpdin_pass_flag and fb_pass_flag: res[host]["Pass times"] += 1 except UnboundLocalError: # print("No dpdin value detected!") self.logger.error("No dpdin value detected!") res[host]["No value detected"] += 1 self.fail_flag = True row += 1 col = col_origin count += 1 res[host]["read counts"] += 1 time.sleep(1) ssh.close()