示例#1
0
def start_chassis():
    """

    """
    global conf
    global ssh1
    global ssh2
    global chassis
    conf = fixtures.ChassisConfig().get_chassis_info()
    conf["data"]["pn"] = "What_ever_SN"
    conf["data"]["sn"] = "What_ever_SN"
    conf["data"]["psu1_pn"] = "A380-B737-C909"

    node0_log = "/tmp/qemu_node0.log"
    node1_log = "/tmp/qemu_node1.log"
    compute_0 = conf["nodes"][0]["compute"]
    compute_0["storage_backend"][0]["drives"][0][
        "file"] = fixtures.a_boot_image
    compute_0["extra_option"] = "-D {} -trace events=/tmp/trace_items".format(
        node0_log)
    compute_0["ntb"] = [{
        "addr": 'a.0',
        "bus": "pcie.0",
        "bar1_exp": 15,
        "bar2_exp": 15,
        "id": "ntb0",
        "peer_id": "ntb1"
    }]

    compute_1 = conf["nodes"][1]["compute"]
    compute_1["storage_backend"][0]["drives"][0][
        "file"] = fixtures.b_boot_image
    compute_1["extra_option"] = "-D {} -trace events=/tmp/trace_items".format(
        node1_log)
    compute_1["ntb"] = [{
        "addr": 'a.0',
        "bus": "pcie.0",
        "bar1_exp": 15,
        "bar2_exp": 15,
        "id": "ntb1",
        "peer_id": "ntb0"
    }]

    if os.path.exists(node0_log):
        os.remove(node0_log)
    if os.path.exists(node1_log):
        os.remove(node1_log)

    chassis = model.CChassis(conf["name"], conf)
    chassis.precheck()
    chassis.init()

    data_file_dir = os.path.join(
        ChassisWorkspace(conf).get_workspace_data(), "oem_data.json")
    with open(data_file_dir, "w") as f:
        json.dump(data_file, f)
    chassis.start()

    ssh1 = helper.prepare_ssh(nodes_ip[0], 8022)
    ssh2 = helper.prepare_ssh(nodes_ip[1], 8022)
