def test_get_set_arb_feature(self): # Test get and set arbitration feature. nvme_list = self.get_nvme_disks() ssh = sshclient.SSH("127.0.0.1", "root", "root", port=2222) assert ssh.wait_for_host_up() is True # select [0-3]: current/default/saved/supported sel = 0 # feature id 1: arbitration feature_id = 1 for dev in nvme_list: status, rsp_before_set = ssh.exec_command("nvme get-feature {} -f {} -s {}".format(dev, feature_id, sel)) print "Before set: ", rsp_before_set match_obj = re.search( r'^get-feature:0x(?P<feature_id>\d+) \(Arbitration\), Current value:\s?0x(?P<value>[0-9a-fA-F]+)', rsp_before_set) assert match_obj assert feature_id == int(match_obj.groupdict().get('feature_id'), 16) # Prepare set feature value exp_arb_after_set = int(match_obj.groupdict().get('value'), 16) + 1 # Set feature status, rsp_set = ssh.exec_command( "nvme set-feature {} -f {} -v {}".format(dev, feature_id, exp_arb_after_set)) assert status == 0 # Get feature again and verify status, rsp_after_set = ssh.exec_command("nvme get-feature {} -f {} -s {}".format(dev, feature_id, sel)) print "After set: ", rsp_after_set assert status == 0 match_obj = re.search(r"Current value:\s?0x([0-9a-fA-F]+)", rsp_after_set) assert match_obj arb_after_set = int(match_obj.group(1), 16) assert exp_arb_after_set == arb_after_set
def test_get_set_temp_feature(self): # Test get and set temparature feature. nvme_list = self.get_nvme_disks() ssh = sshclient.SSH("127.0.0.1", "root", "root", port=2222) assert ssh.wait_for_host_up() is True # select [0-3]: current/default/saved/supported sel = 0 # feature id 4: temparature feature_id = 4 for dev in nvme_list: status, rsp_before_set = ssh.exec_command("nvme get-feature {} -f {} -s {}".format(dev, feature_id, sel)) print rsp_before_set match_obj = re.search( r'^get-feature:0x(?P<id>\d+) \(Temperature Threshold\), Current value:\s?0x(?P<value>[0-9a-fA-F]+)', rsp_before_set) assert match_obj assert feature_id == int(match_obj.groupdict().get('id'), 16) # Check keywords existance in command output # Prepare set temparature feature value exp_temp_after_set = int(match_obj.groupdict().get('value'), 16) + 1 # Set feature status, rsp_set = ssh.exec_command( "nvme set-feature {} -f {} -v {}".format(dev, feature_id, exp_temp_after_set)) # Get feature again and verify status, rsp_after_set = ssh.exec_command("nvme get-feature {} -f {} -s {}".format(dev, feature_id, sel)) temp_after_set = re.search(r"Current value:\s?0x([0-9a-fA-F]+)", rsp_after_set).group(1) assert exp_temp_after_set == int(temp_after_set, 16)
def test_smart_log(self): # To get MT devices list. nvme_model_list = [] ssh = sshclient.SSH("127.0.0.1", "root", "root", port=2222) assert ssh.wait_for_host_up() is True status, output = ssh.exec_command("nvme list |grep \"/dev\" |awk '{print $1,$3}'") nvme_model_list = output.split("\n")[:-1] mt_list = [] for item in nvme_model_list: if str(item.split(" ")[1]) == "MTC_8GB": mt_list.append(item.split(" ")[0].split("/")[2]) nvme_dev_list = self.get_nvme_dev() for nvme in nvme_dev_list: nsid_list = self.get_nvme_ns_list(nvme) for ns_id in nsid_list: status, output = ssh.exec_command("nvme smart-log /dev/{} -n {}".format(nvme, ns_id)) print output # FIXME: Once IN-1393 fixed, change critical_warnings to "0" to reflect NVMe drive is healthy. assert re.search(r"critical_warning\s+:\s+(0x\d|\d+)", output) assert re.search(r"temperature\s+:\s+(\d+)(\s+)C", output) assert re.search(r"available_spare\s+:\s+(\d+)%", output) assert re.search(r"available_spare_threshold\s+:\s+(\d+)%", output) # FIXME: For MT, there are two Temperature Sensors need to check, now this step is expected to FAIL. '''
def test_error_log(self): nvme_disk_list = self.get_nvme_disks() ssh = sshclient.SSH("127.0.0.1", "root", "root", port=2222) assert ssh.wait_for_host_up() is True for nvme in nvme_disk_list: status, output = ssh.exec_command("nvme error-log {}".format(nvme)) assert re.search("Error Log Entries for device:{} entries:(\d+)".format(nvme.split("/")[2]), output)
def test_step1_nvmedrive_remove(self): ssh = sshclient.SSH("127.0.0.1", "root", "root", port=2222) assert ssh.wait_for_host_up() is True s = UnixSocket(path) s.connect() s.recv() # 1.1: remove drive status, stdout = ssh.exec_command('nvme list') self.assertIn('0400001C6BB4', stdout, "Failed: didn't find dev-nvme-1") payload_enable_qmp = {"execute": "qmp_capabilities"} s.send(json.dumps(payload_enable_qmp)) s.recv() payload_drive_remove = { "execute": "human-monitor-command", "arguments": { "command-line": "device_del dev-nvme-1" } } s.send(json.dumps(payload_drive_remove)) s.close() # around 10s is necessary for refresh the device list time.sleep(10) status, stdout = ssh.exec_command('nvme list') self.assertNotIn('0400001C6BB4', stdout, "NVME drive remove failed")
def client_ssh(self, ns_ip): ssh = sshclient.SSH(host=ns_ip, username="******", password="******", port=8022) ssh.wait_for_host_up() return ssh
def test_nvmeerror_inject(self): ssh = sshclient.SSH(host="127.0.0.1", username="******", password="******", port=2222) ssh.wait_for_host_up() s = UnixSocket(path) s.connect() s.recv() payload_enable_qmp = {"execute": "qmp_capabilities"} s.send(json.dumps(payload_enable_qmp)) s.recv() payload_error_inject = { "execute": "nvme-status-code-error-inject", "arguments": { "count": 65536, "opcode": "rw", "id": "dev-nvme-0", "nsid": 1, "status_field": { "dnr": True, "more": True } } } payload_nvmeclear = { 'execute': 'nvme-status-code-error-inject', 'arguments': { 'count': 0, 'opcode': 'rw', 'id': 'dev-nvme-0', 'nsid': 0, 'status_field': { 'sc': 0, 'sct': 0, 'dnr': True, 'more': True } } } for cmd_error_inject in error_inject_list: payload_error_inject['arguments']['status_field'][ 'sc'] = cmd_error_inject[0] payload_error_inject['arguments']['status_field'][ 'sct'] = cmd_error_inject[1] s.send(json.dumps(payload_error_inject)) s.recv() status, output = ssh.exec_command( "nvme read /dev/nvme0n1 -z 3008 -a 128") self.assertNotIn("Success", output, "error of %s inject failed" % cmd_error_inject[2]) s.send(json.dumps(payload_nvmeclear)) s.recv() status, output = ssh.exec_command( "nvme read /dev/nvme0n1 -z 3008 -a 128") self.assertIn("Success", output, "clear error failed") s.close()
def start_node(): global conf global ssh global s global sg fake_config = fixtures.FakeConfig() conf = fake_config.get_node_info() conf["compute"]["guest-agent"] = True conf["compute"]["networks"] = [{ "device": "e1000", "id": "e1000.0", "mac": "00:60:16:9c:50:6a" }] conf["compute"]["networks"][0]["port_forward"] = [{ "outside": 2222, "inside": 22, "protocal": "tcp" }] conf["compute"]["storage_backend"] = [ { "type": "ahci", "max_drive_per_controller": 6, "drives": [{ "size": 8, "file": fixtures.image }] }, ] conf["compute"]["guest-agent"] = True node = model.CNode(conf) node.init() node.precheck() node.start() # first s : unixsocket .monitor path = os.path.join(node.workspace.get_workspace(), ".monitor") s = UnixSocket(path) s.connect() s.recv() payload_enable_qmp = {"execute": "qmp_capabilities"} s.send(json.dumps(payload_enable_qmp)) s.recv() # second sg: unixsocket guest.agt path_guestagt = os.path.join(node.workspace.get_workspace(), "guest.agt") sg = UnixSocket(path_guestagt) sg.connect() payload_test_ping = {"execute": "guest-ping"} sg.send(json.dumps(payload_test_ping)) # wait until system is ready for ssh. ssh = sshclient.SSH(host="127.0.0.1", username="******", password="******", port=2222) ssh.wait_for_host_up()
def get_nvme_dev(self): # Return nvme drive device, eg. ['nvme0', 'nvme1'] ssh = sshclient.SSH("127.0.0.1", "root", "root", port=2222) assert ssh.wait_for_host_up() is True nvme_dev_list = [] status, output = ssh.exec_command("ls /sys/class/nvme") nvme_dev_list = output.split() return nvme_dev_list
def get_nvme_disks(self): # Return nvme , eg. ['/dev/nvme0n1', '/dev/nvme0n2'] ssh = sshclient.SSH("127.0.0.1", "root", "root", port=2222) assert ssh.wait_for_host_up() is True nvme_list = [] status, output = ssh.exec_command("nvme list |grep \"/dev\" |awk '{print $1}'") nvme_list = [dev.strip(os.linesep) for dev in output.strip().split()] return nvme_list
def _clean_up(self): # Clean up temperary files ssh = sshclient.SSH("127.0.0.1", "root", "root", port=2222) assert ssh.wait_for_host_up() is True status, output = ssh.exec_command("ls /tmp/") print "OUTPUT: {}".format(output) status, output = ssh.exec_command("rm /tmp/*") print "STATUS: {}".format(status) return status
def get_nvme_ns_list(self, nvme): # Return name space id list, eg. ['1', '2'] ssh = sshclient.SSH("127.0.0.1", "root", "root", port=2222) assert ssh.wait_for_host_up() is True status, output = ssh.exec_command("ls /sys/class/nvme/{} |grep {}".format(nvme, nvme)) nsid_list = [] for ns in output.split(): id = re.search(r"nvme(\d+)n(\d+)", ns) nsid = id.group(2) nsid_list.append(nsid) return nsid_list
def test_get_ns_id(self): global conf nvme_list = self.get_nvme_disks() ssh = sshclient.SSH("127.0.0.1", "root", "root", port=2222) assert ssh.wait_for_host_up() is True for dev in nvme_list: status, rsp = ssh.exec_command("nvme get-ns-id {}".format(dev)) ns_id_get = rsp.split(":")[2] result = re.search(r"nvme(\d+)n(\d+)", dev) ns_id_read = result.group(2) assert int(ns_id_get) == int(ns_id_read)
def test_copy_file_across_drives(self): # ssh = helper.prepare_ssh() ssh = sshclient.SSH("127.0.0.1", "root", "root", port=2222) ssh.connect() assert ssh.wait_for_host_up() rc, output = ssh.exec_command('touch /root/source.bin') assert rc == 0 rc, output = ssh.exec_command( "echo 'Test message is found! :D' >> /root/source.bin") drive = self.get_drive(boot_drive_serial) for i in ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'): if 'sd' + i != drive: rc, output = ssh.exec_command( 'dd if=/root/source.bin of=/dev/sd' + i + ' bs=512 seek=0 count=1 conv=fsync') assert rc == 0 boot_drive = self.get_drive(boot_drive_serial) sas_drive = self.get_drive(sas_drive_serial) sata_drive = self.get_drive(sata_drive_serial) # ssh = helper.prepare_ssh() for i in ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'): if 'sd' + i not in [boot_drive, sas_drive, sata_drive]: rc, output = ssh.exec_command( 'dd if=/dev/sd' + i + ' of=/root/target_' + i + '.bin bs=512 skip=0 count=1 conv=fsync') assert rc == 0 # ssh = helper.prepare_ssh() for i in ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'): if 'sd' + i not in [boot_drive, sas_drive, sata_drive]: rc, output = ssh.exec_command('cat /root/target_' + i + '.bin') assert 'Test message is found! :D' in output rc, output = ssh.exec_command('rm /root/source.bin') assert rc == 0 boot_drive = self.get_drive(boot_drive_serial) sas_drive = self.get_drive(sas_drive_serial) sata_drive = self.get_drive(sata_drive_serial) for i in ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'): if 'sd' + i not in [boot_drive, sas_drive, sata_drive]: rc, output = ssh.exec_command('rm /root/target_' + i + '.bin') assert rc == 0 rc, output = ssh.exec_command('ls /root' + i + '/target_' + i + '.bin') assert rc != 0 time.sleep(2)
def start_node(): global conf nvme_config = fixtures.NvmeConfig() conf = nvme_config.get_node_info() node = model.CNode(conf) node.init() node.precheck() node.start() node.wait_node_up() helper.port_forward(node) global ssh ssh = sshclient.SSH("127.0.0.1", "root", "root", port=2222) assert ssh.wait_for_host_up() is True
def test_flush(self): # Test flush command, it commit data/metadata associated with the specified namespace to volatile media. nvme_ctrls = self.get_nvme_dev() ssh = sshclient.SSH("127.0.0.1", "root", "root", port=2222) assert ssh.wait_for_host_up() is True for nvme in nvme_ctrls: ns_list = self.get_nvme_ns_list(nvme) for ns in ns_list: status, output = ssh.exec_command("nvme flush /dev/{}n{} -n {}".format(nvme, ns, ns)) assert status == 0 print output # Check keywords existance in command output key_words = ["Flush:", "NVMe", "success"] assert set(key_words) <= set(output.split())
def test_get_log(self): global conf nvme_dev_list = self.get_nvme_dev() ssh = sshclient.SSH("127.0.0.1", "root", "root", port=2222) assert ssh.wait_for_host_up() is True # Now infrasim design only support log_id(1, 2, 3) log_id_max = 3 for nvme in nvme_dev_list: nsid_list = self.get_nvme_ns_list(nvme) for ns_id in nsid_list: for log_id in range(1, log_id_max + 1): status, rsp = ssh.exec_command( "nvme get-log /dev/{} -n {} -i {} -l 512".format(nvme, ns_id, log_id)) print rsp assert nvme, ns_id in rsp assert str(log_id) in rsp
def _create_gen_bin_script(self, bin_file_name, pattern, block=4): # Parameters: # script_name, eg. "/tmp/script_name.py" # pattern, eg. "0xff" # Return script path ssh = sshclient.SSH("127.0.0.1", "root", "root", port=2222) assert ssh.wait_for_host_up() is True script_name = "/tmp/gen_{}.py".format(str(pattern)) script_content = '''#!/usr/bin/env python import struct with open('{}', 'wb') as f: for i in range(512 * {}): f.write(struct.pack('=B',{})) '''.format(bin_file_name, block, pattern) status, output = ssh.exec_command("echo \"{}\" > {}".format(script_content, script_name)) return script_name
def test_drive_capacity_consistency(self): ssh = sshclient.SSH("127.0.0.1", "root", "root", port=2222) assert ssh.wait_for_host_up() is True s = UnixSocket(path) s.connect() s.recv() # 1. expect: yml img zise == host disk size cmd = "qemu-img info {}".format(drive_test_image) r = os.popen(cmd) img_info = r.read() r.close() self.assertIn( 'virtual size: 1.0G', img_info, "Existing host drive image \ size is different from the size defined in yaml" ) # 2. expect: yml img size == guest disk size status, stdout = ssh.exec_command('sg_readcap /dev/sdb') self.assertIn( 'Device size: 1073741760 bytes', stdout, "Guest drive image \ size is different from the size defined in yaml" ) last_lba = re.search("Last logical block address=([0-9]{0,7})", stdout).group(1) invalid_lba = int(last_lba) + 1 # 3. expect: report failed when access lba range out of 1G status, sg_info = ssh.exec_command("sg_map -i | grep sdb") assert re.search("ST4000NM0005", sg_info).group() sg_index = re.search("sg([0-9]{1,2})", sg_info).group(1) cmd = "sg_dd if=/dev/sg{0} bs=520 count=1 skip={1}".format( sg_index, last_lba) status, stdout = ssh.exec_command(cmd) self.assertNotIn('failed', stdout, 'Failed, read failed when lba is valid') cmd = "sg_dd if=/dev/sg{0} bs=520 count=1 skip={1}".format( sg_index, str(invalid_lba)) status, stdout = ssh.exec_command(cmd) self.assertIn('failed', stdout, 'Failed, read success when lba out of range') s.close
def test_compare(self): # Test compare command, compare success when disk data of specified range is identical # with the specified data file. nvme_list = self.get_nvme_disks() start_block = 0 data_size = 4096 block_count = 8 ssh = sshclient.SSH("127.0.0.1", "root", "root", port=2222) assert ssh.wait_for_host_up() is True pattern = 0xff bin_file_name = tempfile.mktemp(suffix=".bin", prefix="nvme-test-") script_name = self._create_gen_bin_script(bin_file_name, pattern, block_count) assert self._run_gen_bin_script(bin_file_name, script_name) == 0 for dev in nvme_list: status, output = ssh.exec_command( "nvme compare {} -z {} -s {} -c {} -d {}\n".format(dev, data_size, start_block, block_count, bin_file_name)) assert 0 != status print "compare OUTPUT: {}".format(output) cobj = re.search(r"[Cc]ompare:\s?COMPARE_FAILED\(\d+\)", output) assert cobj # assert "COMPARE_FAILED" in output status, output = ssh.exec_command( "nvme write {} -z {} -s {} -c {} -d {}\n".format(dev, data_size, start_block, block_count, bin_file_name)) assert 0 == status print "write OUTPUT: {}".format(output) cobj = re.search(r"[Ww]rite:\s?[Ss]uccess", output) assert cobj status, output = ssh.exec_command( "nvme compare {} -z {} -s {} -c {} -d {}\n".format(dev, data_size, start_block, block_count, bin_file_name)) assert 0 == status print "compare OUTPUT: {}".format(output) cobj = re.search(r"[Cc]ompare:\s?[Ss]uccess", output) assert cobj
def test_id_ctrl(self): global conf nvme_list = self.get_nvme_disks() ssh = sshclient.SSH("127.0.0.1", "root", "root", port=2222) assert ssh.wait_for_host_up() is True nvme_config_list = [] nvme_id_ctrl_list = [] # initialize nvme id-ctrl list for dev in nvme_list: status, ctrl_data = ssh.exec_command("nvme id-ctrl {}".format(dev)) li = ctrl_data.split("\n") id_ctrl = {} for i in li: pattern = r"\w+\s*:\s*\w+\s*" result = re.match(pattern, i) if result: elem = result.group(0) id_ctrl[elem.split(":")[0].strip()] = elem.split(":")[1].strip() if id_ctrl: nvme_id_ctrl_list.append(id_ctrl) # initialize nvme drive list from yml configure file for disk in conf["compute"]["storage_backend"]: if disk["type"] == "nvme": nvme_config_list.append(disk) # compare nvme info from id-ctrl list against yml configure file # currently we compares: # 1. disk size # 2. serial number match_list = [] for id_ctrl in nvme_id_ctrl_list: for id_config in nvme_config_list: if id_ctrl["sn"] == id_config["serial"]: match_list.append(id_config["serial"]) assert "MTC_{}GB".format(id_config["drives"][0]["size"]) == id_ctrl["mn"] assert len(match_list) == len(nvme_list)
def test_identify_namespace(self): nvme_list = self.get_nvme_disks() ssh = sshclient.SSH("127.0.0.1", "root", "root", port=2222) assert ssh.wait_for_host_up() is True for dev in nvme_list: status, rsp_id_ns = ssh.exec_command("nvme id-ns {}".format(dev)) # Check identity keywords existance in command output key_words = ["nsze", "ncap", "nuse", "nsfeat", "nlbaf", "flbas", "mc", "dpc", "dps", "nmic", "rescap", "fpi", "nawun", "nawupf", "nacwu", "nabsn", "nabo", "nabspf", "noiob", "nvmcap", "nguid", "eui64", "lbaf"] print rsp_id_ns current_lba_index = None for line in rsp_id_ns.split(os.linesep): if line.startswith('NVME'): continue if line.startswith('lbaf'): robj = re.search( r'lbaf\s+(?P<index>\d+)\s+:\s+ms:(?P<ms>\d+)\s+(lba)?ds:' r'(?P<ds>\d+)\s+rp:\d+(\s+)?(?P<used>\(.*\))?', line) assert robj assert int(robj.groupdict().get('index')) < 5 if robj.groupdict().get('used'): current_lba_index = int(robj.groupdict().get('index')) assert current_lba_index is not None else: robj = re.search(r'(?P<key>\w+)\s+:\s+.*', rsp_id_ns) assert robj assert robj.groupdict().get('key') in key_words # Check namespace logical block size in command output status, rsp_sg = ssh.exec_command("sg_readcap {}".format(dev)) rsp_sg = re.search(r"blocks=(\d+)", rsp_sg) sg_block_size = hex(int(rsp_sg.group(1))) nsze = re.search(r"nsze\s*:\s*(0x\d+)", rsp_id_ns).group(1) assert sg_block_size == nsze
def test_write_zeroes(self): nvme_list = self.get_nvme_disks() ssh = sshclient.SSH("127.0.0.1", "root", "root", port=2222) assert ssh.wait_for_host_up() is True pattern = 0xff bin_file_name = tempfile.mktemp(suffix=".bin", prefix="nvme-test-") script_name = self._create_gen_bin_script(bin_file_name, pattern) assert self._run_gen_bin_script(bin_file_name, script_name) == 0 for dev in nvme_list: # Write 0xff to 2048 byte of nvme disks status, output = ssh.exec_command("nvme write {} -d {} -c 4 -z 2048".format(dev, bin_file_name)) assert status == 0 read_data_file = "/tmp/read_data.bin" # Verify data consistent as written status, _ = ssh.exec_command("nvme read {} -c 4 -z 2048 -d {}".format(dev, read_data_file)) assert status == 0 status, _ = ssh.exec_command("cmp {} {}".format(bin_file_name, read_data_file)) assert status == 0 # Restore drive data to all zero pattern = 0x00 bin_file_name = tempfile.mktemp(suffix=".bin", prefix="nvme-test-") script_name = self._create_gen_bin_script(bin_file_name, pattern) assert self._run_gen_bin_script(bin_file_name, script_name) == 0 for dev in nvme_list: # Write 0x00 to 2048 byte of nvme disks status, output = ssh.exec_command("nvme write-zeroes {} -c 4".format(dev)) assert status == 0 read_data_file = "/tmp/read_zero.bin" status, _ = ssh.exec_command("nvme read {} -c 4 -z 2048 -d {}".format(dev, read_data_file)) status, _ = ssh.exec_command("cmp {} {}".format(bin_file_name, read_data_file)) assert status == 0 self._clean_up()
def test_step2_nvmedrive_insert(self): ssh = sshclient.SSH("127.0.0.1", "root", "root", port=2222) assert ssh.wait_for_host_up() is True s = UnixSocket(path) s.connect() s.recv() status, stdout = ssh.exec_command('nvme list') self.assertNotIn('SSD00000001', stdout, "Failed: SN is duplicate") # 2.1: insert known NVME drive payload_enable_qmp = {"execute": "qmp_capabilities"} s.send(json.dumps(payload_enable_qmp)) s.recv() payload_drive_insert = { "execute": "human-monitor-command", "arguments": { "command-line": "device_add nvme," "id=dev-nvme-1,drive=nvme-1," "model_number=INTEL-SSD00000001," "serial=FUKD72220009375A01," "bus=downstream4,cmb_size_mb=1" } } s.send(json.dumps(payload_drive_insert)) time.sleep(5) status, stdout = ssh.exec_command('nvme list') self.assertIn('SSD00000001', stdout, "NVME drive insert failed") # 2.2: IO test, nvme1n1, SSD00000001 status, stdout = ssh.exec_command( 'sudo fio -filename=/dev/nvme1n1 -direct=1 -iodepth 1 -thread \ -rw=write -ioengine=psync -bs=4k -size=10M -numjobs=10 \ -runtime=100 -do_verify=1 -group_reporting -name=mytest') self.assertNotIn('error', stdout, "New NVME drive r/w test failed") s.close()
def client_ssh(self, ns_ip): ssh = sshclient.SSH(host=ns_ip, username="******", password="******") ssh.wait_for_host_up(300) return ssh
def _run_gen_bin_script(self, bin_file_name, script_name): ssh = sshclient.SSH("127.0.0.1", "root", "root", port=2222) assert ssh.wait_for_host_up() is True status, output = ssh.exec_command("python {}".format(script_name)) return status
def start_node(node_type): """ create two drive for comparasion. First drive has additional page, second doesn't """ global conf global tmp_conf_file global ssh global s # create a empty image for test. os.system("touch {0}".format(test_drive_image)) fake_config = fixtures.FakeConfig() conf = fake_config.get_node_info() conf["type"] = node_type conf["compute"]["storage_backend"] = [{ "type": "ahci", "max_drive_per_controller": 6, "drives": [{ "size": 8, "file": fixtures.image }] }, { "type": "megasas", "max_drive_per_controller": 16, "drives": [{ "file": test_drive_image, "format": "raw", "vendor": "SEAGATE", "product": "ST4000NM0005", "serial": "01234567", "version": "M001", "wwn": "0x5000C500852E2971", "share-rw": "true", "cache": "none", "scsi-id": 0, "slot_number": 0, "page-file": page_file }, { "file": test_drive_image, "format": "raw", "vendor": "SEAGATE", "product": "ST4000NM0005", "serial": "12345678", "version": "M001", "wwn": "0x5000C500852E3141", "share-rw": "true", "cache": "none", "scsi-id": 1, "slot_number": 1 }] }] with open(tmp_conf_file, "w") as yaml_file: yaml.dump(conf, yaml_file, default_flow_style=False) node = model.CNode(conf) node.init() node.precheck() node.start() helper.port_forward(node) path = os.path.join(node.workspace.get_workspace(), ".monitor") s = UnixSocket(path) s.connect() s.recv() payload_enable_qmp = {"execute": "qmp_capabilities"} s.send(json.dumps(payload_enable_qmp)) s.recv() # wait until system is ready for ssh. ssh = sshclient.SSH(host="127.0.0.1", username="******", password="******", port=2222) ssh.wait_for_host_up()