PyU4V is a Python module that simplifies interaction with the Unisphere for PowerMax REST API. It wraps REST calls with simple APIs that abstracts the HTTP request and response handling.
Apache License 2.0
41
stars
37
forks
source link
I need to get only linked snapshot from storage group. #151
Hi @murugesanmadappan there is no easy way to list only linked snapshots from a storage group without iterating over them. The easier way is to list storage groups that have snapshots linked to them.
I've generated a sample function here, we need to add the option to the SDK. if you use the is_link target variable and set to true you can get a list of storage groups that are linked to snapshots, you can then do a get on each of the storage groups to find out what snapshot is linked to it. Note my sample function uses the connection as api you will need to change this to match your codebase.
api_version='100'
def List_Storage_Groups (symmetrixId, hasSrdf=None,hasSnapshots=None,hasCloudSnapshots=None,is_link_target=None,has_snap_policies=None,has_clones=None):
"""List Storage Groups.
param: symmetrixId The storage array ID -- string
param: hasSrdf Value that filters returned list to display Storage Groups that have SRDF -- bool
param: hasSnapshots Value that filters returned list to display Storage Groups that have Snapshots -- bool
param: hasCloudSnapshots Value that filters returned list to display Storage Groups that have Cloud Snapshots -- bool
param: is_link_target Value that filters returned list to display Storage Groups that are Link Targets -- bool
param: has_snap_policies Value that filters returned list to display Storage Groups that have Snapshot Policies -- bool
param: has_clones Value that filters returned list to display Storage Groups that have Clones -- bool
"""
query_params = {'hasSrdf': hasSrdf,'hasSnapshots': hasSnapshots,'hasCloudSnapshots': hasCloudSnapshots,'is_link_target': is_link_target,'has_snap_policies': has_snap_policies,'has_clones': has_clones,}
return api.common.get_request(target_uri=f"/{api_version}/replication/symmetrix/{symmetrixId}/storagegroup", resource_type=None,params=query_params)
linked_snapshot_sg = List_Storage_Groups(symmetrix_id='000123456',is_link_target = True )
for sg in linked_snapshot_sg:
print(api.replication.get_storage_group_snapshot_list(sg))
Hi @murugesanmadappan there is no easy way to list only linked snapshots from a storage group without iterating over them. The easier way is to list storage groups that have snapshots linked to them.
I've generated a sample function here, we need to add the option to the SDK. if you use the is_link target variable and set to true you can get a list of storage groups that are linked to snapshots, you can then do a get on each of the storage groups to find out what snapshot is linked to it. Note my sample function uses the connection as api you will need to change this to match your codebase.
api_version='100' def List_Storage_Groups (symmetrixId, hasSrdf=None,hasSnapshots=None,hasCloudSnapshots=None,is_link_target=None,has_snap_policies=None,has_clones=None): """List Storage Groups. param: symmetrixId The storage array ID -- string param: hasSrdf Value that filters returned list to display Storage Groups that have SRDF -- bool param: hasSnapshots Value that filters returned list to display Storage Groups that have Snapshots -- bool param: hasCloudSnapshots Value that filters returned list to display Storage Groups that have Cloud Snapshots -- bool param: is_link_target Value that filters returned list to display Storage Groups that are Link Targets -- bool param: has_snap_policies Value that filters returned list to display Storage Groups that have Snapshot Policies -- bool param: has_clones Value that filters returned list to display Storage Groups that have Clones -- bool """ query_params = {'hasSrdf': hasSrdf,'hasSnapshots': hasSnapshots,'hasCloudSnapshots': hasCloudSnapshots,'is_link_target': is_link_target,'has_snap_policies': has_snap_policies,'has_clones': has_clones,} return api.common.get_request(target_uri=f"/{api_version}/replication/symmetrix/{symmetrixId}/storagegroup", resource_type=None,params=query_params)
linked_snapshot_sg = List_Storage_Groups(symmetrix_id='000123456',is_link_target = True ) for sg in linked_snapshot_sg: print(api.replication.get_storage_group_snapshot_list(sg))