示例#2
0
    def test_sata_drive_erase_master_pw(self):
        # Only format 1 sata drive here.
        # Otherwise, it will take long time which is not suitable for functional test.
        global sata_drive_serial
        drive = self.get_drive(sata_drive_serial)
        # Set master password
        master_pw = "master_password"
        ssh = helper.prepare_ssh()
        stdin, stdout, stderr = ssh.exec_command(
            'hdparm --user-master m --security-set-pass ' + master_pw + ' /dev/' + drive)
        lines = stdout.channel.recv(2048)
        # Check master password set command response correctly
        assert re.search(r"Issuing SECURITY_SET_PASS command, password="******"Security Mode feature set" enabled.
        usr_pw = "user_password"
        stdin, stdout, stderr = ssh.exec_command('hdparm --security-set-pass ' + usr_pw + ' /dev/' + drive)
        lines = stdout.channel.recv(2048)
        # Check user password set command response correctly
        assert re.search(r"Issuing SECURITY_SET_PASS command, password="******"\*\s+Security Mode feature set", lines)
        assert re.search(r"\s+device size with M = 1024\*1024:\s+4096 MBytes", lines)

        ssh.close()

        ssh = helper.prepare_ssh()
        # Write disk
        stdin, stdout, stderr = ssh.exec_command('echo abcdefg > test_file')
        stdin, stdout, stderr = ssh.exec_command(
            'dd if=test_file of=/dev/' + drive + ' bs=10M seek=8388607 count=1 conv=fsync')
        ssh.exec_command('rm -rf test_file')
        ssh.close()

        # Erase disk
        ssh = helper.prepare_ssh()
        stdin, stdout, stderr = ssh.exec_command(
            'hdparm --user-master m --security-erase ' + master_pw + ' /dev/' + drive)
        while not stdout.channel.exit_status_ready():
            pass
        stdin, stdout, stderr = ssh.exec_command('dd if=/dev/{} skip=8388607 count=1 | hexdump -C'.format(drive))
        lines = stdout.channel.recv(2048)
        print "hexdump result after formating:\r\n", lines
        # Expects hexdump shows drive data in the last sector is all zero. That is something like below:
        # 00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
        # *
        # 00000200
        assert re.match(r"00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|\*\00000200",
                        lines)

        stdin, stdout, stderr = ssh.exec_command('hdparm -I /dev/' + drive)
        lines = stdout.channel.recv(2048)
        ssh.close()

        assert re.search(r"\*\s+Security Mode feature set", lines) is None
示例#3
0
    def test_sas_drive_erase(self):
        # Only format 1 sas drive here.
        # Otherwise, it will take long time which is not suitable for functional test.
        global sas_drive_serial
        ssh = helper.prepare_ssh()
        stdin, stdout, stderr = ssh.exec_command('echo abcdefg > test_file')
        while not stdout.channel.exit_status_ready():
            pass
        ssh.close()

        drive = self.get_drive(sas_drive_serial)
        ssh = helper.prepare_ssh()
        stdin, stdout, stderr = ssh.exec_command(
            'dd if=test_file of=/dev/' + drive +
            ' bs=10M seek=8388607 count=1 conv=fsync')
        while not stdout.channel.exit_status_ready():
            pass
        ssh.exec_command('rm -rf test_file')

        # Check disk size, which should be 4GB
        stdin, stdout, stderr = ssh.exec_command('sg_readcap /dev/' + drive)
        while not stdout.channel.exit_status_ready():
            pass
        lines = stdout.channel.recv(2048)
        assert "Device size: 4294967296 bytes, 4096.0 MiB, 4.29 GB" in lines

        stdin, stdout, stderr = ssh.exec_command('sg_format --format /dev/' +
                                                 drive)
        while not stdout.channel.exit_status_ready():
            pass
        ssh.close()

        ssh = helper.prepare_ssh()
        while True:
            stdin, stdout, stderr = ssh.exec_command('sg_requests -p /dev/' +
                                                     drive)
            while not stdout.channel.exit_status_ready():
                pass
            lines = stdout.channel.recv(2048)
            # Expects format complete, and no "Progress indication" message from "sg_requests"
            if 'Progress indication' in lines:
                time.sleep(1)
            else:
                break

        stdin, stdout, stderr = ssh.exec_command(
            'dd if=/dev/{} skip=8388607 count=1 | hexdump -C'.format(drive))
        lines = stdout.channel.recv(2048)
        print "hexdump result after formating:\r\n", lines
        # Expects hexdump shows drive data in the last sector is all zero. That is something like below:
        # 00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
        # *
        # 00000200
        assert re.match(
            r"00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|\*\00000200",
            lines)
        ssh.close()
示例#4
0
    def test_sas_drive_erase(self):
        # Only format 1 sas drive here.
        # Otherwise, it will take long time which is not suitable for functional test.
        global sas_drive_serial
        ssh = helper.prepare_ssh()
        stdin, stdout, stderr = ssh.exec_command('echo abcdefg > test_file')
        while not stdout.channel.exit_status_ready():
            pass
        ssh.close()

        drive = self.get_drive(sas_drive_serial)
        ssh = helper.prepare_ssh()
        stdin, stdout, stderr = ssh.exec_command(
            'dd if=test_file of=/dev/' + drive + ' bs=10M seek=8388607 count=1 conv=fsync')
        while not stdout.channel.exit_status_ready():
            pass
        ssh.exec_command('rm -rf test_file')

        # Check disk size, which should be 4GB
        stdin, stdout, stderr = ssh.exec_command('sg_readcap /dev/' + drive)
        while not stdout.channel.exit_status_ready():
            pass
        lines = stdout.channel.recv(2048)
        assert "Device size: 4294967296 bytes, 4096.0 MiB, 4.29 GB" in lines

        stdin, stdout, stderr = ssh.exec_command(
            'sg_format --format /dev/' + drive)
        while not stdout.channel.exit_status_ready():
            pass
        ssh.close()

        ssh = helper.prepare_ssh()
        while True:
            stdin, stdout, stderr = ssh.exec_command(
                'sg_requests -p /dev/' + drive)
            while not stdout.channel.exit_status_ready():
                pass
            lines = stdout.channel.recv(2048)
            # Expects format complete, and no "Progress indication" message from "sg_requests"
            if 'Progress indication' in lines:
                time.sleep(1)
            else:
                break

        stdin, stdout, stderr = ssh.exec_command('dd if=/dev/{} skip=8388607 count=1 | hexdump -C'.format(drive))
        lines = stdout.channel.recv(2048)
        print "hexdump result after formating:\r\n", lines
        # Expects hexdump shows drive data in the last sector is all zero. That is something like below:
        # 00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
        # *
        # 00000200
        assert re.match(r"00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|\*\00000200",
                        lines)
        ssh.close()
    def test_sata_drive_erase_usr_pw(self):
        # Only format 1 sata drive here.
        # Otherwise, it will take long time which is not suitable for functional test.
        drive = self.get_drive(sata_drive_serial)
        ssh = helper.prepare_ssh()
        stdin, stdout, stderr = ssh.exec_command('hdparm -I /dev/'+drive)
        lines = stdout.channel.recv(2048)
        assert re.search(r"\*\s+Security Mode feature set", lines) is None

        usr_pw = "user_password"
        stdin, stdout, stderr = ssh.exec_command('hdparm --security-set-pass '+usr_pw+' /dev/'+drive)

        stdin, stdout, stderr = ssh.exec_command('hdparm -I /dev/'+drive)
        lines = stdout.channel.recv(2048)
        # Expect "Security Mode feature set" to be enabled after set user password
        print "hdparm -I /dev/'"+drive+'\r\n', lines
        assert re.search(r"\*\s+Security Mode feature set", lines)
        assert re.search(r"\s+device size with M = 1024\*1024:\s+4096 MBytes", lines)

        ssh.close()

        ssh = helper.prepare_ssh()
        stdin, stdout, stderr = ssh.exec_command('echo abcdefg > test_file')
        while not stdout.channel.exit_status_ready():
            pass
        ssh.close()

        ssh = helper.prepare_ssh()
        # Write to the last block of drive
        stdin, stdout, stderr = ssh.exec_command(
            'dd if=test_file of=/dev/'+drive+' bs=10M seek=8388607 count=1 conv=fsync')
        ssh.exec_command('rm -rf test_file')
        ssh.close()

        ssh = helper.prepare_ssh()
        stdin, stdout, stderr = ssh.exec_command('hdparm --user-master u --security-erase '+usr_pw+' /dev/'+drive)
        while not stdout.channel.exit_status_ready():
            pass
        stdin, stdout, stderr = ssh.exec_command('dd if=/dev/{} skip=8388607 count=1 | hexdump -C'.format(drive))
        lines = stdout.channel.recv(2048)

        # Expects hexdump shows drive data in the last sector is all zero. That is something like below:
        # 00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
        # *
        # 00000200
        print "hexdump result after formating:\r\n", lines
        assert re.match(r"00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|\*\00000200", lines)

        stdin, stdout, stderr = ssh.exec_command('hdparm -I /dev/'+drive)
        lines = stdout.channel.recv(2048)
        # Expect "Security Mode feature set" to be disabled
        assert re.search(r"\*\s+Security Mode feature set", lines) is None
        ssh.close()
示例#6
0
def start_chassis():
    """

    """
    global conf
    global ssh1
    global ssh2
    global chassis
    conf = fixtures.ChassisConfig().get_chassis_info()
    conf["type"] = "s2600kp"
    conf["data"]["pn"] = "What_ever_SN"
    conf["data"]["sn"] = "What_ever_SN"
    conf["data"]["psu1_pn"] = "A380-B737-C909"

    node0_log = "/tmp/qemu_node0.log"
    node1_log = "/tmp/qemu_node1.log"
    compute_0 = conf["nodes"][0]["compute"]
    compute_0["storage_backend"][0]["drives"][0]["file"] = fixtures.a_boot_image
    compute_0["extra_option"] = "-D {} -trace events=/tmp/trace_items".format(node0_log)
    compute_0["ntb"] = [{"addr": 'a.0',
                         "bus": "pcie.0",
                         "bar1_exp": 15,
                         "bar2_exp": 15,
                         "id": "ntb0",
                         "peer_id": "ntb1"}]

    compute_1 = conf["nodes"][1]["compute"]
    compute_1["storage_backend"][0]["drives"][0]["file"] = fixtures.b_boot_image
    compute_1["extra_option"] = "-D {} -trace events=/tmp/trace_items".format(node1_log)
    compute_1["ntb"] = [{"addr": 'a.0',
                         "bus": "pcie.0",
                         "bar1_exp": 15,
                         "bar2_exp": 15,
                         "id": "ntb1",
                         "peer_id": "ntb0"}]

    if os.path.exists(node0_log):
        os.remove(node0_log)
    if os.path.exists(node1_log):
        os.remove(node1_log)

    chassis = model.CChassis(conf["name"], conf)
    chassis.precheck()
    chassis.init()

    data_file_dir = os.path.join(ChassisWorkspace(conf).get_workspace_data(), "oem_data.json")
    with open(data_file_dir, "w") as f:
        json.dump(data_file, f)
    chassis.start()

    ssh1 = helper.prepare_ssh(nodes_ip[0], 8022)
    ssh2 = helper.prepare_ssh(nodes_ip[1], 8022)
示例#7
0
    def test_identify_namespace(self):
        nvme_list = self.get_nvme_disks()
        ssh = helper.prepare_ssh()
        for dev in nvme_list:
            stdin, stdout, stderr = ssh.exec_command("nvme id-ns {}".format(dev))
            while not stdout.channel.exit_status_ready():
                pass
            # Check identity keywords existance in command output
            rsp_id_ns = stdout.channel.recv(2048)
            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"]
            assert set(key_words)<set(rsp_id_ns.split())

            # Check namespace logical block size in command output
            stdin, stdout, stderr = ssh.exec_command("sg_readcap {}".format(dev))
            while not stdout.channel.exit_status_ready():
                pass
            rsp_sg = stdout.channel.recv(2048)
            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
        ssh.close()
def start_node():
    global conf
    global ssh

    fake_config = fixtures.FakeConfig()
    conf = fake_config.get_node_info()
    conf["compute"]["networks"][0]["port_forward"] = [{
        "protocal": "tcp",
        "inside": 22,
        "outside": 2222
    }]
    conf["compute"]["boot"] = {"boot_order": "c"}
    conf["compute"]["serial_number"] = "infrasim300"
    conf["compute"]["cpu"] = {"type": "Haswell", "quantities": 4}

    conf["compute"]["memory"] = {"size": 4096}

    conf["compute"]["storage_backend"] = [{
        "type":
        "ahci",
        "max_drive_per_controller":
        6,
        "drives": [{
            "size": 10,
            "file": fixtures.image
        }]
    }]

    node = model.CNode(conf)
    node.init()
    node.precheck()
    node.start()
    node.wait_node_up()

    ssh = helper.prepare_ssh()
示例#9
0
def start_node(conf):
    global ssh
    node = model.CNode(conf)
    node.init()
    node.precheck()
    node.start()
    helper.port_forward(node)
    ssh = helper.prepare_ssh("127.0.0.1", 2222, "root", "root")
示例#10
0
def start_node(conf):
    global ssh
    node = model.CNode(conf)
    node.init()
    node.precheck()
    node.start()
    helper.port_forward(node)
    ssh = helper.prepare_ssh("127.0.0.1", 2222, "root", "root")
示例#11
0
 def get_nvme_disks(self):
     ssh = helper.prepare_ssh()
     nvme_list = []
     stdin, stdout, stderr = ssh.exec_command("sudo nvme list |grep \"/dev\" |awk '{print $1}'")
     while not stdout.channel.exit_status_ready():
         pass
     nvme_list = stdout.channel.recv(2048).split()
     ssh.close()
     return nvme_list
示例#12
0
def start_node_directly():
    global conf
    global tmp_conf_file
    global ssh
    os.system("touch {0}".format(test_drive_directly_image))
    fake_config = fixtures.FakeConfig()
    conf = fake_config.get_node_info()
    conf["compute"]["boot"] = {"boot_order": "c"}

    conf["compute"]["storage_backend"] = [{
        "type":
        "ahci",
        "max_drive_per_controller":
        6,
        "drives": [{
            "size": 8,
            "file": fixtures.image
        }]
    }, {
        "type":
        "lsisas3008",
        "max_drive_per_controller":
        32,
        "drives": [{
            "file": test_drive_directly_image,
            "format": "raw",
            "vendor": "SEAGATE",
            "product": "ST4000NM0005",
            "serial": "01234567",
            "version": "M001",
            "wwn": "0x5000C500852E2971",
            "share-rw": "true",
            "cache": "none",
            "scsi-id": 0,
            "slot_number": 0
        }, {
            "file": test_drive_directly_image,
            "format": "raw",
            "vendor": "SEAGATE",
            "product": "ST4000NM0005",
            "serial": "12345678",
            "version": "M001",
            "wwn": "0x5000C500852E3141",
            "share-rw": "true",
            "cache": "none",
            "scsi-id": 1,
            "slot_number": 1
        }]
    }]

    node = model.CNode(conf)
    node.init()
    node.precheck()
    node.start()

    helper.port_forward(node)
    ssh = helper.prepare_ssh()
示例#13
0
 def test_error_log(self):
     nvme_disk_list = self.get_nvme_disks()
     ssh = helper.prepare_ssh()
     for nvme in nvme_disk_list:
         stdin, stdout, stderr = ssh.exec_command("nvme error-log {}".format(nvme))
         while not stdout.channel.exit_status_ready():
             pass
         rsp = stdout.channel.recv(2048)
         assert re.search("Error Log Entries for device:{} entries:(\d+)".format(nvme.split("/")[2]), rsp)
     ssh.close()
示例#14
0
 def get_nvme_dev(self):
     # Return nvme drive device, eg. ['nvme0', 'nvme1']
     ssh = helper.prepare_ssh()
     nvme_dev_list = []
     stdin, stdout, stderr = ssh.exec_command("ls /sys/class/nvme")
     while not stdout.channel.exit_status_ready():
         pass
     nvme_dev_list = stdout.channel.recv(2048).split()
     ssh.close()
     return nvme_dev_list
示例#15
0
    def get_nvme_ns_list(self, nvme):
        # Return name space id list, eg. ['1', '2']
        ssh = helper.prepare_ssh()
        stdin, stdout, stderr = ssh.exec_command("ls /sys/class/nvme/{} |grep {}".format(nvme, nvme))
        response = stdout.channel.recv(2048)
        nsid_list = []

        for ns in response.split():
            id = re.search(r"nvme(\d+)n(\d+)", ns)
            nsid = id.group(2)
            nsid_list.append(nsid)
        return nsid_list
def start_node():
    global conf
    global ssh
    global s
    fake_config = fixtures.FakeConfig()
    conf = fake_config.get_node_info()

    conf["compute"]["networks"] = [{
        "device":
        "e1000",
        "id":
        "e1000.0",
        "mac":
        "00:60:16:9c:ff:6a",
        "network_mode":
        "nat",
        "port_forward": [{
            "outside": 2222,
            "inside": 22,
            "protocal": "tcp"
        }]
    }, {
        "device": "e1000",
        "id": "e1000.1",
        "network_mode": "nat",
        "mac": target_mac,
    }]
    conf["compute"]["storage_backend"] = [
        {
            "type": "ahci",
            "max_drive_per_controller": 6,
            "drives": [{
                "size": 8,
                "file": fixtures.image
            }]
        },
    ]
    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()

    ssh = prepare_ssh()
 def start_node():
     global conf
     global path
     global ssh
     nvme_config = fixtures.NvmeConfig()
     conf = nvme_config.get_node_info()
     node = model.CNode(conf)
     node.init()
     node.precheck()
     node.start()
     helper.port_forward(node)
     path = os.path.join(node.workspace.get_workspace(), ".monitor")
     ssh = helper.prepare_ssh("127.0.0.1")
示例#18
0
def start_node():
    """
    create two drive for comparasion.
    First drive has additional page, second doesn't
    """
    global conf
    global ssh

    fake_config = fixtures.FakeConfig()
    conf = fake_config.get_node_info()
    conf["compute"]["networks"][0]["port_forward"] = [
        {
            "protocal": "tcp",
            "inside": 22,
            "outside": 2222
        }
    ]
    conf["compute"]["boot"] = {
        "boot_order": "c"
    }
    conf["compute"]["uuid"] = "9cef4921-fc70-493f-8674-a01801384881"
    conf["compute"]["cpu"] = {
        "type": "Haswell",
        "quantities": 4
    }

    conf["compute"]["memory"] = {
        "size": 4096
    }

    conf["compute"]["storage_backend"] = [
        {
            "type": "ahci",
            "max_drive_per_controller": 6,
            "drives": [
                {
                    "size": 10,
                    "file": fixtures.image
                }
            ]
        }
    ]

    node = model.CNode(conf)
    node.init()
    node.precheck()
    node.start()
    node.wait_node_up()

    ssh = helper.prepare_ssh()
示例#19
0
    def test_smart_log(self):
        # To get MT devices list.
        nvme_model_list = []
        ssh = helper.prepare_ssh()
        stdin, stdout, stderr = ssh.exec_command("nvme list |grep \"/dev\" |awk '{print $1,$3}'")
        while not stdout.channel.exit_status_ready():
            pass
        nvme_model_list = stdout.channel.recv(2048).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])
        ssh.close()

        nvme_dev_list = self.get_nvme_dev()
        ssh = helper.prepare_ssh()
        for nvme in nvme_dev_list:
            nsid_list = self.get_nvme_ns_list(nvme)
            for ns_id in nsid_list:
                stdin, stdout, stderr = ssh.exec_command("nvme smart-log /dev/{} -n {}".format(nvme, ns_id))
                while not stdout.channel.exit_status_ready():
                    pass
                rsp = stdout.channel.recv(2048)
                print rsp
                # 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+)", rsp)
                assert re.search(r"temperature\s+:\s+(\d+)(\s+)C", rsp)
                assert re.search(r"available_spare\s+:\s+(\d+)%", rsp)
                assert re.search(r"available_spare_threshold\s+:\s+(\d+)%", rsp)

                # FIXME: For MT, there are two Temperature Sensors need to check, now this step is expected to FAIL.
                '''
                if "{}n{}".format(nvme, ns_id) in mt_list:
                    print "This is MT, need to check two temperature sensors"
                    assert re.search(r"Temperature(\s+)Sensor(\s+)(\d+)(\s+):(\s+)(\d+)(\s+)C", rsp)
                '''
        ssh.close()
