PyU4V icon indicating copy to clipboard operation
PyU4V copied to clipboard

I need to get only linked snapshot from storage group.

Open murugesanmadappan opened this issue 3 years ago • 2 comments

murugesanmadappan avatar Sep 02 '22 18:09 murugesanmadappan

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))

rawstorage avatar Sep 05 '22 08:09 rawstorage

thank you very much i will try with this.

murugesanmadappan avatar Sep 05 '22 20:09 murugesanmadappan

closing

rawstorage avatar Dec 06 '22 15:12 rawstorage