当前位置: 首页>>代码示例>>Python>>正文


Python Client.add_scope方法代码示例

本文整理汇总了Python中rucio.client.Client.add_scope方法的典型用法代码示例。如果您正苦于以下问题:Python Client.add_scope方法的具体用法?Python Client.add_scope怎么用?Python Client.add_scope使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在rucio.client.Client的用法示例。


在下文中一共展示了Client.add_scope方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: open

# 需要导入模块: from rucio.client import Client [as 别名]
# 或者: from rucio.client.Client import add_scope [as 别名]
from rucio.client import Client
from rucio.common.exception import Duplicate

if __name__ == '__main__':

    info = []
    f = open ('tools/atlas_accounts.csv')
#    f = open ('user_accounts.csv')
    for line in f.readlines():
        account, dn, email = line.rstrip().split('\t')
        info.append((account, dn, email))
    f.close()

    c = Client()
    for account, dn, email in info:
        try:
            c.add_account(account=account, type='USER')
        except Duplicate:
           print 'Account %(account)s already added' % locals()

        try:
            c.add_identity(account=account, identity=dn, authtype='X509', email=email , default=True)
        except Duplicate:
           print 'Identity %(account)s already added' % locals()

        try:
            scope = 'user.' + account
            c.add_scope(account, scope)
        except Duplicate:
           print 'Scope %(scope)s already added' % locals()
开发者ID:pombredanne,项目名称:rucio,代码行数:32,代码来源:sync_user_accounts.py

示例2: Research

# 需要导入模块: from rucio.client import Client [as 别名]
# 或者: from rucio.client.Client import add_scope [as 别名]
#!/usr/bin/env python
# Copyright European Organization for Nuclear Research (CERN)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#                       http://www.apache.org/licenses/LICENSE-2.0
#
# Authors:
# - Vincent Garonne, <[email protected]>, 2013

from rucio.client import Client
from rucio.common.exception import Duplicate

if __name__ == '__main__':

    scopes = []
    f = open ('tools/scopes.csv')
    for line in f.readlines():
        scope = line.rstrip()
        scopes.append(scope)
    f.close()

    c = Client()
    for scope in scopes:
        try:
            c.add_scope('ddmusr01', scope)
        except Duplicate:
           print 'Scope %(scope)s already added' % locals()
开发者ID:pombredanne,项目名称:rucio,代码行数:31,代码来源:sync_scopes.py

示例3: open

# 需要导入模块: from rucio.client import Client [as 别名]
# 或者: from rucio.client.Client import add_scope [as 别名]
# You may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#                       http://www.apache.org/licenses/LICENSE-2.0
#
# Authors:
# - Vincent Garonne, <[email protected]>, 2013

from rucio.client import Client
from rucio.common.exception import Duplicate

if __name__ == '__main__':

    info = []
    f = open ('tools/atlas_groups.csv')
    for line in f.readlines():
         group = line.rstrip()
         info.append(group)
    f.close()

    c = Client()
    for group in info:
        try:
            account = group.split('.')[1]
            c.add_account(account=account, type='GROUP')
        except Duplicate:
           print 'Account %(account)s already added' % locals()

        try:
            c.add_scope(account, scope=group)
        except Duplicate:
           print 'Scope %(group)s already added' % locals()
开发者ID:pombredanne,项目名称:rucio,代码行数:33,代码来源:sync_group_accounts.py

示例4: users

# 需要导入模块: from rucio.client import Client [as 别名]
# 或者: from rucio.client.Client import add_scope [as 别名]
            pass
        except Exception:
            errno, errstr = sys.exc_info()[:2]
            trcbck = traceback.format_exc()
            print "Interrupted processing with %s %s %s." % (errno, errstr, trcbck)
            sys.exit(CRITICAL)
        rses_total -= 1
    print "2. Adding %s artificial RSEs finished." % tmp

    # 3. Create known users
    tmp = users_total
    for user in known_users:
        print "Adding account %s" % user[0]
        try:
            c.add_account(user[0], user[1])
            c.add_scope(user[0], user[0])  # Adding default scope
        except Duplicate:
            print "User %s already exists" % user[0]
        users_total -= 1
    print "3. Adding %s known users finished." % (tmp - users_total)
    tmp = users_total
    # 4. Fill up DB to total number of Users
    while users_total:
        try:
            c.add_account("user%s" % users_total, "user")  # Adding user
            c.add_scope("user%s" % users_total, "user%s" % users_total)  # Adding default scope
        except Duplicate:
            print "User user%s already exists" % users_total
        users_total -= 1
    print "4. Adding %s artificial users (and default scopes) finished." % tmp
开发者ID:pombredanne,项目名称:rucio,代码行数:32,代码来源:bootstrap_stresstest.py

示例5: Client

# 需要导入模块: from rucio.client import Client [as 别名]
# 或者: from rucio.client.Client import add_scope [as 别名]
# Authors:
# - Vincent Garonne, <[email protected]>, 2013
# - Mario Lassnig, <[email protected]>, 2014

from rucio.client import Client
from rucio.common.exception import Duplicate

if __name__ == "__main__":
    c = Client()
    try:
        c.add_account("jdoe", "SERVICE")
    except Duplicate:
        print "Account jdoe already added" % locals()

    try:
        c.add_scope("jdoe", "mock")
    except Duplicate:
        print "Scope mock already added" % locals()

    # add your accounts here, if you test against CERN authed nodes
    additional_test_accounts = [
        (
            "/DC=ch/DC=cern/OU=Organic Units/OU=Users/CN=mlassnig/CN=663551/CN=Mario Lassnig",
            "x509",
            "[email protected]",
        ),
        (
            "/DC=ch/DC=cern/OU=Organic Units/OU=Users/CN=eliotiri/CN=756407/CN=Evangelia Liotiri",
            "x509",
            "[email protected]",
        ),
开发者ID:pombredanne,项目名称:rucio,代码行数:33,代码来源:bootstrap_tests.py

示例6: Client

# 需要导入模块: from rucio.client import Client [as 别名]
# 或者: from rucio.client.Client import add_scope [as 别名]
                 ('campaign', 'ALL', None, []),
                 ('guid', 'FILE', '^(\{){0,1}[0-9a-fA-F]{8}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{4}-?[0-9a-fA-F]{12}(\}){0,1}$', []),
                 ('events', 'DERIVED', '^\d+$', [])]

    c = Client()
    for key, key_type, value_regexp, values in meta_keys:
        try:
            try:
                c.add_key(key=key, key_type=key_type, value_regexp=value_regexp)
            except Duplicate:
                print '%(key)s already added' % locals()

            for value in values:

                try:
                    c.add_value(key=key, value=value)
                except Duplicate:
                    print '%(key)s:%(value)s already added' % locals()

                if key == 'project':
                    try:
                        c.add_scope('root', value)
                    except Duplicate:
                        print 'Scope %(value)s already added' % locals()
        except:
            errno, errstr = sys.exc_info()[:2]
            trcbck = traceback.format_exc()
            print 'Interrupted processing with %s %s %s.' % (errno, errstr, trcbck)

    sys.exit(OK)
开发者ID:pombredanne,项目名称:rucio,代码行数:32,代码来源:sync_meta.py


注:本文中的rucio.client.Client.add_scope方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。