示例#20
0
    def get_drive(self, serial):
        ssh = helper.prepare_ssh()
        stdin, stdout, stderr = ssh.exec_command("ls /dev")
        drives = stdout.channel.recv(2048)
        drives = [e for e in filter(lambda x:"sd" in x, drives.split())]

        for drive in drives:
            stdin, stdout, stderr = ssh.exec_command('sg_inq /dev/' + drive)
            lines = stdout.channel.recv(2048)
            if serial in lines:
                ssh.close()
                time.sleep(2)
                return drive
        ssh.close()
        time.sleep(2)
示例#21
0
    def get_drive(self, serial):
        ssh = helper.prepare_ssh()
        stdin, stdout, stderr = ssh.exec_command("ls /dev")
        drives = stdout.channel.recv(2048)
        drives = [e for e in filter(lambda x: "sd" in x, drives.split())]

        for drive in drives:
            stdin, stdout, stderr = ssh.exec_command('sg_inq /dev/' + drive)
            lines = stdout.channel.recv(2048)
            if serial in lines:
                ssh.close()
                time.sleep(2)
                return drive
        ssh.close()
        time.sleep(2)
示例#22
0
    def test_get_ns_id(self):
        global conf
        nvme_list = self.get_nvme_disks()
        ssh = helper.prepare_ssh()

        for dev in nvme_list:
            stdin, stdout, stderr = ssh.exec_command("nvme get-ns-id {}".format(dev))
            while not stdout.channel.exit_status_ready():
                pass
            rsp = stdout.channel.recv(2048)
            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)
        ssh.close()
