Exemple #1
0
def whoami(account='natasha', auth_type='x509_proxy'):
    """Runs whoami command for a given account via client tool,
    requires a valid proxy
    """
    if args.password and args.username:
        creds = {'username': args.username, 'password': args.password}
        account_client = AccountClient(account=account,
                                       auth_type='userpass',
                                       creds=creds,
                                       rucio_host=args.host,
                                       auth_host=args.auth_host)
    else:
        account_client = AccountClient(account=account, auth_type='x509_proxy')
    print("Connected to rucio as %s" % account_client.whoami()['account'])
Exemple #2
0
 def setup(self):
     self.account_client = AccountClient()
     self.scope_client = ScopeClient()
     self.meta_client = MetaClient()
     self.did_client = DIDClient()
     self.replica_client = ReplicaClient()
     self.rse_client = RSEClient()
 def setUp(self):
     self.account = 'root'
     self.scope = 'mock'
     self.upload_client = UploadClient()
     self.account_client = AccountClient()
     self.file_sizes = 2
     self.rse = 'MOCK4'
     self.rse_id = get_rse(self.rse).id
     self.session = get_session()
Exemple #4
0
 def setUp(self):
     self.account = InternalAccount('root')
     self.scope = InternalScope('mock')
     self.upload_client = UploadClient()
     self.account_client = AccountClient()
     self.file_sizes = 2
     self.rse = 'MOCK4'
     self.rse_id = get_rse_id(self.rse)
     self.session = get_session()
Exemple #5
0
    def setUp(self):
        self.account_client = AccountClient()
        self.rse_client = RSEClient()

        self.account = generate_uuid()[:10]
        self.rse = rse_name_generator()

        self.account_client.add_account(self.account, 'SERVICE',
                                        '*****@*****.**')
        self.rse_client.add_rse(self.rse)
Exemple #6
0
def create_accounts(account_list, user_type):
    """ Registers a set of accounts

    :param account_list: the list of accounts to be added
    :param user_type: the type of accounts
    """
    account_client = AccountClient()
    for account in account_list:
        try:
            account_client.add_account(account, user_type, email=None)
        except exception.Duplicate:
            pass  # Account already exists, no need to create it
Exemple #7
0
    def setUp(self):
        if config_get_bool('common', 'multi_vo', raise_exception=False, default=False):
            self.vo = {'vo': config_get('client', 'vo', raise_exception=False, default='tst')}
        else:
            self.vo = {}

        self.account_client = AccountClient()
        self.scope_client = ScopeClient()
        self.meta_client = MetaClient()
        self.did_client = DIDClient()
        self.replica_client = ReplicaClient()
        self.rse_client = RSEClient()
Exemple #8
0
    def setUpClass(cls):
        cls.upload_client = UploadClient()
        cls.account_client = AccountClient()
        cls.session = get_session()

        if config_get_bool('common',
                           'multi_vo',
                           raise_exception=False,
                           default=False):
            cls.vo = {'vo': get_vo()}

        cls.account = InternalAccount('root', **cls.vo)
        cls.scope = InternalScope('mock', **cls.vo)
        cls.rse_id = get_rse_id(cls.rse, session=cls.session, **cls.vo)
Exemple #9
0
    def setUp(self):
        self.rse = 'MOCK4'
        self.file_sizes = 2
        self.upload_client = UploadClient()
        self.account_client = AccountClient()
        self.session = get_session()

        if config_get_bool('common', 'multi_vo', raise_exception=False, default=False):
            self.vo = {'vo': config_get('client', 'vo', raise_exception=False, default='tst')}
        else:
            self.vo = {}

        self.account = InternalAccount('root', **self.vo)
        self.scope = InternalScope('mock', **self.vo)
        self.rse_id = get_rse_id(self.rse, session=self.session, **self.vo)
