def get_remote_host(): cf = ConfigParser.ConfigParser() host_path = os.path.join(caliper_path.config_files.config_dir, 'hosts') cf.read(host_path) sections = cf.sections() opts = cf.options(sections[0])[0].split(' ') client_ip = opts[0] user_list = cf.get(sections[0], cf.options(sections[0])[0]) user = user_list.split(' ')[0] port = 22 password = user_list.split('"')[-2] remote_host = host_factory.create_host(client_ip, user, password, port) return remote_host
def get_BMC_host(self): try: bmc_ip = settings.get_value('BMCER', 'host', type=str) port = settings.get_value('BMCER', 'port', type=int) user = settings.get_value('BMCER', 'user', type=str) passwd = settings.get_value('BMCER', 'password', type=str) command = settings.get_value('BMCER', 'command', type=str) except Exception as e: raise error.ServRunError(e.args[0], e.args[1]) else: self.command = command try: bmc_host = host_factory.create_host(bmc_ip, user, passwd, port) except Exception as e: raise error.ServRunError(e.args[0], e.args[1]) else: self.host = bmc_host
elif tool in exec_par_tools: exec_info = exec_partial_info % tool else: if tool in build_fail_tools: exec_info = "" else: exec_info = exec_fail_info % tool write_file(filename, build_info) write_file(filename, exec_info) def output_summary_info(config_json, summary_file, interval): if os.path.exists(summary_file): os.remove(summary_file) try: fp = open(config_json, 'r') hardware_info = yaml.load(fp) except: hardware_info = {} write_yaml_file(hardware_info, summary_file) used_time = "Total used time: %.4s minutes" % (interval/60.0) write_file(summary_file, used_time) write_summary_tools(summary_file) write_info_for_tools(summary_file) if __name__ == "__main__": start_time = datetime.datetime.now() target = host_factory.create_host('localhost', 'wuyanjun', '', 22) end_time = datetime.datetime.now() output_summary_info(target, (end_time-start_time).seconds)
except Exception, e: client_ip = '127.0.0.1' try: port = settings.get_value('TARGET', 'port', type=int) except Exception, e: port = 22 try: user = settings.get_value('TARGET', 'user', type=str) except Exception, e: user = os.getlogin() try: password = settings.get_value('TARGET', 'password', type=str) except Exception, e: raise error.ServRunError(e.args[0], e.args[1]) remote_host = host_factory.create_host(client_ip, user, password, port) return remote_host def network_populate(dic, contents): bogo = 0 for blocks in contents: if blocks != '': if re.search(r'(\d+)[.]([\w /]+)', blocks): group = re.search(r'(\d+)[.]([\w /]+)', blocks) if group.group(2).strip() == "lspci": lspci_list.sort() key_lists = dic['Hardware_Info']['NETWORK'].keys() key_lists.sort() pci_info = [] for i in range(0, (len(key_lists))):
elif tool in exec_par_tools: exec_info = exec_partial_info % tool else: if tool in build_fail_tools: exec_info = "" else: exec_info = exec_fail_info % tool write_file(filename, build_info) write_file(filename, exec_info) def output_summary_info(target, interval): summary_file = caliper_path.folder_ope.summary_file if os.path.exists(summary_file): os.remove(summary_file) hardware_info = server_utils.get_host_hardware_info(target) write_yaml_file(hardware_info, summary_file) used_time = "Total used time: %.4s minutes" % (interval/60.0) write_file(summary_file, used_time) write_summary_tools(summary_file, target) write_info_for_tools(summary_file, target) if __name__ == "__main__": start_time = datetime.datetime.now() target = host_factory.create_host('localhost', 'wuyanjun', '', 22) end_time = datetime.datetime.now() output_summary_info(target, (end_time-start_time).seconds)
# Author : wuyanjun 00291783 # E-mail : [email protected] # Date : 15/01/07 10:15:34 # Desc : # try: import autotest.common as common except ImportError: import common #import caliper from caliper.server.hosts import host_factory if __name__ == "__main__": server = host_factory.create_host("10.175.102.38", "wuyanjun", "open275249A*", 22) file_name = '/home/disk/hisi/wuyanjun/123.txt' status = server.run("touch '%s'" % file_name) status = server.run('echo 123456 > /home/disk/hisi/wuyanjun/123.txt') if not status.exit_status: #server.disable_ipfilters() print "1234" file_name = '/home/disk/hisi/wuyanjun/caliper' status = server.send_file("/home/wuyanjun/caliper/client", file_name) #if not status.exit_status: # #server.disable_ipfilters() # print "5678" file_name = '/home/disk/hisi/wuyanjun/123.txt' status = server.get_file(file_name, "/home/wuyanjun") #if not status.exit_status:
except Exception, e: client_ip = '127.0.0.1' try: port = settings.get_value('CLIENT', 'port', type=int) except Exception, e: port = 22 try: user = settings.get_value('CLIENT', 'user', type=str) except Exception, e: user = os.getlogin() try: password = settings.get_value('CLIENT', 'password', type=str) except Exception, e: raise error.ServRunError(e.args[0], e.args[1]) remote_host = host_factory.create_host(client_ip, user, password, port) return remote_host def network_populate(dic,contents): bogo = 0 for blocks in contents: if blocks != '': if re.search(r'(\d+)[.]([\w /]+)', blocks): group = re.search(r'(\d+)[.]([\w /]+)', blocks) if group.group(2).strip() == "lspci": lspci_list.sort() key_lists = dic['Hardware_Info']['NETWORK'].keys() key_lists.sort() pci_info = [] for i in range(0,(len(key_lists))): pci_details = "*TBA"