def start_node():
    global conf
    global ssh

    fake_config = fixtures.FakeConfig()
    conf = fake_config.get_node_info()
    conf["compute"]["networks"][0]["port_forward"] = [
        {
            "protocal": "tcp",
            "inside": 22,
            "outside": 2222
        }
    ]
    conf["compute"]["boot"] = {
        "boot_order": "c"
    }
    conf["compute"]["serial_number"] = "infrasim300"
    conf["compute"]["cpu"] = {
        "type": "Haswell",
        "quantities": 4
    }

    conf["compute"]["memory"] = {
        "size": 4096
    }

    conf["compute"]["storage_backend"] = [
        {
            "type": "ahci",
            "max_drive_per_controller": 6,
            "drives": [
                {
                    "size": 10,
                    "file": fixtures.image
                }
            ]
        }
    ]

    node = model.CNode(conf)
    node.init()
    node.precheck()
    node.start()
    node.wait_node_up()

    ssh = helper.prepare_ssh()
示例#24
0
    def test_write_zeroes(self):

        nvme_list = self.get_nvme_disks()
        ssh = helper.prepare_ssh()
        for dev in nvme_list:
            # Write 0xff to 2048 byte of nvme disks
            stdin, stdout, stderr = ssh.exec_command("nvme write {} -d ff_binfile -c 4 -z 2048".format(dev))
            while not stdout.channel.exit_status_ready():
                pass

            # Verify data consistent as written
            stdin, stdout, stderr = ssh.exec_command("nvme read {} -c 4 -z 2048 > read_data".format(dev))
            while not stdout.channel.exit_status_ready():
                pass

            stdin, stdout, stderr = ssh.exec_command("hexdump read_data -n 2048".format(dev))
            while not stdout.channel.exit_status_ready():
                pass
            read_data = stdout.channel.recv(2048)
            stdin, stdout, stderr = ssh.exec_command("hexdump ff_binfile".format(dev))
            while not stdout.channel.exit_status_ready():
                pass
            binfile_data = stdout.channel.recv(2048)
            assert read_data == binfile_data

            # restore drive data to all zero
            stdin, stdout, stderr = ssh.exec_command("nvme write-zeroes {} -c 4".format(dev))
            while not stdout.channel.exit_status_ready():
                pass

            stdin, stdout, stderr = ssh.exec_command("nvme read {} -c 4 -z 2048 > read_zero".format(dev))
            while not stdout.channel.exit_status_ready():
                pass

            stdin, stdout, stderr = ssh.exec_command("hexdump read_zero -n 2048".format(dev))
            while not stdout.channel.exit_status_ready():
                pass
            read_data = stdout.channel.recv(2048)

            stdin, stdout, stderr = ssh.exec_command("hexdump 0_binfile -n 2048".format(dev))
            while not stdout.channel.exit_status_ready():
                pass
            binfile_data = stdout.channel.recv(2048)
            assert read_data == binfile_data
        ssh.close()
示例#25
0
 def test_get_log(self):
     global conf
     nvme_dev_list = self.get_nvme_dev()
     ssh = helper.prepare_ssh()
     # 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):
                 stdin, stdout, stderr = ssh.exec_command("nvme get-log /dev/{} -n {} -i {} -l 512".format(nvme, ns_id, log_id))
                 while not stdout.channel.exit_status_ready():
                     pass
                 rsp = stdout.channel.recv(2048)
                 print rsp
                 assert nvme, ns_id in rsp
                 assert str(log_id) in rsp
     ssh.close()
def start_chassis():
    """

    """
    global conf
    global ssh
    global chassis
    conf = fixtures.ChassisConfig().get_chassis_info()
    conf["data"]["pn"] = "What_ever_SN"
    conf["data"]["sn"] = "What_ever_SN"
    conf["data"]["psu1_pn"] = "A380-B737-C909"

    node0_log = "/tmp/qemu_node0.log"
    node1_log = "/tmp/qemu_node1.log"
    compute_0 = conf["nodes"][0]["compute"]
    compute_0["storage_backend"][0]["drives"][0][
        "file"] = fixtures.a_boot_image
    compute_0["extra_option"] = "-D {} -trace events=/tmp/trace_items".format(
        node0_log)

    compute_1 = conf["nodes"][1]["compute"]
    compute_1["storage_backend"][0]["drives"][0][
        "file"] = fixtures.b_boot_image
    compute_1["extra_option"] = "-D {} -trace events=/tmp/trace_items".format(
        node1_log)

    if os.path.exists(node0_log):
        os.remove(node0_log)
    if os.path.exists(node1_log):
        os.remove(node1_log)

    chassis = model.CChassis(conf["name"], conf)
    chassis.precheck()
    chassis.init()

    data_file_dir = os.path.join(
        ChassisWorkspace(conf).get_workspace_data(), "oem_data.json")
    with open(data_file_dir, "w") as f:
        json.dump(data_file, f)
    chassis.start()

    ssh = helper.prepare_ssh("192.168.188.92", 8022)
