Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement list_volumes() API for VMAX driver #70

Merged
merged 3 commits into from
May 26, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
NajmudheenCT marked this conversation as resolved.
Show resolved Hide resolved
used_cap = (total_cap * vol['allocated_percent']) / 100.0
free_cap = total_cap - used_cap

status = switcher.get(vol['status'],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suggest , default to 'Unknown', what do you think?

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:
kumarashit marked this conversation as resolved.
Show resolved Hide resolved
sg = vol['storageGroupId'][0]
sg_info = self.conn.provisioning.get_storage_group(sg)
v['original_pool_id'] = sg_info['srp']
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'original_pool_id' or 'original_id' ?? . Plz cross check models.

one Q:
incase 'num_of_storage_groups' !=1, there will be no 'original_id' of a pool??

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is 'original_pool_id' (in class Volume(BASE, DolphinBase)). Currently we meed SG of the volume to get these info. Please see the TODO comment in the code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got it. Thanks

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