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

Add vTree migration support #13

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
61 changes: 61 additions & 0 deletions PyPowerFlex/objects/volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -522,3 +522,64 @@ def set_volume_access_mode_limit(self, volume_id, access_mode_limit):
raise exceptions.PowerFlexClientException(msg)

return self.get(entity_id=volume_id)

def migrate_vtree(self,
volume_id,
dest_sp_id,
ignore_dest_capacity=None,
queue_position=None,
vol_type_conversion=None,
allow_thick_non_zero=None,
compression_method=None):
"""
Migrates a volume from one storage pool (SP) to another.

doubletap-dave marked this conversation as resolved.
Show resolved Hide resolved
Args:
volume_id (str): The ID of the volume to be migrated.
dest_sp_id (str): The ID of the destination storage pool.
ignore_dest_capacity (bool, optional): Whether to ignore the destination storage pool's capacity. Defaults to None.
queue_position (int, optional): The position in the migration queue. Defaults to None.
vol_type_conversion (bool, optional): Whether to allow volume type conversion. Defaults to None.
allow_thick_non_zero (bool, optional): Whether to allow thick non-zero volumes. Defaults to None.
compression_method (str, optional): The compression method to use. Defaults to None.

Raises:
InvalidInput: If either volume_id or dest_sp_id is not set.
PowerFlexClientException: If the migration fails.

Returns:
dict: The updated volume information.

"""
action = 'migrateVTree'

if not all([volume_id, dest_sp_id]):
msg = 'Both volume_id and dest_sp_id must be set.'
raise exceptions.InvalidInput(msg)

params = dict(
id=volume_id,
destSPId=dest_sp_id,
ignoreDestinationCapacity=ignore_dest_capacity,
queuePosition=queue_position,
volTypeConversion=vol_type_conversion,
allowThickNonZeroPaddedVTree=allow_thick_non_zero,
compressionMethod=compression_method
)

r, response = self.send_post_request(self.base_action_url,
action=action,
entity=self.entity,
entity_id=volume_id,
params=params)

if r.status_code != requests.codes.ok:
msg = ('Failed to migrate PowerFlex {entity} with id {_id} '
'Error: {response}'.format(entity=self.entity,_id=volume_id, response=response))

LOG.error(msg)

raise exceptions.PowerFlexClientException(msg)

return self.get(entity_id=volume_id)