示例#27
0
    def test_id_ctrl(self):
        global conf
        nvme_list = self.get_nvme_disks()
        ssh = helper.prepare_ssh()
        nvme_config_list = []
        nvme_id_ctrl_list = []

        # initialize nvme id-ctrl list
        for dev in nvme_list:
            stdin, stdout, stderr = ssh.exec_command("nvme id-ctrl {}".format(dev))
            while not stdout.channel.exit_status_ready():
                pass
            ctrl_data = stdout.channel.recv(2048)

            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)
        ssh.close()

        # 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)
示例#28
0
def start_node():
    """
    create two drive for comparasion.
    First drive has additional page, second doesn't
    """
    global conf
    global ssh

    fake_config = fixtures.FakeConfig()
    conf = fake_config.get_node_info()
    conf["compute"]["networks"][0]["port_forward"] = [{
        "protocal": "tcp",
        "inside": 22,
        "outside": 2222
    }]
    conf["compute"]["boot"] = {"boot_order": "c"}
    conf["compute"]["uuid"] = "9cef4921-fc70-493f-8674-a01801384881"
    conf["compute"]["cpu"] = {"type": "Haswell", "quantities": 4}

    conf["compute"]["memory"] = {"size": 4096}

    conf["compute"]["storage_backend"] = [{
        "type":
        "ahci",
        "max_drive_per_controller":
        6,
        "drives": [{
            "size": 10,
            "file": fixtures.image
        }]
    }]

    node = model.CNode(conf)
    node.init()
    node.precheck()
    node.start()
    node.wait_node_up()

    ssh = helper.prepare_ssh()
示例#29
0
def start_chassis():
    """
    
    """
    global conf
    global ssh

    conf = fixtures.ChassisConfig().get_chassis_info()
    conf["data"]["pn"] = "What_ever_SN"
    conf["data"]["sn"] = "What_ever_SN"
    conf["data"]["psu1_pn"] = "A380-B737-C909"

    node0_log = "/tmp/qemu_node0.log"
    node1_log = "/tmp/qemu_node1.log"
    compute_0 = conf["nodes"][0]["compute"]
    compute_0["storage_backend"][0]["drives"][0]["file"] = a_boot_image
    compute_0["extra_option"] = "-D {} -trace events=/tmp/trace_items".format(
        node0_log)

    compute_1 = conf["nodes"][1]["compute"]
    compute_1["storage_backend"][0]["drives"][0]["file"] = b_boot_image
    compute_1["extra_option"] = "-D {} -trace events=/tmp/trace_items".format(
        node1_log)

    if os.path.exists(node0_log):
        os.remove(node0_log)
    if os.path.exists(node1_log):
        os.remove(node1_log)

    global chassis
    chassis = model.CChassis(conf["name"], conf)
    chassis.precheck()
    chassis.init()
    chassis.start()

    ssh = helper.prepare_ssh("192.168.188.92", 8022)
示例#30
0
    def test_sata_drive_erase_usr_pw(self):
        # Only format 1 sata drive here.
        # Otherwise, it will take long time which is not suitable for functional test.
        drive = self.get_drive(sata_drive_serial)
        ssh = helper.prepare_ssh()
        stdin, stdout, stderr = ssh.exec_command('hdparm -I /dev/' + drive)
        lines = stdout.channel.recv(2048)
        assert re.search(r"\*\s+Security Mode feature set", lines) is None

        usr_pw = "user_password"
        stdin, stdout, stderr = ssh.exec_command(
            'hdparm --security-set-pass ' + usr_pw + ' /dev/' + drive)
        lines = stdout.channel.recv(2048)
        # Check user password set command response correctly
        assert re.search(r"Issuing SECURITY_SET_PASS command, password="******"Security Mode feature set" to be enabled after set user password
        print "hdparm -I /dev/" + drive + '\r\n', lines
        assert re.search(r"\*\s+Security Mode feature set", lines)
        assert re.search(r"\s+device size with M = 1024\*1024:\s+4096 MBytes",
                         lines)
        ssh.close()

        ssh = helper.prepare_ssh()
        stdin, stdout, stderr = ssh.exec_command('echo abcdefg > test_file')
        while not stdout.channel.exit_status_ready():
            pass
        ssh.close()

        ssh = helper.prepare_ssh()
        # Write to the last block of drive
        stdin, stdout, stderr = ssh.exec_command(
            'dd if=test_file of=/dev/' + drive +
            ' bs=10M seek=8388607 count=1 conv=fsync')
        ssh.exec_command('rm -rf test_file')
        ssh.close()

        ssh = helper.prepare_ssh()
        stdin, stdout, stderr = ssh.exec_command(
            'hdparm --user-master u --security-erase ' + usr_pw + ' /dev/' +
            drive)
        while not stdout.channel.exit_status_ready():
            pass
        stdin, stdout, stderr = ssh.exec_command(
            'dd if=/dev/{} skip=8388607 count=1 | hexdump -C'.format(drive))
        lines = stdout.channel.recv(2048)

        # Expects hexdump shows drive data in the last sector is all zero. That is something like below:
        # 00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|
        # *
        # 00000200
        print "hexdump result after formating:\r\n", lines
        assert re.match(
            r"00000000  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  |................|\*\00000200",
            lines)

        stdin, stdout, stderr = ssh.exec_command('hdparm -I /dev/' + drive)
        lines = stdout.channel.recv(2048)
        # Expect "Security Mode feature set" to be disabled
        assert re.search(r"\*\s+Security Mode feature set", lines) is None
        ssh.close()
示例#31
0
    def test_copy_file_across_drives(self):
        ssh = helper.prepare_ssh()
        stdin, stdout, stderr = ssh.exec_command('touch /root/source.bin')
        while not stdout.channel.exit_status_ready():
            pass

        stdin, stdout, stderr = ssh.exec_command(
            "echo 'Test message is found! :D' >> /root/source.bin")
        while not stdout.channel.exit_status_ready():
            pass

        ssh.close()

        drive = self.get_drive(boot_drive_serial)
        ssh = helper.prepare_ssh()
        for i in ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'):
            if 'sd'+i != drive:
                stdin, stdout, stderr = ssh.exec_command(
                    'dd if=/root/source.bin of=/dev/sd' + i + ' bs=512 seek=0 count=1 conv=fsync')

        ssh.close()

        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]:
                stdin, stdout, stderr = ssh.exec_command(
                    'dd if=/dev/sd' + i + ' of=/root/target_' + i + '.bin bs=512 skip=0 count=1 conv=fsync')
        ssh.close()
        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]:
                stdin, stdout, stderr = ssh.exec_command(
                    'cat /root/target_' + i + '.bin')
                lines = stdout.channel.recv(2048)
                assert 'Test message is found! :D' in lines
        ssh.close()

        ssh = helper.prepare_ssh()
        stdin, stdout, stderr = ssh.exec_command('rm /root/source.bin')
        while not stdout.channel.exit_status_ready():
            pass
        ssh.close()

        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]:
                stdin, stdout, stderr = ssh.exec_command(
                    'rm /root/target_' + i + '.bin')

                stdin, stdout, stderr = ssh.exec_command(
                    'ls /root' + i + '/target_' + i + '.bin')

                lines = stdout.channel.recv(2048)
                assert 'target_' + i + '.bin' not in lines
        ssh.close()
        time.sleep(2)
