예제 #1
0
def cim_disk_to_lsm_disk(smis_common, cim_disk):
    """
    Convert CIM_DiskDrive to lsm.Disk.
    """
    # CIM_DiskDrive does not have disk size information.
    # We have to find out the Primordial CIM_StorageExtent for that.
    cim_ext = _pri_cim_ext_of_cim_disk(
        smis_common,
        cim_disk.path,
        property_list=['BlockSize', 'NumberOfBlocks'])

    status = _disk_status_of_cim_disk(cim_disk)
    if smis_common.profile_check(SmisCommon.SNIA_SPARE_DISK_PROFILE,
                                 SmisCommon.SMIS_SPEC_VER_1_4,
                                 raise_error=False):
        cim_srss = smis_common.AssociatorNames(
            cim_ext.path,
            AssocClass='CIM_IsSpare',
            ResultClass='CIM_StorageRedundancySet')
        if len(cim_srss) >= 1:
            status |= Disk.STATUS_SPARE_DISK

    if 'EMCInUse' in cim_disk.keys() and cim_disk['EMCInUse'] is False:
        status |= Disk.STATUS_FREE

    name = ''
    block_size = Disk.BLOCK_SIZE_NOT_FOUND
    num_of_block = Disk.BLOCK_COUNT_NOT_FOUND
    disk_type = Disk.TYPE_UNKNOWN
    sys_id = sys_id_of_cim_disk(cim_disk)

    # These are mandatory
    # we do not check whether they follow the SNIA standard.
    if 'Name' in cim_disk:
        name = cim_disk["Name"]
    if 'BlockSize' in cim_ext:
        block_size = cim_ext['BlockSize']
    if 'NumberOfBlocks' in cim_ext:
        num_of_block = cim_ext['NumberOfBlocks']

    if smis_common.is_megaraid():
        disk_type = _disk_type_megaraid(cim_disk)
    else:
        # SNIA SMI-S 1.4 or even 1.6 does not define anyway to find out disk
        # type.
        # Currently, EMC is following DMTF define to do so.
        if 'InterconnectType' in cim_disk:  # DMTF 2.31 CIM_DiskDrive
            disk_type = cim_disk['InterconnectType']
            if 'Caption' in cim_disk:
                # EMC VNX introduced NL_SAS disk.
                if cim_disk['Caption'] == 'NL_SAS':
                    disk_type = Disk.TYPE_NL_SAS

        if disk_type == Disk.TYPE_UNKNOWN and 'DiskType' in cim_disk:
            disk_type = _dmtf_disk_type_2_lsm_disk_type(cim_disk['DiskType'])

    disk_id = _disk_id_of_cim_disk(cim_disk)

    return Disk(disk_id, name, disk_type, block_size, num_of_block, status,
                sys_id)
예제 #2
0
    def _arcconf_disk_to_lsm_disk(arcconf_disk, sys_id, ctrl_num):
        disk_id = arcconf_disk['serialNumber'].strip()

        disk_name = "%s" % (arcconf_disk['model'])
        disk_type = _disk_type_of(arcconf_disk)
        link_type = disk_type

        try:
            blk_size = int(arcconf_disk['physicalBlockSize'])
        except KeyError:
            blk_size = int(arcconf_disk['blockSize'])
        blk_count = int(arcconf_disk['numOfUsableBlocks'])

        status = _disk_status_of(arcconf_disk)
        disk_reported_slot = arcconf_disk['fsaSlotNum']
        disk_channel = arcconf_disk['channelID']
        disk_device = arcconf_disk['deviceID']
        disk_location = \
            "%s %s %s" % (disk_reported_slot, disk_channel, disk_device)
        plugin_data = \
            "%s,%s,%s,%s" % (ctrl_num, disk_channel, disk_device, status)

        # TODO(Raghavendra) Need to find better way of getting the vpd83 info.
        # Just providing disk_path did not yield the correct vpd info.
        vpd83 = ''
        rpm = arcconf_disk['rotationalSpeed']

        return Disk(
            disk_id, disk_name, disk_type, blk_size, blk_count,
            status, sys_id, _plugin_data=plugin_data, _vpd83=vpd83,
            _location=disk_location, _rpm=rpm, _link_type=link_type)
예제 #3
0
    def _hp_disk_to_lsm_disk(hp_disk,
                             sys_id,
                             ctrl_num,
                             key_name,
                             flag_free=False):
        disk_id = hp_disk['Serial Number']
        disk_num = key_name[len("physicaldrive "):]
        disk_name = "%s %s" % (hp_disk['Model'], disk_num)
        disk_type = _disk_type_of(hp_disk)
        blk_size = int(hp_disk['Native Block Size'])
        blk_count = int(_hp_size_to_lsm(hp_disk['Size']) / blk_size)
        status = _disk_status_of(hp_disk, flag_free)
        plugin_data = "%s:%s" % (ctrl_num, disk_num)

        return Disk(disk_id, disk_name, disk_type, blk_size, blk_count, status,
                    sys_id, plugin_data)
