def test_access_rule_vo(self): """ MULTI VO (CORE): Test accessing rules from a different VO """ scope = InternalScope('mock', **self.vo) dataset = 'dataset_' + str(generate_uuid()) account = InternalAccount('root', **self.vo) rse_str = ''.join(choice(ascii_uppercase) for x in range(10)) rse_name = 'MOCK_%s' % rse_str rse_id = add_rse(rse_name, 'root', **self.vo) add_replica(rse_id=rse_id, scope=scope, name=dataset, bytes=10, account=account) rule_id = add_rule(dids=[{'scope': scope, 'name': dataset}], account=account, copies=1, rse_expression='MOCK', grouping='NONE', weight='fakeweight', lifetime=None, locked=False, subscription_id=None)[0] with assert_raises(AccessDenied): delete_replication_rule(rule_id=rule_id, purge_replicas=False, issuer='root', **self.new_vo) # check locks are not accessible from other VO locks = list(get_replica_locks_for_rule_id(rule_id, **self.vo)) assert_equal(len(locks), 1) locks = list(get_replica_locks_for_rule_id(rule_id, **self.new_vo)) assert_equal(len(locks), 0) delete_replication_rule(rule_id=rule_id, purge_replicas=False, issuer='root', **self.vo) rule_dict = get_replication_rule(rule_id=rule_id, issuer='root', **self.vo) assert_is_not_none(rule_dict['expires_at'])
def GET(self, rule_id): """ get locks for a given rule_id. HTTP Success: 200 OK HTTP Error: 404 Not Found 500 InternalError :returns: JSON dict containing informations about the requested user. """ header('Content-Type', 'application/x-json-stream') try: locks = get_replica_locks_for_rule_id(rule_id) except RucioException, e: raise generate_http_error(500, e.__class__.__name__, e.args[0])
def GET(self, rule_id): """ get locks for a given rule_id. HTTP Success: 200 OK HTTP Error: 404 Not Found 500 InternalError :returns: JSON dict containing informations about the requested user. """ header('Content-Type', 'application/x-json-stream') try: locks = get_replica_locks_for_rule_id(rule_id) except RucioException as error: raise generate_http_error(500, error.__class__.__name__, error.args[0]) except Exception as error: raise InternalError(error) for lock in locks: yield dumps(lock, cls=APIEncoder) + '\n'
def get(self, rule_id): """ get locks for a given rule_id. .. :quickref: ReplicaLocks; get locks by rule id :status 200: Rule found :status 406: Not Acceptable :status 500: Database Exception :returns: JSON dict containing informations about the requested user. """ try: locks = get_replica_locks_for_rule_id(rule_id) except RucioException as error: return generate_http_error_flask(500, error.__class__.__name__, error.args[0]) except Exception as error: return error, 500 data = "" for lock in locks: data += dumps(lock, cls=APIEncoder) + '\n' return Response(data, content_type="application/x-json-stream")
def generate(vo): for lock in get_replica_locks_for_rule_id(rule_id, vo=vo): yield render_json(**lock) + '\n'