示例#32
0
def start_node():
    global conf
    global ssh

    fake_config = fixtures.FakeConfig()
    conf = fake_config.get_node_info()
    conf["compute"]["networks"][0]["port_forward"] = [
        {
            "protocal": "tcp",
            "inside": 22,
            "outside": 2222
        }
    ]
    conf["compute"]["boot"] = {
        "boot_order": "c"
    }
    conf["compute"]["uuid"] = "9cef4921-fc70-493f-8674-a01801384881"
    conf["compute"]["cpu"] = {
        "type": "Haswell",
        "quantities": 4
    }

    conf["compute"]["memory"] = {
        "size": 4096
    }

    conf["compute"]["storage_backend"] = [
        {
            "type": "ahci",
            "max_drive_per_controller": 6,
            "drives": [
                {
                    "size": 10,
                    "file": fixtures.image
                }
            ]
        }
    ]

    conf["compute"]["smbios"] = {
        "type1": {
              "sku_number": "sssdsf",
              "sn": "a1111"
        },
        "type2": {
              "location": "SPA",
              "sn": "a222"
        },
        "type3": {
              "sn": "a3333"
        },
        "type4": {
              "cores": 4,
              "sn": "a4444"
        },
        "type17": [
            {
               "locator": "B1",
               "part_number": "p11716",
               "size": 8,
               "sn": "a1717"
            }
        ]
    }
    conf["bmc"] = {}
    conf["bmc"]["fru0"] = {
        "board": {
             "name": "test1",
             "pn": "p222",
             "sn": "s222"
        }
    }
    node = model.CNode(conf)
    node.init()
    node.precheck()
    node.start()
    node.wait_node_up()

    ssh = helper.prepare_ssh()
示例#33
0
    def test_file_existance_after_node_restart(self):
        global conf
        # Write disk
        ssh = helper.prepare_ssh()
        stdin, stdout, stderr = ssh.exec_command('touch /root/source.bin')
        while not stdout.channel.exit_status_ready():
            pass
        stdin, stdout, stderr = ssh.exec_command(
            "echo 'Test message is found! :D' >> /root/source.bin")
        while not stdout.channel.exit_status_ready():
            pass

        # FIXME: close ssh is walk around to issue of ssh connection go inactive
        # which seems like a paramiko issue? So as other ssh.close() in file.
        ssh.close()
        # FIXME
        drive = self.get_drive(sas_drive_serial)
        ssh = helper.prepare_ssh()
        stdin, stdout, stderr = ssh.exec_command(
            'dd if=/root/source.bin of=/dev/' + drive +
            ' bs=512 seek=0 count=1 conv=fsync')
        while not stdout.channel.exit_status_ready():
            pass

        ssh.close()

        # Check disk content intact after node restart
        run_command("infrasim node restart {}".format(conf["name"]))
        node = model.CNode(conf)
        node.init()
        helper.port_forward(node)
        ssh = helper.prepare_ssh()

        stdin, stdout, stderr = ssh.exec_command('touch /root/source.bin')
        while not stdout.channel.exit_status_ready():
            pass
        stdin, stdout, stderr = ssh.exec_command(
            "echo 'Test message is found! :D' >> /root/source.bin")
        while not stdout.channel.exit_status_ready():
            pass
        stdin, stdout, stderr = ssh.exec_command(
            'dd if=/dev/' + drive +
            ' of=/root/target.bin bs=512 skip=0 count=1 conv=fsync')
        while not stdout.channel.exit_status_ready():
            pass

        ssh.close()

        ssh = helper.prepare_ssh()
        stdin, stdout, stderr = ssh.exec_command(
            'diff /root/source.bin /root/target.bin -B')
        while not stdout.channel.exit_status_ready():
            pass

        lines = stdout.channel.recv(2048)
        print('Expect lines="", Actual lines="{}"'.format(lines))
        assert lines is ''
        ssh.close()

        ssh = helper.prepare_ssh()
        stdin, stdout, stderr = ssh.exec_command('rm /root/target.bin')
        while not stdout.channel.exit_status_ready():
            pass

        stdin, stdout, stderr = ssh.exec_command('ls /root')
        while not stdout.channel.exit_status_ready():
            pass

        lines = stdout.channel.recv(2048)
        assert 'target.bin' not in lines
        stdin, stdout, stderr = ssh.exec_command('rm /root/source.bin')
        while not stdout.channel.exit_status_ready():
            pass

        stdin, stdout, stderr = ssh.exec_command('ls /root')
        while not stdout.channel.exit_status_ready():
            pass

        lines = stdout.channel.recv(2048)
        ssh.close()
        assert 'source.bin' not in lines
示例#34
0
    def test_file_existance_after_node_restart(self):
        global conf
        # Write disk
        ssh = helper.prepare_ssh()
        stdin, stdout, stderr = ssh.exec_command('touch /root/source.bin')
        while not stdout.channel.exit_status_ready():
            pass
        stdin, stdout, stderr = ssh.exec_command(
            "echo 'Test message is found! :D' >> /root/source.bin")
        while not stdout.channel.exit_status_ready():
            pass

        # FIXME: close ssh is walk around to issue of ssh connection go inactive
        # which seems like a paramiko issue? So as other ssh.close() in file.
        ssh.close()
        # FIXME
        drive = self.get_drive(sas_drive_serial)
        ssh = helper.prepare_ssh()
        stdin, stdout, stderr = ssh.exec_command(
            'dd if=/root/source.bin of=/dev/' + drive + ' bs=512 seek=0 count=1 conv=fsync')
        while not stdout.channel.exit_status_ready():
            pass

        ssh.close()

        # Check disk content intact after node restart
        run_command("infrasim node restart {}".format(conf["name"]))
        node = model.CNode(conf)
        node.init()
        helper.port_forward(node)
        ssh = helper.prepare_ssh()

        stdin, stdout, stderr = ssh.exec_command('touch /root/source.bin')
        while not stdout.channel.exit_status_ready():
            pass
        stdin, stdout, stderr = ssh.exec_command(
            "echo 'Test message is found! :D' >> /root/source.bin")
        while not stdout.channel.exit_status_ready():
            pass
        stdin, stdout, stderr = ssh.exec_command(
            'dd if=/dev/' + drive + ' of=/root/target.bin bs=512 skip=0 count=1 conv=fsync')
        while not stdout.channel.exit_status_ready():
            pass

        ssh.close()

        ssh = helper.prepare_ssh()
        stdin, stdout, stderr = ssh.exec_command(
            'diff /root/source.bin /root/target.bin -B')
        while not stdout.channel.exit_status_ready():
            pass

        lines = stdout.channel.recv(2048)
        print('Expect lines="", Actual lines="{}"'.format(lines))
        assert lines is ''
        ssh.close()

        ssh = helper.prepare_ssh()
        stdin, stdout, stderr = ssh.exec_command('rm /root/target.bin')
        while not stdout.channel.exit_status_ready():
            pass

        stdin, stdout, stderr = ssh.exec_command('ls /root')
        while not stdout.channel.exit_status_ready():
            pass

        lines = stdout.channel.recv(2048)
        assert 'target.bin' not in lines
        stdin, stdout, stderr = ssh.exec_command('rm /root/source.bin')
        while not stdout.channel.exit_status_ready():
            pass

        stdin, stdout, stderr = ssh.exec_command('ls /root')
        while not stdout.channel.exit_status_ready():
            pass

        lines = stdout.channel.recv(2048)
        ssh.close()
        assert 'source.bin' not in lines
