예제 #1
0
    def post(self, vo):
        """ Add a VO with a given name.

        .. :quickref: VO; Add a VOs.

        :param vo: VO to be added.
        :<json string description: Desciption of VO.
        :<json string email: Admin email for VO.
        :status 201: VO created successfully.
        :status 401: Invalid Auth Token.
        :status 409: Unsupported operation.
        """
        parameters = json_parameters(optional=True)
        kwargs = {'description': None, 'email': None}
        for keyword in kwargs.keys():
            kwargs[keyword] = param_get(parameters, keyword, default=kwargs[keyword])
        kwargs['issuer'] = request.environ.get('issuer')
        kwargs['vo'] = request.environ.get('vo')

        try:
            add_vo(new_vo=vo, **kwargs)
        except AccessDenied as error:
            return generate_http_error_flask(401, error)
        except (UnsupportedOperation, Duplicate) as error:
            return generate_http_error_flask(409, error)

        return 'Created', 201
예제 #2
0
    def POST(self, new_vo):
        ''' Add a VO with a given name. '''

        json_data = data()
        kwargs = {'description': None, 'email': None}

        try:
            parameters = json_data and loads(json_data)
            if parameters:
                for param in kwargs:
                    if param in parameters:
                        kwargs[param] = parameters[param]
        except ValueError:
            raise generate_http_error(400, 'ValueError', 'Cannot decode json parameter dictionary')
        kwargs['issuer'] = ctx.env.get('issuer')
        kwargs['vo'] = ctx.env.get('vo')

        try:
            add_vo(new_vo=new_vo, **kwargs)
        except RucioException as error:
            raise generate_http_error(500, error.__class__.__name__, error.args[0])
        except Exception as error:
            print(error)
            print(format_exc())
            raise InternalError(error)

        raise Created()
예제 #3
0
파일: vo.py 프로젝트: stfc/rucio
    def post(self, vo):
        """ Add a VO with a given name.

        .. :quickref: VO; Add a VOs.

        :param vo: VO to be added.
        :<json string description: Desciption of VO.
        :<json string email: Admin email for VO.
        :status 201: VO created successfully.
        :status 401: Invalid Auth Token.
        :status 409: Unsupported operation.
        :status 500: Internal Error.

        """
        json_data = request.data.decode()
        kwargs = {'description': None, 'email': None}

        try:
            parameters = json_data and loads(json_data)
            if parameters:
                for param in kwargs:
                    if param in parameters:
                        kwargs[param] = parameters[param]
        except ValueError:
            return generate_http_error_flask(
                400, 'ValueError', 'Cannot decode json parameter dictionary')
        kwargs['issuer'] = request.environ.get('issuer')
        kwargs['vo'] = request.environ.get('vo')

        try:
            add_vo(new_vo=vo, **kwargs)
        except AccessDenied as error:
            return generate_http_error_flask(401, 'AccessDenied',
                                             error.args[0])
        except UnsupportedOperation as error:
            return generate_http_error_flask(409, 'UnsupportedOperation',
                                             error.args[0])
        except Duplicate as error:
            return generate_http_error_flask(409, 'Duplicate', error.args[0])
        except RucioException as error:
            return generate_http_error_flask(500, error.__class__.__name__,
                                             error.args[0])
        except Exception as error:
            print(format_exc())
            return str(error), 500

        return 'Created', 201
예제 #4
0
    def POST(self, new_vo):
        """ Add a VO with a given name.

        HTTP Success:
            201 Created

        HTTP Error:
            401 Unauthorized
            409 Conflict
            500 InternalError

        :param new_vo: VO to be added.
        """
        json_data = data().decode()
        kwargs = {'description': None, 'email': None}

        try:
            parameters = json_data and loads(json_data)
            if parameters:
                for param in kwargs:
                    if param in parameters:
                        kwargs[param] = parameters[param]
        except ValueError:
            raise generate_http_error(400, 'ValueError', 'Cannot decode json parameter dictionary')
        kwargs['issuer'] = ctx.env.get('issuer')
        kwargs['vo'] = ctx.env.get('vo')

        try:
            add_vo(new_vo=new_vo, **kwargs)
        except AccessDenied as error:
            raise generate_http_error(401, 'AccessDenied', error.args[0])
        except UnsupportedOperation as error:
            raise generate_http_error(409, 'UnsupportedOperation', error.args[0])
        except Duplicate as error:
            raise generate_http_error(409, 'Duplicate', error.args[0])
        except RucioException as error:
            raise generate_http_error(500, error.__class__.__name__, error.args[0])
        except Exception as error:
            print(error)
            print(format_exc())
            raise InternalError(error)

        raise Created()
예제 #5
0
파일: vo_tests.py 프로젝트: ijjorama/rucio
from rucio.api.vo import add_vo, list_vos
from rucio.client import Client
from rucio.common.config import config_get_bool
from rucio.common.exception import Duplicate
from rucio.core.account import add_account_attribute
from rucio.common.types import InternalAccount

if __name__ == '__main__':
    if config_get_bool('common',
                       'multi_vo',
                       raise_exception=False,
                       default=False):

        voname = 'tst'
        vo = {'vo': voname}
        issuer = 'super_root'
        add_vo(new_vo=vo['vo'],
               issuer=issuer,
               password='******',
               description='A VO to test multi-vo features',
               email='N/A',
               vo='def')
        print('Added VO tst OK')

        for eachvo in list_vos(issuer=issuer, vo='def'):
            if eachvo['vo'] != 'def':
                print("vo = {vo}, description={description}".format(
                    vo=eachvo['vo'], description=eachvo['description']))
    else:
        vo = {}
예제 #6
0
if __name__ == '__main__':
    if config_get_bool('common',
                       'multi_vo',
                       raise_exception=False,
                       default=False):
        vo = {
            'vo': config_get('client',
                             'vo',
                             raise_exception=False,
                             default='tst')
        }
        try:
            add_vo(new_vo=vo['vo'],
                   issuer='super_root',
                   description='A VO to test multi-vo features',
                   email='N/A',
                   vo='def')
        except Duplicate:
            print('VO {} already added'.format(vo['vo']) % locals())
    else:
        vo = {}

    c = Client()
    try:
        c.add_account('jdoe', 'SERVICE', '*****@*****.**')
    except Duplicate:
        print('Account jdoe already added' % locals())

    try:
        add_account_attribute(
예제 #7
0
 def test_add_vo(self):
     """ MULTI VO (CORE): Test creation of VOs """
     with assert_raises(AccessDenied):
         vo_api.add_vo(self.new_vo['vo'], 'root', 'Add new VO with root', '*****@*****.**', **self.vo)
     with assert_raises(Duplicate):
         vo_api.add_vo(self.new_vo['vo'], 'super_root', 'Add existing VO', '*****@*****.**', 'def')