Skip to content

Commit

Permalink
Implement list_volumes() API for VMAX driver (#70)
Browse files Browse the repository at this point in the history
* Implement list_volumes() API for VMAX driver

* Address review comments

Co-authored-by: Ashit Kumar <akopensrc@gmail.com>
  • Loading branch information
joseph-v and kumarashit committed May 26, 2020
1 parent 473767d commit 94262b0
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 2 deletions.
3 changes: 2 additions & 1 deletion dolphin/drivers/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ def list_pools(self, context, storage_id):

def list_volumes(self, context, storage_id):
"""List all storage volumes from storage system."""
pass
driver = self.driver_manager.get_driver(context, storage_id=storage_id)
return driver.list_volumes(context)

def add_trap_config(self, context, storage_id, trap_config):
"""Config the trap receiver in storage system."""
Expand Down
62 changes: 62 additions & 0 deletions dolphin/drivers/dell_emc/vmax/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,65 @@ def list_pools(self):
LOG.error("Failed to get pool metrics from VMAX: {}".format(err))
raise exception.StorageBackendException(
reason='Failed to get pool metrics from VMAX')

def list_volumes(self, storage_id):

try:
# List all volumes except data volumes
volumes = self.conn.provisioning.get_volume_list(
filters={'data_volume': 'false'})

# TODO: Update constants.VolumeStatus to make mapping more precise
switcher = {
'Ready': constants.VolumeStatus.AVAILABLE,
'Not Ready': constants.VolumeStatus.ERROR,
'Mixed': constants.VolumeStatus.ERROR,
'Write Disabled': constants.VolumeStatus.ERROR,
'N/A': constants.VolumeStatus.ERROR,
}

volume_list = []
for volume in volumes:
# Get volume details
vol = self.conn.provisioning.get_volume(volume)

total_cap = vol['cap_mb'] * units.Mi
used_cap = (total_cap * vol['allocated_percent']) / 100.0
free_cap = total_cap - used_cap

status = switcher.get(vol['status'],
constants.VolumeStatus.ERROR)

description = "Dell EMC VMAX volume"
if vol['type'] == 'TDEV':
description = "Dell EMC VMAX 'thin device' volume"

v = {
"name": volume,
"storage_id": storage_id,
"description": description,
"status": status,
"original_id": vol['volumeId'],
"wwn": vol['wwn'],
"storage_type": constants.StorageType.BLOCK,
"total_capacity": int(total_cap),
"used_capacity": int(used_cap),
"free_capacity": int(free_cap),
}

if vol['num_of_storage_groups'] == 1:
sg = vol['storageGroupId'][0]
sg_info = self.conn.provisioning.get_storage_group(sg)
v['original_pool_id'] = sg_info['srp']
v['compressed'] = sg_info['compression']

# TODO: Workaround when SG is, not available/not unique

volume_list.append(v)

return volume_list

except Exception as err:
LOG.error("Failed to get list volumes from VMAX: {}".format(err))
raise exception.StorageBackendException(
reason='Failed to get list volumes from VMAX')
2 changes: 1 addition & 1 deletion dolphin/drivers/dell_emc/vmax/vmax.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def list_pools(self, context):
return self.client.list_pools()

def list_volumes(self, context):
pass
return self.client.list_volumes(self.storage_id)

def add_trap_config(self, context, trap_config):
pass
Expand Down

0 comments on commit 94262b0

Please sign in to comment.