示例#35
0
def start_node_enclosure():
    global ssh
    global conf
    fake_config = fixtures.FakeConfig()
    conf = fake_config.get_node_info()
    conf["compute"]["boot"] = {"boot_order": "c"}

    conf["compute"]["storage_backend"] = [{
        "type":
        "ahci",
        "max_drive_per_controller":
        6,
        "drives": [{
            "size": 8,
            "file": fixtures.image
        }]
    }, {
        "type":
        "lsisas3008",
        "sas_address":
        5764824129059291136,
        "max_drive_per_controller":
        32,
        "connectors": [{
            "phy": 0,
            "wwn": 5764824129059291136,
            "atta_enclosure": "enclosure_0",
            "atta_exp": "lcc-a",
            "atta_port": 0
        }, {
            "phy": 4,
            "wwn": 5764824129059291137,
            "atta_enclosure": "enclosure_0",
            "atta_exp": "lcc-b",
            "atta_port": 0
        }]
    }, {
        "type":
        "disk_array",
        "disk_array": [{
            "enclosure": {
                "type":
                28,
                "drives": [{
                    "repeat": drv_count,
                    "start_phy_id": 12,
                    "format": "raw",
                    "share-rw": "true",
                    "version": "B29C",
                    "file": "/tmp/topo/sda{}.img",
                    "slot_number": 0,
                    "serial": "ZABCD{}",
                    "wwn": wwn_drv
                }],
                "expanders": [{
                    "phy_count":
                    36,
                    "wwn":
                    wwn_exp0,
                    "phy_map":
                    "35-10,8,9",
                    "ports": [{
                        "phy": 0,
                        "id": 0,
                        "number": 4
                    }, {
                        "phy": 4,
                        "id": 1,
                        "number": 4
                    }],
                    "side":
                    0,
                    "name":
                    "lcc-a",
                    "ses": {
                        "buffer_data":
                        "/home/infrasim/workspace/bins/buffer.bin"
                    }
                }, {
                    "phy_count":
                    36,
                    "wwn":
                    wwn_exp1,
                    "ports": [{
                        "phy": 0,
                        "id": 0,
                        "number": 4
                    }, {
                        "phy": 4,
                        "id": 1,
                        "number": 4
                    }],
                    "side":
                    1,
                    "name":
                    "lcc-b",
                    "ses": {
                        "buffer_data":
                        "/home/infrasim/workspace/bins/buffer.bin"
                    }
                }]
            },
            "name": "enclosure_0"
        }, {
            "enclosure": {
                "type":
                28,
                "drives": [{
                    "repeat": drv1_count,
                    "start_phy_id": 12,
                    "format": "raw",
                    "share-rw": "true",
                    "version": "B29C",
                    "file": "/tmp/topo/sdb{}.img",
                    "slot_number": 0,
                    "serial": "ZABCE{}",
                    "wwn": wwn_drv1
                }],
                "expanders": [{
                    "phy_count":
                    36,
                    "wwn":
                    wwn_exp2,
                    "ports": [{
                        "phy": 0,
                        "id": 0,
                        "number": 4
                    }, {
                        "phy": 4,
                        "id": 1,
                        "number": 4
                    }],
                    "side":
                    0,
                    "name":
                    "lcc-a",
                    "ses": {
                        "buffer_data":
                        "/home/infrasim/workspace/bins/buffer.bin"
                    }
                }, {
                    "phy_count":
                    36,
                    "wwn":
                    wwn_exp3,
                    "ports": [{
                        "phy": 0,
                        "id": 0,
                        "number": 4
                    }, {
                        "phy": 4,
                        "id": 1,
                        "number": 4
                    }],
                    "side":
                    1,
                    "name":
                    "lcc-b",
                    "ses": {
                        "buffer_data":
                        "/home/infrasim/workspace/bins/buffer.bin"
                    }
                }]
            },
            "name": "enclosure_1"
        }, {
            "connections": [{
                "link": [{
                    "disk_array": "enclosure_0",
                    "exp": "lcc-a",
                    "number": 4,
                    "phy": 4
                }, {
                    "disk_array": "enclosure_1",
                    "exp": "lcc-a",
                    "number": 4,
                    "phy": 0
                }]
            }, {
                "link": [{
                    "disk_array": "enclosure_0",
                    "exp": "lcc-b",
                    "number": 4,
                    "phy": 4
                }, {
                    "disk_array": "enclosure_1",
                    "exp": "lcc-b",
                    "number": 4,
                    "phy": 0
                }]
            }]
        }]
    }]

    node = model.CNode(conf)
    node.init()
    node.precheck()
    node.start()
    helper.port_forward(node)
    ssh = helper.prepare_ssh()
示例#36
0
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
    fake_config = fixtures.FakeConfig()
    conf = fake_config.get_node_info()
    conf["compute"]["boot"] = {
        "boot_order": "c"
        }

    conf["compute"]["storage_backend"] = [
        {
            "type": "ahci",
            "max_drive_per_controller": 6,
            "drives": [
                {
                    "size": 8,
                    "file": test_img_file
                }
            ]
        },
        {
            "type": "lsisas3008",
            "max_drive_per_controller": 32,
            "connectors": [
                {
                    "phy": 0,
                    "wwn": 5764824129059291136,
                    "atta_enclosure": "enclosure_0",
                    "atta_exp": "lcc-a",
                    "atta_port": 0
                },
                {
                    "phy": 4,
                    "wwn": 5764824129059291137,
                    "atta_enclosure": "enclosure_0",
                    "atta_exp": "lcc-b",
                    "atta_port": 0
                }
            ]
        },
        {
            "type": "disk_array",
            "disk_array": [
                {
                    "enclosure": {
                        "type": 28,
                        "drives": [
                            {
                                "repeat": 8,
                                "start_phy_id": 12,
                                "format": "raw",
                                "share-rw": "true",
                                "version": "B29C",
                                "file": "/tmp/topo/sda{}.img",
                                "slot_number": 0,
                                "serial": "ZABCD{}",
                                "wwn": wwn_drv
                            }
                        ],
                        "expanders": [
                            {
                                "phy_count": 36,
                                "wwn": wwn_exp0,
                                "ports": [
                                    {
                                        "phy": 0,
                                        "id": 0,
                                        "number": 4
                                    },
                                    {
                                        "phy": 4,
                                        "id": 1,
                                        "number": 4
                                    }
                                ],
                                "side": 0,
                                "name": "lcc-a",
                                "ses": {
                                   "buffer_data": "/home/infrasim/workspace/bins/buffer.bin"
                                }
                            },
                            {
                                "phy_count": 36,
                                "wwn": wwn_exp1,
                                "ports": [
                                    {
                                        "phy": 0,
                                        "id": 0,
                                        "number": 4
                                    },
                                    {
                                        "phy": 4,
                                        "id": 1,
                                        "number": 4
                                    }
                                ],
                                "side": 1,
                                "name": "lcc-b",
                                "ses": {
                                   "buffer_data": "/home/infrasim/workspace/bins/buffer.bin"
                                }
                            }
                        ]
                    },
                    "name": "enclosure_0"
                }
            ]
        }
    ]

    node = model.CNode(conf)
    node.init()
    node.precheck()
    node.start()

    helper.port_forward(node)
    ssh = helper.prepare_ssh()