Exemple #10
0
 def test_accounts_at_different_vos(self):
     """ MULTI VO (CLIENT): Test that accounts from 2nd vo don't interfere """
     account_client = AccountClient()
     usr_uuid = str(generate_uuid()).lower()[:16]
     tst = 'tst-%s' % usr_uuid
     new = 'new-%s' % usr_uuid
     shr = 'shr-%s' % usr_uuid
     account_client.add_account(tst, 'USER', '*****@*****.**')
     account_client.add_account(shr, 'USER', '*****@*****.**')
     add_account(new, 'USER', '*****@*****.**', 'root', **self.new_vo)
     add_account(shr, 'USER', '*****@*****.**', 'root', **self.new_vo)
     account_list_tst = [a['account'] for a in account_client.list_accounts()]
     account_list_new = [a['account'] for a in list_accounts(filter={}, **self.new_vo)]
     assert_true(tst in account_list_tst)
     assert_false(new in account_list_tst)
     assert_true(shr in account_list_tst)
     assert_false(tst in account_list_new)
     assert_true(new in account_list_new)
     assert_true(shr in account_list_new)
Exemple #11
0
 def setUp(self):
     self.account_client = AccountClient()
     self.scope_client = ScopeClient()
    size = 0
    adler32 = None
    n_events = 0
    for dbs_file in dbs_files:
        if dbs_file['file'][0]['name'] == filename:
            size = dbs_file['file'][0]['size']
            adler32 = dbs_file['file'][0]['adler32']
            n_events = dbs_file['file'][0]['nevents']
            break

    return size, adler32, n_events


if __name__ == '__main__':

    aClient = AccountClient(account='ewv', auth_type='x509_proxy')
    dClient = DIDClient(account='ewv', auth_type='x509_proxy')
    rClient = ReplicaClient(account='ewv', auth_type='x509_proxy')
    lClient = LifetimeClient(account='ewv', auth_type='x509_proxy')
    ruleClient = RuleClient(account='ewv', auth_type='x509_proxy')

    print("Connected to rucio as %s" % aClient.whoami()['account'])

    # Make Rucio container and dataset to correspond to CMS dataset

    try:
        print("Adding dataset %s" % RUCIO_CONTAINER)
        status = dClient.add_container(scope='cms', name=RUCIO_CONTAINER, lifetime=DAYS_TO_LIVE*24*3600)
        print(' Status for add_container', status)
    except DataIdentifierAlreadyExists:
        print('Container already exists')
Exemple #13
0
 def __init__(self):
     self.client = AccountClient()
Exemple #14
0
#!/usr/bin/env python
from __future__ import print_function
from multiprocessing import Pool
from rucio.client import Client
from rucio.client.accountclient import AccountClient
from rucio.client.accountlimitclient import AccountLimitClient

import getopt
import sys

rclient = Client()
accclient = AccountClient()
acclimitclient = AccountLimitClient()


def bytes_to_floored_tb(space):
    return space // (1000 * 1000 * 1000 * 1000)


def tb_to_bytes(space):
    return space * 1000 * 1000 * 1000 * 1000


MY_RSE = 'UNI-BONN_LOCALGROUPDISK'
MY_DEF_QUOTA = 10 * 1000 * 1000 * 1000 * 1000
MY_ADM_DEF_QUOTA = 50 * 1000 * 1000 * 1000 * 1000
DEF_IN_TB = bytes_to_floored_tb(MY_DEF_QUOTA)

BREATHE_SPACE_TB = 5
STEP_SPACE_TB = 10
Exemple #15
0
for user_record in cric_data:
    dn = user_record['DN']
    username = user_record['LOGIN']
    if dn in current_dns:
        new_accounts.add(username)
        identity_map[dn].add(username)

# And the email for each DN
for email, record in cric_users.items():
    if record['dn'] in current_dns:
        email_map[record['dn']] = email

# Now we have new_accounts which tells us which accounts to create
# and identity_map which tells us how to map the identites to those accounts

ac = AccountClient()

