def _arcconf_ld_to_lsm_vol(arcconf_ld, pool_id, sys_id, ctrl_num, array_num, arcconf_ld_name): ld_num = arcconf_ld['logicalDriveID'] vpd83 = str(arcconf_ld['volumeUniqueID']).lower() block_size = arcconf_ld['BlockSize'] num_of_blocks = int(arcconf_ld['dataSpace']) * 1024 / int(block_size) vol_name = arcconf_ld_name if vpd83: blk_paths = LocalDisk.vpd83_search(vpd83) if blk_paths: vol_name += ": %s" % " ".join(blk_paths) if int(arcconf_ld['state']) != LOGICAL_DEVICE_OK: admin_status = Volume.ADMIN_STATE_DISABLED else: admin_status = Volume.ADMIN_STATE_ENABLED plugin_data = "%s:%s:%s" % (ctrl_num, array_num, ld_num) volume_id = array_num return Volume( volume_id, vol_name, vpd83, block_size, num_of_blocks, admin_status, sys_id, pool_id, plugin_data)
def _arcconf_ld_to_lsm_vol(arcconf_ld, array_num, sys_id, ctrl_num): ld_id = arcconf_ld['logicalDriveID'] raid_level = arcconf_ld['raidLevel'] vpd83 = str(arcconf_ld['volumeUniqueID']).lower() pool_id = "%s:%s" % (sys_id, array_num) block_size = arcconf_ld['BlockSize'] num_of_blocks = int(arcconf_ld['dataSpace']) vol_name = arcconf_ld['name'] if vpd83: blk_paths = LocalDisk.vpd83_search(vpd83) if blk_paths: vol_name += ": %s" % " ".join(blk_paths) if int(arcconf_ld['state']) != LOGICAL_DEVICE_OK: admin_status = Volume.ADMIN_STATE_DISABLED else: admin_status = Volume.ADMIN_STATE_ENABLED stripe_size = arcconf_ld['StripeSize'] full_stripe_size = arcconf_ld['fullStripeSize'] ld_state = arcconf_ld['state'] plugin_data = "%s:%s:%s:%s:%s:%s:%s" % (ld_state, raid_level, stripe_size, full_stripe_size, ld_id, array_num, ctrl_num) volume_id = "%s:%s" % (sys_id, ld_id) return Volume(volume_id, vol_name, vpd83, block_size, num_of_blocks, admin_status, sys_id, pool_id, plugin_data)
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) disk_port, disk_box, disk_bay = disk_num.split(":") disk_location = "Port: %s Box: %s Bay: %s" % ( disk_port, disk_box, disk_bay) status = _disk_status_of(hp_disk, flag_free) plugin_data = "%s:%s" % (ctrl_num, disk_num) disk_path = hp_disk.get('Disk Name') if disk_path: vpd83 = LocalDisk.vpd83_get(disk_path) else: vpd83 = '' rpm = int(hp_disk.get('Rotational Speed', Disk.RPM_NON_ROTATING_MEDIUM)) link_type = _disk_link_type_of(hp_disk) 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)
def _arcconf_ld_to_lsm_vol(arcconf_ld, pool_id, sys_id, ctrl_num, array_num, arcconf_ld_name): """ raises DeviceNotFoundError """ ld_num = arcconf_ld['logicalDriveID'] vpd83 = str(arcconf_ld['volumeUniqueID']).lower() block_size = arcconf_ld['BlockSize'] num_of_blocks = int(arcconf_ld['dataSpace']) / int(block_size) vol_name = arcconf_ld_name if len(vpd83) > 0: blk_paths = LocalDisk.vpd83_search(vpd83) if len(blk_paths) > 0: blk_path = blk_paths[0] vol_name += ": %s" % " ".join(blk_paths) device = Device.from_device_file(_CONTEXT, blk_path) attributes = device.attributes try: block_size = attributes.asint("BlockSize") num_of_blocks = attributes.asint("dataSpace") except (KeyError, UnicodeDecodeError, ValueError): pass if int(arcconf_ld['state']) > 2: admin_status = Volume.ADMIN_STATE_DISABLED else: admin_status = Volume.ADMIN_STATE_ENABLED plugin_data = "%s:%s:%s" % (ctrl_num, array_num, ld_num) volume_id = array_num return Volume(volume_id, vol_name, vpd83, block_size, num_of_blocks, admin_status, sys_id, pool_id, plugin_data)
def __init__(self, dev_path): self.dev_path = dev_path self.error_list = set() if lsm_available: self.lsm_available = True self.disk = LocalDisk() else: self.lsm_available = False self.error_list.add("libstoragemgmt (lsm module) is unavailable") logger.info("LSM information is unavailable: libstoragemgmt is not installed") self.disk = None self.led_bits = None
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) disk_path = '' # TODO(Raghavendra) Need to find better way of getting the vpd83 info. # Just providing disk_path did not yield the correct vpd info. if disk_path: 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)
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)
def _hp_ld_to_lsm_vol(hp_ld, pool_id, sys_id, ctrl_num, array_num, hp_ld_name): """ raises DeviceNotFoundError """ ld_num = hp_ld_name[len("Logical Drive: "):] vpd83 = hp_ld['Unique Identifier'].lower() # No document or command output indicate block size # of volume. So we try to read from linux kernel, if failed # try 512 and roughly calculate the sector count. block_size = 512 num_of_blocks = int(_hp_size_to_lsm(hp_ld['Size']) / block_size) vol_name = hp_ld_name if len(vpd83) > 0: blk_paths = LocalDisk.vpd83_search(vpd83) if len(blk_paths) > 0: blk_path = blk_paths[0] vol_name += ": %s" % " ".join(blk_paths) device = Device.from_device_file(_CONTEXT, blk_path) attributes = device.attributes try: block_size = attributes.asint("queue/logical_block_size") num_of_blocks = attributes.asint("size") except (KeyError, UnicodeDecodeError, ValueError): pass if 'Failed' in hp_ld['Status']: admin_status = Volume.ADMIN_STATE_DISABLED else: admin_status = Volume.ADMIN_STATE_ENABLED plugin_data = "%s:%s:%s" % (ctrl_num, array_num, ld_num) # HP SmartArray does not allow disabling volume. return Volume( vpd83, vol_name, vpd83, block_size, num_of_blocks, admin_status, sys_id, pool_id, plugin_data)