def _filter_datastores_matching_storage_policy(session, data_stores, storage_policy):
 profile_id = pbm.get_profile_id_by_name(session, storage_policy)
 if profile_id:
  factory = session.pbm.client.factory
  ds_mors = [oc.obj for oc in data_stores.objects]
  hubs = pbm.convert_datastores_to_hubs(factory, ds_mors)
  matching_hubs = pbm.filter_hubs_by_profile(session, hubs, profile_id)
  if matching_hubs:
   matching_ds = pbm.filter_datastores_by_hubs(matching_hubs, ds_mors)
   object_contents = [oc for oc in data_stores.objects if (oc.obj in matching_ds)]
   data_stores.objects = object_contents
   return data_stores
 LOG.error(_LE('Unable to retrieve storage policy with name %s'), storage_policy)

def _filter_datastores_matching_storage_policy ( session , data_stores , storage_policy ) : profile_id = pbm . get_profile_id_by_name ( session , storage_policy ) if profile_id : factory = session . pbm . client . factory ds_mors = [ oc . obj for oc in data_stores . objects ] hubs = pbm . convert_datastores_to_hubs ( factory , ds_mors ) matching_hubs = pbm . filter_hubs_by_profile ( session , hubs , profile_id ) if matching_hubs : matching_ds = pbm . filter_datastores_by_hubs ( matching_hubs , ds_mors ) object_contents = [ oc for oc in data_stores . objects if ( oc . obj in matching_ds ) ] data_stores . objects = object_contents return data_stores LOG . error ( _LE ( 'Unable to retrieve storage policy with name %s' ) , storage_policy )
get datastores matching the given storage policy .