def get_dataset_locks_bulk(dids, session=None): """ Get the dataset locks of a list of datasets or containers, recursively :param dids: List of dictionaries {"scope":scope(type:InternalScope), "name":name, "type":did type(DIDType.DATASET or DIDType.CONTAINER)}, "type" is optional :param session: The db session to use. :return: Generator of lock_info dicts, may contain duplicates """ for did in dids: scope = did["scope"] assert isinstance(scope, InternalScope) name = did["name"] did_type = did.get("type") if not did_type: try: did_info = rucio.core.did.get_did(scope, name, session=session) except DataIdentifierNotFound: continue did_type = did_info["type"] assert did_type in (DIDType.DATASET, DIDType.CONTAINER) if did_type == DIDType.DATASET: for lock_dict in get_dataset_locks(scope, name, session=session): yield lock_dict else: for dataset_info in rucio.core.did.list_child_datasets( scope, name, session=session): dataset_scope, dataset_name = dataset_info[ "scope"], dataset_info["name"] for lock_dict in get_dataset_locks(dataset_scope, dataset_name, session=session): yield lock_dict
def perm_add_dids(issuer, kwargs): """ Checks if an account can bulk add data identifiers. :param issuer: Account identifier which issues the command. :param kwargs: List of arguments for the action. :returns: True if account is allowed, otherwise False """ # Check the accounts of the issued rules if issuer != 'root' and not has_account_attribute(account=issuer, key='admin'): for did in kwargs['dids']: for rule in did.get('rules', []): if rule['account'] != issuer: return False return issuer == 'root' or has_account_attribute(account=issuer, key='admin')