예제 #4
0
    def disks(self, search_key=None, search_value=None,
              flags=Client.FLAG_RSVD):
        rc_lsm_disks = []
        mega_disk_path_regex = re.compile(
            r"^Drive (\/c[0-9]+\/e[0-9]+\/s[0-9]+) - Detailed Information$")

        for ctrl_num in range(self._ctrl_count()):
            sys_id = self._sys_id_of_ctrl_num(ctrl_num)

            disk_show_output = self._storcli_exec(
                ["/c%d/eall/sall" % ctrl_num, "show", "all"])
            for drive_name in disk_show_output.keys():
                re_match = mega_disk_path_regex.match(drive_name)
                if not re_match:
                    continue

                mega_disk_path = re_match.group(1)
                # Assuming only 1 disk attached to each slot.
                disk_show_basic_dict = disk_show_output[
                    "Drive %s" % mega_disk_path][0]
                disk_show_attr_dict = disk_show_output[drive_name][
                    'Drive %s Device attributes' % mega_disk_path]
                disk_show_stat_dict = disk_show_output[drive_name][
                    'Drive %s State' % mega_disk_path]

                disk_id = disk_show_attr_dict['SN'].strip()
                disk_name = "Disk %s %s %s" % (
                    disk_show_basic_dict['DID'],
                    disk_show_attr_dict['Manufacturer Id'].strip(),
                    disk_show_attr_dict['Model Number'])
                disk_type = _disk_type_of(disk_show_basic_dict)
                blk_size = size_human_2_size_bytes(
                    disk_show_basic_dict['SeSz'])
                blk_count = _blk_count_of(disk_show_attr_dict['Coerced size'])
                status = _disk_status_of(
                    disk_show_basic_dict, disk_show_stat_dict)

                plugin_data = "%s:%s" % (
                    ctrl_num, disk_show_basic_dict['EID:Slt'])

                rc_lsm_disks.append(
                    Disk(
                        disk_id, disk_name, disk_type, blk_size, blk_count,
                        status, sys_id, plugin_data))

        return search_property(rc_lsm_disks, search_key, search_value)
예제 #5
0
    def _arcconf_disk_to_lsm_disk(arcconf_disk, sys_id, ctrl_num):
        disk_id = arcconf_disk['serialNumber'].strip()

        disk_name = "%s - %s" % (arcconf_disk['vendor'], arcconf_disk['model'])
        disk_type = _disk_type_of(arcconf_disk)
        link_type = _disk_link_type_of(arcconf_disk)

        try:
            blk_size = int(arcconf_disk['physicalBlockSize'])
        except KeyError:
            blk_size = int(arcconf_disk['blockSize'])
        blk_count = int(arcconf_disk['numOfUsableBlocks'])

        status = _disk_status_of(arcconf_disk)
        disk_reported_slot = arcconf_disk['fsaSlotNum']
        disk_channel = arcconf_disk['channelID']
        disk_device = arcconf_disk['deviceID']
        disk_location = \
            "%s %s %s" % (disk_reported_slot, disk_channel, disk_device)
        plugin_data = \
            "%s,%s,%s,%s" % (ctrl_num, disk_channel, disk_device, status)

        disk_path = arcconf_disk['physicalDriveName']
        if disk_path != 'Not Applicable':
            vpd83 = LocalDisk.vpd83_get(disk_path)
        else:
            vpd83 = ''
        rpm = arcconf_disk['rotationalSpeed']

        return Disk(disk_id,
                    disk_name,
                    disk_type,
                    blk_size,
                    blk_count,
                    status,
                    sys_id,
                    _plugin_data=plugin_data,
                    _vpd83=vpd83,
                    _location=disk_location,
                    _rpm=rpm,
                    _link_type=link_type)