# Make all the accounts from this list
for account in new_accounts:
    try:
        print('Add account %s' % account)
        ac.add_account(account=account, type='USER', email=None)
    except (Duplicate, InvalidObject):
        print(' Account %s already exists or invalid' % account)

# Add all the identities to the list
for dn, accounts in identity_map.items():
    email = email_map.get(dn, '*****@*****.**')
    for account in accounts:
        try:
            print('Add identity %s for %s' % (dn, account))
def whoami(account='natasha', auth_type='x509_proxy'):
    """Runs whoami command for a given account via client tool,
    requires a valid proxy
    """
    account_client = AccountClient(account=account, auth_type='x509_proxy')
    print("Connected to rucio as %s" % account_client.whoami()['account'])
Exemple #17
0
 def setup(self):
     self.client = AccountClient()
     self.alclient = AccountLimitClient()
Exemple #18
0
from rucio.client import Client
from rucio.client.didclient import DIDClient
from rucio.client.replicaclient import ReplicaClient
from rucio.client.rseclient import RSEClient
from rucio.client.ruleclient import RuleClient
from rucio.client.accountclient import AccountClient

from rucio.common import exception

DID = namedtuple('DID', ['scope', 'name', 'ftype', 'owner', 'path', 'dataset'])

did_client = DIDClient()
rep_client = ReplicaClient()
rse_client = RSEClient()
rule_client = RuleClient()
admin_client = AccountClient()


def list_uk_localgroupdisks():
    """Return a list of known uk localgroup disks
    """
    global rse_client
    r = rse_client.list_rses(
        rse_expression='spacetoken=ATLASLOCALGROUPDISK&cloud=UK')
    return sorted(x['rse'] for x in r)


def get_rse_usage(rse, filters=None):
    return rse_client.get_rse_usage(rse, filters=filters)