def set_port_forward_try_ssh(node):
    helper.port_forward(node)
    ssh = helper.prepare_ssh()
    ssh.close()
    time.sleep(5)
示例#38
0
def start_node():
    """
    create two drive for comparasion.
    First drive has additional page, second doesn't
    """
    global conf
    global tmp_conf_file
    global ssh

    fake_config = fixtures.FakeConfig()
    conf = fake_config.get_node_info()
    conf["compute"]["networks"][0]["port_forward"] = [{
        "protocal": "tcp",
        "inside": 22,
        "outside": 2222
    }]
    conf["compute"]["boot"] = {"boot_order": "c"}

    conf["compute"]["cpu"] = {"type": "Haswell", "quantities": 4}

    conf["compute"]["memory"] = {"size": 4096}

    conf["compute"]["storage_backend"] = [{
        "type":
        "ahci",
        "max_drive_per_controller":
        6,
        "drives": [{
            "size": 10,
            "file": fixtures.image
        }]
    }, {
        "type":
        "lsisas3008",
        "max_drive_per_controller":
        16,
        "drives": [{
            "format": "raw",
            "size": 10,
            "vendor": "SEAGATE",
            "product": "ST4000NM0005",
            "serial": "01234567",
            "version": "M001",
            "wwn": "0x5000C500852E2971",
            "share-rw": "true",
            "cache": "none",
            "scsi-id": 0,
            "slot_number": 0,
            "sector_size": 520
        }, {
            "format": "raw",
            "size": 10,
            "vendor": "HITACH",
            "product": "ST4000NM0006",
            "serial": "12345678",
            "version": "M001",
            "wwn": "0x5000C500852E3141",
            "share-rw": "true",
            "cache": "none",
            "scsi-id": 1,
            "slot_number": 1
        }]
    }]

    node = model.CNode(conf)
    node.init()
    node.precheck()
    node.start()
    node.wait_node_up()

    ssh = helper.prepare_ssh()
示例#39
0
def set_port_forward_try_ssh(node):
    helper.port_forward(node)
    ssh = helper.prepare_ssh()
    ssh.close()
    time.sleep(5)
示例#40
0
    def test_copy_file_across_drives(self):
        ssh = helper.prepare_ssh()
        stdin, stdout, stderr = ssh.exec_command('touch /root/source.bin')
        while not stdout.channel.exit_status_ready():
            pass

        stdin, stdout, stderr = ssh.exec_command(
            "echo 'Test message is found! :D' >> /root/source.bin")
        while not stdout.channel.exit_status_ready():
            pass

        ssh.close()

        drive = self.get_drive(boot_drive_serial)
        ssh = helper.prepare_ssh()
        for i in ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l'):
            if 'sd' + i != drive:
                stdin, stdout, stderr = ssh.exec_command(
                    'dd if=/root/source.bin of=/dev/sd' + i +
                    ' bs=512 seek=0 count=1 conv=fsync')

        ssh.close()

        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]:
                stdin, stdout, stderr = ssh.exec_command(
                    'dd if=/dev/sd' + i + ' of=/root/target_' + i +
                    '.bin bs=512 skip=0 count=1 conv=fsync')
        ssh.close()
        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]:
                stdin, stdout, stderr = ssh.exec_command('cat /root/target_' +
                                                         i + '.bin')
                lines = stdout.channel.recv(2048)
                assert 'Test message is found! :D' in lines
        ssh.close()

        ssh = helper.prepare_ssh()
        stdin, stdout, stderr = ssh.exec_command('rm /root/source.bin')
        while not stdout.channel.exit_status_ready():
            pass
        ssh.close()

        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]:
                stdin, stdout, stderr = ssh.exec_command('rm /root/target_' +
                                                         i + '.bin')

                stdin, stdout, stderr = ssh.exec_command('ls /root' + i +
                                                         '/target_' + i +
                                                         '.bin')

                lines = stdout.channel.recv(2048)
                assert 'target_' + i + '.bin' not in lines
        ssh.close()
        time.sleep(2)
示例#41
0
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
    fake_config = fixtures.FakeConfig()
    conf = fake_config.get_node_info()
    conf["compute"]["boot"] = {"boot_order": "c"}

    conf["compute"]["storage_backend"] = [{
        "type":
        "ahci",
        "max_drive_per_controller":
        6,
        "drives": [{
            "size": 8,
            "file": test_img_file
        }]
    }, {
        "type":
        "lsisas3008",
        "max_drive_per_controller":
        32,
        "connectors": [{
            "phy": 0,
            "wwn": 5764824129059291136,
            "atta_enclosure": "enclosure_0",
            "atta_exp": "lcc-a",
            "atta_port": 0
        }, {
            "phy": 4,
            "wwn": 5764824129059291137,
            "atta_enclosure": "enclosure_0",
            "atta_exp": "lcc-b",
            "atta_port": 0
        }]
    }, {
        "type":
        "disk_array",
        "disk_array": [{
            "enclosure": {
                "type":
                28,
                "drives": [{
                    "repeat": 8,
                    "start_phy_id": 12,
                    "format": "raw",
                    "share-rw": "true",
                    "version": "B29C",
                    "file": "/tmp/topo/sda{}.img",
                    "slot_number": 0,
                    "serial": "ZABCD{}",
                    "wwn": wwn_drv
                }],
                "expanders": [{
                    "phy_count":
                    36,
                    "wwn":
                    wwn_exp0,
                    "ports": [{
                        "phy": 0,
                        "id": 0,
                        "number": 4
                    }, {
                        "phy": 4,
                        "id": 1,
                        "number": 4
                    }],
                    "side":
                    0,
                    "name":
                    "lcc-a",
                    "ses": {
                        "buffer_data":
                        "/home/infrasim/workspace/bins/buffer.bin"
                    }
                }, {
                    "phy_count":
                    36,
                    "wwn":
                    wwn_exp1,
                    "ports": [{
                        "phy": 0,
                        "id": 0,
                        "number": 4
                    }, {
                        "phy": 4,
                        "id": 1,
                        "number": 4
                    }],
                    "side":
                    1,
                    "name":
                    "lcc-b",
                    "ses": {
                        "buffer_data":
                        "/home/infrasim/workspace/bins/buffer.bin"
                    }
                }]
            },
            "name": "enclosure_0"
        }]
    }]

    node = model.CNode(conf)
    node.init()
    node.precheck()
    node.start()

    helper.port_forward(node)
    ssh = helper.prepare_ssh()