예제 #6
0
    def disks(self,
              search_key=None,
              search_value=None,
              flags=Client.FLAG_RSVD):
        rc_lsm_disks = []
        mega_disk_path_regex = re.compile(
            r"""
                ^Drive \ (
                \/c[0-9]+\/             # Controller ID
                (:?e[0-9]+\/){0,1}      # Enclosure ID(optional)
                s[0-9]+                 # Slot ID
                )\ -\ Detailed\ Information$""", re.X)

        for ctrl_num in range(self._ctrl_count()):
            sys_id = self._sys_id_of_ctrl_num(ctrl_num)

            try:
                disk_show_output = self._storcli_exec(
                    ["/c%d/eall/sall" % ctrl_num, "show", "all"])
            except ExecError:
                disk_show_output = {}

            try:
                disk_show_output.update(
                    self._storcli_exec(["/c%d/sall" % ctrl_num, "show",
                                        "all"]))
            except (ExecError, TypeError, LsmError):
                pass

            for drive_name in list(disk_show_output.keys()):
                re_match = mega_disk_path_regex.match(drive_name)
                if not re_match:
                    continue

                mega_disk_path = re_match.group(1)
                # Assuming only 1 disk attached to each slot.
                disk_show_basic_dict = disk_show_output["Drive %s" %
                                                        mega_disk_path][0]
                disk_show_attr_dict = disk_show_output[drive_name][
                    'Drive %s Device attributes' % mega_disk_path]
                disk_show_stat_dict = disk_show_output[drive_name][
                    'Drive %s State' % mega_disk_path]

                disk_id = disk_show_attr_dict['SN'].strip()
                disk_name = "Disk %s %s %s" % (
                    disk_show_basic_dict['DID'],
                    disk_show_attr_dict['Manufacturer Id'].strip(),
                    disk_show_attr_dict['Model Number'])
                disk_type = _disk_type_of(disk_show_basic_dict)
                blk_size = size_human_2_size_bytes(
                    disk_show_basic_dict['SeSz'])
                blk_count = _blk_count_of(disk_show_attr_dict['Coerced size'])
                status = _disk_status_of(disk_show_basic_dict,
                                         disk_show_stat_dict)

                plugin_data = "%s:%s" % (ctrl_num,
                                         disk_show_basic_dict['EID:Slt'])
                vpd83 = disk_show_attr_dict["WWN"].lower()
                if vpd83 == 'na':
                    vpd83 = ''
                rpm = _disk_rpm_of(disk_show_basic_dict)
                link_type = _disk_link_type_of(disk_show_basic_dict)

                rc_lsm_disks.append(
                    Disk(disk_id,
                         disk_name,
                         disk_type,
                         blk_size,
                         blk_count,
                         status,
                         sys_id,
                         plugin_data,
                         _vpd83=vpd83,
                         _rpm=rpm,
                         _link_type=link_type))

        return search_property(rc_lsm_disks, search_key, search_value)
예제 #7
0
    def disks(
        self,
        search_key=None,
        search_value=None,
        flags=Client.FLAG_RSVD,
    ):
        _ = flags
        rc_lsm_disks = []
        mega_disk_path_regex = re.compile(
            r"""
                ^Drive \ (
                \/c[0-9]+\/             # Controller ID
                (:?e[0-9]+\/){0,1}      # Enclosure ID(optional)
                s[0-9]+                 # Slot ID
                )\ -\ Detailed\ Information$""",
            re.X,
        )

        for ctrl_num in range(self._ctrl_count()):
            sys_id = self._sys_id_of_ctrl_num(ctrl_num)
            try:
                disk_show_output = self._storcli_exec(
                    f"/c{ctrl_num:d}/eall/sall show all",
                    ignore_failure=True,
                )
            except ExecError:
                disk_show_output = {}

            try:
                disk_show_output.update(
                    self._storcli_exec(
                        f"/c{ctrl_num:d}/sall show all",
                        ignore_failure=True,
                    ), )
            except (ExecError, TypeError):
                pass
            for drive_name in list(disk_show_output.keys()):
                re_match = mega_disk_path_regex.match(drive_name)
                if not re_match:
                    continue

                mega_disk_path = re_match.group(1)
                # Assuming only 1 disk attached to each slot.
                disk_show_basic_dict = disk_show_output[
                    f"Drive {mega_disk_path}"][0]
                disk_show_attr_dict = disk_show_output[drive_name][
                    f"Drive {mega_disk_path} Device attributes"]
                disk_show_stat_dict = disk_show_output[drive_name][
                    f"Drive {mega_disk_path} State"]

                disk_id = disk_show_attr_dict["SN"].strip()
                disk_name = "Disk {} {} {}".format(
                    disk_show_basic_dict["DID"],
                    disk_show_attr_dict["Manufacturer Id"].strip(),
                    disk_show_attr_dict["Model Number"],
                )
                disk_type = _disk_type_of(disk_show_basic_dict)
                blk_size = size_human_2_size_bytes(
                    disk_show_basic_dict["SeSz"], )
                blk_count = _blk_count_of(disk_show_attr_dict["Coerced size"])
                status = _disk_status_of(
                    disk_show_basic_dict,
                    disk_show_stat_dict,
                )

                plugin_data = f"{ctrl_num}:{disk_show_basic_dict['EID:Slt']}"
                vpd83 = disk_show_attr_dict["WWN"].lower()
                if vpd83 == "na":
                    vpd83 = ""
                rpm = _disk_rpm_of(disk_show_basic_dict)
                link_type = _disk_link_type_of(disk_show_basic_dict)

                rc_lsm_disks.append(
                    Disk(
                        disk_id,
                        disk_name,
                        disk_type,
                        blk_size,
                        blk_count,
                        status,
                        sys_id,
                        plugin_data,
                        _vpd83=vpd83,
                        _rpm=rpm,
                        _link_type=link_type,
                    ))
        return search_property(rc_lsm_disks, search_key, search_value)