Exemple #19
0
    def test_subscriptions_at_different_vos(self):
        """ MULTI VO (CLIENT): Test that subscriptions from 2nd vo don't interfere """

        account_client = AccountClient()
        usr_uuid = str(generate_uuid()).lower()[:16]
        shr_acc = 'shr-%s' % usr_uuid
        account_client.add_account(shr_acc, 'USER', '*****@*****.**')
        add_account(shr_acc, 'USER', '*****@*****.**', 'root', **self.new_vo)

        scope_client = ScopeClient()
        scope_uuid = str(generate_uuid()).lower()[:16]
        tst_scope = 'tst_%s' % scope_uuid
        new_scope = 'new_%s' % scope_uuid
        scope_client.add_scope('root', tst_scope)
        add_scope(new_scope, 'root', 'root', **self.new_vo)

        did_client = DIDClient()
        did_uuid = str(generate_uuid()).lower()[:16]
        tst_did = 'tstset_%s' % did_uuid
        new_did = 'newset_%s' % did_uuid

        rse_client = RSEClient()
        rse_str = ''.join(choice(ascii_uppercase) for x in range(10))
        tst_rse1 = 'TST1_%s' % rse_str
        tst_rse2 = 'TST2_%s' % rse_str
        new_rse1 = 'NEW1_%s' % rse_str
        new_rse2 = 'NEW2_%s' % rse_str
        rse_client.add_rse(tst_rse1)
        rse_client.add_rse(tst_rse2)
        add_rse(new_rse1, 'root', **self.new_vo)
        add_rse(new_rse2, 'root', **self.new_vo)

        acc_lim_client = AccountLimitClient()
        acc_lim_client.set_local_account_limit(shr_acc, tst_rse1, 10)
        acc_lim_client.set_local_account_limit(shr_acc, tst_rse2, 10)
        set_local_account_limit(shr_acc, new_rse1, 10, 'root', **self.new_vo)
        set_local_account_limit(shr_acc, new_rse2, 10, 'root', **self.new_vo)

        did_client.add_did(tst_scope, tst_did, 'DATASET', rse=tst_rse1)
        add_did(new_scope, new_did, 'DATASET', 'root', rse=new_rse1, **self.new_vo)

        sub_client = SubscriptionClient()
        sub_str = generate_uuid()
        tst_sub = 'tstsub_' + sub_str
        new_sub = 'newsub_' + sub_str
        shr_sub = 'shrsub_' + sub_str

        tst_sub_id = sub_client.add_subscription(tst_sub, shr_acc, {'scope': [tst_scope]},
                                                 [{'copies': 1, 'rse_expression': tst_rse2, 'weight': 0,
                                                   'activity': 'User Subscriptions'}],
                                                 '', None, 0, 0)
        shr_tst_sub_id = sub_client.add_subscription(shr_sub, shr_acc, {'scope': [tst_scope]},
                                                     [{'copies': 1, 'rse_expression': tst_rse2, 'weight': 0,
                                                       'activity': 'User Subscriptions'}],
                                                     '', None, 0, 0)

        new_sub_id = add_subscription(new_sub, shr_acc, {'scope': [new_scope]},
                                      [{'copies': 1, 'rse_expression': new_rse2, 'weight': 0, 'activity': 'User Subscriptions'}],
                                      '', False, 0, 0, 3, 'root', **self.new_vo)
        shr_new_sub_id = add_subscription(shr_sub, shr_acc, {'scope': [new_scope]},
                                          [{'copies': 1, 'rse_expression': new_rse2, 'weight': 0, 'activity': 'User Subscriptions'}],
                                          '', False, 0, 0, 3, 'root', **self.new_vo)

        tst_subs = [s['id'] for s in sub_client.list_subscriptions()]
        assert_in(tst_sub_id, tst_subs)
        assert_in(shr_tst_sub_id, tst_subs)
        assert_not_in(new_sub_id, tst_subs)
        assert_not_in(shr_new_sub_id, tst_subs)

        new_subs = [s['id'] for s in list_subscriptions(**self.new_vo)]
        assert_in(new_sub_id, new_subs)
        assert_in(shr_new_sub_id, new_subs)
        assert_not_in(tst_sub_id, new_subs)
        assert_not_in(shr_tst_sub_id, new_subs)

        shr_tst_subs = [s['id'] for s in sub_client.list_subscriptions(name=shr_sub)]
        assert_in(shr_tst_sub_id, shr_tst_subs)
        assert_not_in(shr_new_sub_id, shr_tst_subs)

        shr_new_subs = [s['id'] for s in list_subscriptions(name=shr_sub, **self.new_vo)]
        assert_in(shr_new_sub_id, shr_new_subs)
        assert_not_in(shr_tst_sub_id, shr_new_subs)

        acc_tst_subs = [s['id'] for s in sub_client.list_subscriptions(account=shr_acc)]
        assert_in(tst_sub_id, acc_tst_subs)
        assert_in(shr_tst_sub_id, acc_tst_subs)
        assert_not_in(new_sub_id, acc_tst_subs)
        assert_not_in(shr_new_sub_id, acc_tst_subs)

        acc_new_subs = [s['id'] for s in list_subscriptions(account=shr_acc, **self.new_vo)]
        assert_in(new_sub_id, acc_new_subs)
        assert_in(shr_new_sub_id, acc_new_subs)
        assert_not_in(tst_sub_id, acc_new_subs)
        assert_not_in(shr_tst_sub_id, acc_new_subs)
Exemple #20
0
 def __init__(self):
     self.account_client = AccountClient()
     self.scope_client = ScopeClient()
Exemple #21
0
 def setUp(self):
     self.client = AccountClient()
     self.alclient = AccountLimitClient()
     self.db_session.query(models.AccountLimit).delete()
     self.db_session.query(models.AccountGlobalLimit).delete()
     self.db_session.commit()
Exemple #22
0
 def setUp(self):
     self.client = AccountClient()