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


Python AuthProvider.get_access_data方法代码示例

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


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

示例1: setUpClass

# 需要导入模块: from cloudcafe.auth.provider import AuthProvider [as 别名]
# 或者: from cloudcafe.auth.provider.AuthProvider import get_access_data [as 别名]
    def setUpClass(cls):
        super(ComputeFixture, cls).setUpClass()
        cls.flavors_config = FlavorsConfig()
        cls.images_config = ImagesConfig()
        cls.servers_config = ServersConfig()
        cls.compute_endpoint = ComputeEndpointConfig()
        cls.marshalling = MarshallingConfig()

        cls.flavor_ref = cls.flavors_config.primary_flavor
        cls.flavor_ref_alt = cls.flavors_config.secondary_flavor
        cls.image_ref = cls.images_config.primary_image
        cls.image_ref_alt = cls.images_config.secondary_image
        cls.disk_path = cls.servers_config.instance_disk_path

        cls.endpoint_config = UserAuthConfig()
        cls.user_config = UserConfig()
        access_data = AuthProvider.get_access_data(cls.endpoint_config,
                                                   cls.user_config)
        compute_service = access_data.get_service(
            cls.compute_endpoint.compute_endpoint_name)
        url = compute_service.get_endpoint(
            cls.compute_endpoint.region).public_url
        # If a url override was provided, use that value instead
        if cls.compute_endpoint.compute_endpoint_url:
            url = '{0}/{1}'.format(cls.compute_endpoint.compute_endpoint_url,
                                   cls.user_config.tenant_id)

        cls.flavors_client = FlavorsClient(url, access_data.token.id_,
                                           cls.marshalling.serializer,
                                           cls.marshalling.deserializer)
        cls.servers_client = ServersClient(url, access_data.token.id_,
                                           cls.marshalling.serializer,
                                           cls.marshalling.deserializer)
        cls.images_client = ImagesClient(url, access_data.token.id_,
                                         cls.marshalling.serializer,
                                         cls.marshalling.deserializer)
        cls.keypairs_client = KeypairsClient(url, access_data.token.id_,
                                             cls.marshalling.serializer,
                                             cls.marshalling.deserializer)
        cls.security_groups_client = SecurityGroupsClient(
            url, access_data.token.id_, cls.marshalling.serializer,
            cls.marshalling.deserializer)
        cls.security_group_rule_client = SecurityGroupRulesClient(
            url, access_data.token.id_, cls.marshalling.serializer,
            cls.marshalling.deserializer)
        cls.rescue_client = RescueClient(url, access_data.token.id_,
                                         cls.marshalling.serializer,
                                         cls.marshalling.deserializer)
        cls.vnc_client = VncConsoleClient(url, access_data.token.id_,
                                         cls.marshalling.serializer,
                                         cls.marshalling.deserializer)
        cls.server_behaviors = ServerBehaviors(cls.servers_client,
                                               cls.servers_config,
                                               cls.images_config,
                                               cls.flavors_config)
        cls.image_behaviors = ImageBehaviors(cls.images_client,
                                             cls.servers_client,
                                             cls.images_config)
        cls.flavors_client.add_exception_handler(ExceptionHandler())
        cls.resources = ResourcePool()
开发者ID:CharlesKimpolo,项目名称:cloudroast,代码行数:62,代码来源:fixtures.py

示例2: setUpClass

# 需要导入模块: from cloudcafe.auth.provider import AuthProvider [as 别名]
# 或者: from cloudcafe.auth.provider.AuthProvider import get_access_data [as 别名]
    def setUpClass(cls):
        super(ComputeAdminFixture, cls).setUpClass()

        # Setup admin client
        auth_config = ComputeAdminAuthConfig()
        user_config = ComputeAdminUserConfig()
        access_data = AuthProvider.get_access_data(auth_config,
                                                   user_config)
        admin_endpoint_config = ComputeAdminEndpointConfig()
        compute_service = access_data.get_service(
            admin_endpoint_config.compute_endpoint_name)
        url = compute_service.get_endpoint(
            admin_endpoint_config.region).public_url

        client_args = {'url': url, 'auth_token': access_data.token.id_,
                       'serialize_format': cls.marshalling.serializer,
                       'deserialize_format': cls.marshalling.deserializer}

        cls.admin_flavors_client = FlavorsClient(**client_args)
        cls.admin_servers_client = ServersClient(**client_args)
        cls.admin_images_client = ImagesClient(**client_args)
        cls.admin_hosts_client = HostsClient(**client_args)
        cls.admin_quotas_client = QuotasClient(**client_args)
        cls.admin_hypervisors_client = HypervisorsClient(**client_args)
        cls.admin_server_behaviors = ServerBehaviors(
            servers_client=cls.admin_servers_client,
            images_client=cls.images_client, servers_config=cls.servers_config,
            images_config=cls.images_config, flavors_config=cls.flavors_config)
        cls.admin_images_behaviors = ImageBehaviors(cls.admin_images_client,
                                                    cls.admin_servers_client,
                                                    cls.images_config)
        cls.admin_servers_client.add_exception_handler(ExceptionHandler())
开发者ID:nand0416,项目名称:cloudroast,代码行数:34,代码来源:fixtures.py

示例3: setUpClass

# 需要导入模块: from cloudcafe.auth.provider import AuthProvider [as 别名]
# 或者: from cloudcafe.auth.provider.AuthProvider import get_access_data [as 别名]
    def setUpClass(cls):
        super(AuthorizationTests, cls).setUpClass()
        cls.metadata = {'meta_key_1': 'meta_value_1',
                        'meta_key_2': 'meta_value_2'}
        cls.server = cls.server_behaviors.create_active_server(
            metadata=cls.metadata).entity
        cls.resources.add(cls.server.id, cls.servers_client.delete_server)

        image_name = rand_name('testimage')
        cls.image_meta = {'key1': 'value1', 'key2': 'value2'}
        image_resp = cls.servers_client.create_image(cls.server.id,
                                                     image_name,
                                                     cls.image_meta)
        assert image_resp.status_code == 202
        cls.image_id = cls.parse_image_id(image_resp)
        cls.image_behaviors.wait_for_image_status(
            cls.image_id, NovaImageStatusTypes.ACTIVE)
        cls.resources.add(cls.image_id, cls.images_client.delete_image)

        secondary_user = ComputeAuthorizationConfig()
        access_data = AuthProvider.get_access_data(cls.endpoint_config,
                                                   secondary_user)

        compute_service = access_data.get_service(
            cls.compute_endpoint.compute_endpoint_name)
        url = compute_service.get_endpoint(
            cls.compute_endpoint.region).public_url

        cls.flavors_client = FlavorsClient(url, access_data.token.id_,
                                           'json', 'json')
        cls.servers_client = ServersClient(url, access_data.token.id_,
                                           'json', 'json')
        cls.images_client = ImagesClient(url, access_data.token.id_,
                                         'json', 'json')
        cls.flavors_client.add_exception_handler(ExceptionHandler())
开发者ID:cjoelrun,项目名称:cloudroast,代码行数:37,代码来源:test_authorization.py

示例4: setUpClass

# 需要导入模块: from cloudcafe.auth.provider import AuthProvider [as 别名]
# 或者: from cloudcafe.auth.provider.AuthProvider import get_access_data [as 别名]
    def setUpClass(cls):
        super(ObjectStorageFixture, cls).setUpClass()

        endpoint_config = UserAuthConfig()
        user_config = UserConfig()
        objectstorage_config = ObjectStorageConfig()
        objectstorage_api_config = ObjectStorageAPIConfig()

        auth_provider = AuthProvider()
        access_data = auth_provider.get_access_data(
            endpoint_config,
            user_config)

        service = access_data.get_service(
            objectstorage_config.identity_service_name)

        endpoint = service.get_endpoint(objectstorage_config.region)
        storage_url = endpoint.public_url
        auth_token = access_data.token.id_

        cls.base_container_name = objectstorage_api_config.base_container_name
        cls.base_object_name = objectstorage_api_config.base_object_name

        cls.client = ObjectStorageAPIClient(
                storage_url,
                auth_token)

        cls.behaviors = ObjectStorageAPI_Behaviors(client=cls.client)
开发者ID:CharlesKimpolo,项目名称:cloudroast,代码行数:30,代码来源:fixtures.py

示例5: setUpClass

# 需要导入模块: from cloudcafe.auth.provider import AuthProvider [as 别名]
# 或者: from cloudcafe.auth.provider.AuthProvider import get_access_data [as 别名]
    def setUpClass(cls):
        """
        Initialize autoscale configs, behaviors and client
        """
        super(AutoscaleFixture, cls).setUpClass()
        cls.resources = ResourcePool()
        cls.autoscale_config = AutoscaleConfig()
        cls.endpoint_config = UserAuthConfig()
        user_config = UserConfig()
        access_data = AuthProvider.get_access_data(cls.endpoint_config,
                                                   user_config)

        autoscale_service = access_data.get_service(
            cls.autoscale_config.autoscale_endpoint_name)

        server_service = access_data.get_service(
            cls.autoscale_config.server_endpoint_name)
        server_url = server_service.get_endpoint(
            cls.autoscale_config.region).public_url

        cls.tenant_id = cls.autoscale_config.tenant_id
        env = os.environ['OSTNG_CONFIG_FILE']
        if 'dev' in env.lower():
            url = 'http://localhost:9000/v1.0/{0}'.format(cls.tenant_id)
        elif 'prod' in env.lower():
            url = 'https://autoscale.api.rackspacecloud.com/v1.0/{0}'.format(
                cls.tenant_id)
        else:
            url = autoscale_service.get_endpoint(
                cls.autoscale_config.region).public_url

        cls.autoscale_client = AutoscalingAPIClient(
            url, access_data.token.id_,
            'json', 'json')
        cls.server_client = ServersClient(
            server_url, access_data.token.id_,
            'json', 'json')
        cls.autoscale_behaviors = AutoscaleBehaviors(cls.autoscale_config,
                                                     cls.autoscale_client)
        cls.gc_name = cls.autoscale_config.gc_name
        cls.gc_cooldown = int(cls.autoscale_config.gc_cooldown)
        cls.gc_min_entities = int(cls.autoscale_config.gc_min_entities)
        cls.gc_min_entities_alt = int(cls.autoscale_config.gc_min_entities_alt)
        cls.gc_max_entities = int(cls.autoscale_config.gc_max_entities)
        cls.lc_name = cls.autoscale_config.lc_name
        cls.lc_flavor_ref = cls.autoscale_config.lc_flavor_ref
        cls.lc_image_ref = cls.autoscale_config.lc_image_ref
        cls.lc_image_ref_alt = cls.autoscale_config.lc_image_ref_alt
        cls.sp_name = rand_name(cls.autoscale_config.sp_name)
        cls.sp_cooldown = int(cls.autoscale_config.sp_cooldown)
        cls.sp_change = int(cls.autoscale_config.sp_change)
        cls.sp_change_percent = int(cls.autoscale_config.sp_change_percent)
        cls.sp_desired_capacity = int(cls.autoscale_config.sp_desired_capacity)
        cls.sp_policy_type = cls.autoscale_config.sp_policy_type
        cls.upd_sp_change = int(cls.autoscale_config.upd_sp_change)
        cls.lc_load_balancers = cls.autoscale_config.lc_load_balancers
        cls.sp_list = cls.autoscale_config.sp_list
        cls.wb_name = rand_name(cls.autoscale_config.wb_name)
        cls.interval_time = int(cls.autoscale_config.interval_time)
        cls.timeout = int(cls.autoscale_config.timeout)
开发者ID:apurvvkumaria,项目名称:otter,代码行数:62,代码来源:fixtures.py

示例6: get_auth_data

# 需要导入模块: from cloudcafe.auth.provider import AuthProvider [as 别名]
# 或者: from cloudcafe.auth.provider.AuthProvider import get_access_data [as 别名]
    def get_auth_data():
        """
        Authenticate and return a dictionary containing the storage url and
        auth token.
        """
        result = {
            'storage_url': None,
            'auth_token': None}

        endpoint_config = UserAuthConfig()
        user_config = UserConfig()
        objectstorage_config = ObjectStorageConfig()
        auth_provider = AuthProvider()
        access_data = auth_provider.get_access_data(
            endpoint_config, user_config)

        if endpoint_config.strategy.lower() == 'saio_tempauth':
            result['storage_url'] = access_data.storage_url
            result['auth_token'] = access_data.auth_token
        else:
            service = access_data.get_service(
                objectstorage_config.identity_service_name)
            endpoint = service.get_endpoint(objectstorage_config.region)
            result['storage_url'] = endpoint.public_url
            result['auth_token'] = access_data.token.id_

        return result
开发者ID:ProjectMeniscus,项目名称:cloudroast,代码行数:29,代码来源:fixtures.py

示例7: setUpClass

# 需要导入模块: from cloudcafe.auth.provider import AuthProvider [as 别名]
# 或者: from cloudcafe.auth.provider.AuthProvider import get_access_data [as 别名]
    def setUpClass(cls):
        super(ComputeAdminFixture, cls).setUpClass()

        # Setup admin client
        auth_config = ComputeAdminAuthConfig()
        user_config = ComputeAdminUserConfig()
        access_data = AuthProvider.get_access_data(auth_config,
                                                   user_config)
        admin_endpoint_config = ComputeAdminEndpointConfig()
        compute_service = access_data.get_service(
            admin_endpoint_config.compute_endpoint_name)
        url = compute_service.get_endpoint(
            admin_endpoint_config.region).public_url
        cls.admin_flavors_client = FlavorsClient(url, access_data.token.id_,
                                                 'json', 'json')
        cls.admin_servers_client = ServersClient(url, access_data.token.id_,
                                                 'json', 'json')
        cls.admin_server_behaviors = ServerBehaviors(cls.admin_servers_client,
                                                     cls.servers_config,
                                                     cls.images_config,
                                                     cls.flavors_config)
        cls.admin_images_client = ImagesClient(url, access_data.token.id_,
                                               'json', 'json')
        cls.admin_images_behaviors = ImageBehaviors(cls.admin_images_client,
                                                    cls.admin_servers_client,
                                                    cls.images_config)
        cls.admin_hosts_client = HostsClient(url, access_data.token.id_,
                                             'json', 'json')
        cls.admin_servers_client.add_exception_handler(ExceptionHandler())
开发者ID:john5223,项目名称:cloudroast,代码行数:31,代码来源:fixtures.py

示例8: setUpClass

# 需要导入模块: from cloudcafe.auth.provider import AuthProvider [as 别名]
# 或者: from cloudcafe.auth.provider.AuthProvider import get_access_data [as 别名]
    def setUpClass(cls):
        super(ComputeFixture, cls).setUpClass()
        cls.flavors_config = FlavorsConfig()
        cls.images_config = ImagesConfig()
        cls.servers_config = ServersConfig()
        cls.compute_endpoint = ComputeEndpointConfig()
        cls.marshalling = MarshallingConfig()
        cls.config_drive_config = ConfigDriveConfig()

        cls.flavor_ref = cls.flavors_config.primary_flavor
        cls.flavor_ref_alt = cls.flavors_config.secondary_flavor
        cls.image_ref = cls.images_config.primary_image
        cls.image_ref_alt = cls.images_config.secondary_image
        cls.disk_path = cls.servers_config.instance_disk_path

        cls.endpoint_config = UserAuthConfig()
        cls.user_config = UserConfig()
        access_data = AuthProvider.get_access_data(cls.endpoint_config,
                                                   cls.user_config)
        # If authentication fails, halt
        if access_data is None:
            cls.assertClassSetupFailure('Authentication failed.')

        compute_service = access_data.get_service(
            cls.compute_endpoint.compute_endpoint_name)
        url = compute_service.get_endpoint(
            cls.compute_endpoint.region).public_url
        # If a url override was provided, use that value instead
        if cls.compute_endpoint.compute_endpoint_url:
            url = '{0}/{1}'.format(cls.compute_endpoint.compute_endpoint_url,
                                   cls.user_config.tenant_id)

        client_args = {'url': url, 'auth_token': access_data.token.id_,
                       'serialize_format': cls.marshalling.serializer,
                       'deserialize_format': cls.marshalling.deserializer}

        cls.flavors_client = FlavorsClient(**client_args)
        cls.servers_client = ServersClient(**client_args)
        cls.images_client = ImagesClient(**client_args)
        cls.keypairs_client = KeypairsClient(**client_args)
        cls.security_groups_client = SecurityGroupsClient(**client_args)
        cls.security_group_rule_client = SecurityGroupRulesClient(
            **client_args)
        cls.rescue_client = RescueClient(**client_args)
        cls.vnc_client = VncConsoleClient(**client_args)
        cls.console_output_client = ConsoleOutputClient(**client_args)
        cls.server_behaviors = ServerBehaviors(cls.servers_client,
                                               cls.servers_config,
                                               cls.images_config,
                                               cls.flavors_config)
        cls.image_behaviors = ImageBehaviors(cls.images_client,
                                             cls.servers_client,
                                             cls.images_config)
        cls.config_drive_behaviors = ConfigDriveBehaviors(cls.servers_client,
                                                          cls.servers_config,
                                                          cls.server_behaviors)
        cls.flavors_client.add_exception_handler(ExceptionHandler())
        cls.resources = ResourcePool()
开发者ID:ProjectMeniscus,项目名称:cloudroast,代码行数:60,代码来源:fixtures.py

示例9: _set_up_clients

# 需要导入模块: from cloudcafe.auth.provider import AuthProvider [as 别名]
# 或者: from cloudcafe.auth.provider.AuthProvider import get_access_data [as 别名]
def _set_up_clients():
    """
    Read the user creds from the configuration file in and constructs all the
    service clients.  If it can't authenticate, or it cannot construct the
    autoscale/server/lbaas clients, then it fails.

    The RCv3 client is not created if the account does not have access to RCv3
    or if RCv3 configuration parameters are not present or invalid.
    """
    user_config = UserConfig()
    access_data = AuthProvider.get_access_data(endpoint_config, user_config)

    if access_data is None:
        raise Exception(
            "Unable to authenticate against identity to get auth token and "
            "service catalog.")

    _autoscale_client = _make_client(
        access_data,
        autoscale_config.autoscale_endpoint_name,
        autoscale_config.region,
        AutoscalingAPIClient,
        "Autoscale")

    _server_client = _make_client(
        access_data,
        autoscale_config.server_endpoint_name,
        autoscale_config.server_region_override or autoscale_config.region,
        ServersClient,
        "Nova Compute")

    _lbaas_client = _make_client(
        access_data,
        autoscale_config.load_balancer_endpoint_name,
        autoscale_config.lbaas_region_override or autoscale_config.region,
        LbaasAPIClient,
        "Cloud Load Balancers")

    _rcv3_client = None
    if _rcv3_cloud_network and _rcv3_load_balancer_pool:
        _rcv3_client = _make_client(
            access_data,
            autoscale_config.rcv3_endpoint_name,
            autoscale_config.rcv3_region_override or autoscale_config.region,
            RackConnectV3APIClient,
            "RackConnect v3")
    else:
        print("Not enough test configuration for RCv3 provided. "
              "Will not run RCv3 tests.")

    if not all([x is not None for x in (_autoscale_client, _server_client,
                                        _lbaas_client)]):
        raise Exception(
            "Unable to instantiate all necessary clients.")

    return (_autoscale_client, _server_client, _lbaas_client, _rcv3_client)
开发者ID:pratikmallya,项目名称:otter,代码行数:58,代码来源:fixtures.py

示例10: setUpClass

# 需要导入模块: from cloudcafe.auth.provider import AuthProvider [as 别名]
# 或者: from cloudcafe.auth.provider.AuthProvider import get_access_data [as 别名]
    def setUpClass(cls):
        super(ImagesFixture, cls).setUpClass()
        cls.marshalling = MarshallingConfig()
        cls.images_config = ImagesConfig()
        cls.primary_image = cls.images_config.primary_image

        cls.endpoint_config = UserAuthConfig()
        cls.user_config = UserConfig()
        cls.access_data = AuthProvider.get_access_data(cls.endpoint_config, cls.user_config)
        # If authentication fails, halt
        if cls.access_data is None:
            cls.assertClassSetupFailure("Authentication failed.")

        image_service = cls.access_data.get_service(cls.images_config.endpoint_name)
        url = image_service.get_endpoint(cls.images_config.region).public_url + "/v2"
        client_args = {
            "base_url": url,
            "auth_token": cls.access_data.token.id_,
            "serialize_format": cls.marshalling.serializer,
            "deserialize_format": cls.marshalling.deserializer,
        }
        cls.images_client = ImagesClient(**client_args)

        cls.alt_user_config = AltUserConfig()
        cls.alt_access_data = AuthProvider.get_access_data(cls.endpoint_config, cls.alt_user_config)

        # If authentication fails, halt
        if cls.alt_access_data is None:
            cls.assertClassSetupFailure("Authentication failed.")
        image_service = cls.alt_access_data.get_service(cls.images_config.endpoint_name)
        url = image_service.get_endpoint(cls.images_config.region).public_url + "/v2"
        client_args = {
            "base_url": url,
            "auth_token": cls.alt_access_data.token.id_,
            "serialize_format": cls.marshalling.serializer,
            "deserialize_format": cls.marshalling.deserializer,
        }
        cls.alt_images_client = ImagesClient(**client_args)
        cls.alt_tenant_id = cls.alt_access_data.token.tenant.id_
        cls.resources = ResourcePool()
        cls.addClassCleanup(cls.resources.release)
开发者ID:jcourtois,项目名称:glanceroast,代码行数:43,代码来源:fixtures.py

示例11: setUpClass

# 需要导入模块: from cloudcafe.auth.provider import AuthProvider [as 别名]
# 或者: from cloudcafe.auth.provider.AuthProvider import get_access_data [as 别名]
    def setUpClass(cls):
        super(ImagesV2Fixture, cls).setUpClass()
        cls.config = ImagesConfig()
        cls.resources = ResourcePool()

        access_data = AuthProvider.get_access_data()

        cls.images_endpoint = '{base_url}/v2'.format(
            base_url=cls.config.base_url)

        cls.api_client = ImagesV2Client(cls.images_endpoint,
                                        access_data.token.id_,
                                        'json', 'json')
开发者ID:MUSABALOYI,项目名称:cloudroast,代码行数:15,代码来源:fixtures.py

示例12: get_auth_token

# 需要导入模块: from cloudcafe.auth.provider import AuthProvider [as 别名]
# 或者: from cloudcafe.auth.provider.AuthProvider import get_access_data [as 别名]
def get_auth_token():
    '''
    * This method is to retrieve the User Auth Token from Identity
    * The credentials will be read from a config file
    * Inputs: None
    * Returns: the Auth Token ( a string of letters and numbers)
    '''
    end_config = UserAuthConfig()

    user_config = UserConfig()
    access_data = AuthProvider.get_access_data(end_config, user_config)

    return  access_data.token.id_
开发者ID:rackerlabs,项目名称:phoenixcafe,代码行数:15,代码来源:helpers.py

示例13: authenticate

# 需要导入模块: from cloudcafe.auth.provider import AuthProvider [as 别名]
# 或者: from cloudcafe.auth.provider.AuthProvider import get_access_data [as 别名]
    def authenticate(cls, username=None, password=None):
        """ Should only be called from an instance of AuthComposite """
        if username and password:
            client = TokenAPI_Client(
                UserAuthConfig().auth_endpoint,
                serialize_format="json",
                deserialize_format="json")
            access_data = client.authenticate(
                username=username,
                password=password).entity
        else:
            access_data = AuthProvider.get_access_data()

        if access_data is None:
            raise AssertionError('Authentication failed in setup')

        return access_data
开发者ID:rgeethapriya,项目名称:cloudroast,代码行数:19,代码来源:fixtures.py

示例14: generate_user_list

# 需要导入模块: from cloudcafe.auth.provider import AuthProvider [as 别名]
# 或者: from cloudcafe.auth.provider.AuthProvider import get_access_data [as 别名]
    def generate_user_list(cls, account_list):
        """
        @summary: Generates list of users containing access_data, account
        types, behaviors, clients, and configurations
        """

        cls.ACCESS_DATA = "access_data"
        cls.BEHAVIOR = "behavior"
        cls.CLIENT = "client"
        cls.CONFIG = "config"
        user_list = dict()
        for user in account_list:
            user_list[user] = dict()
            user_list[user][cls.CONFIG] = UserConfig(section_name=user)
            user_list[user][cls.CONFIG].SECTION_NAME = user

            access_data = AuthProvider.get_access_data(
                cls.endpoint_config,
                user_config=user_list[user][cls.CONFIG])
            # If authentication fails, fail immediately
            if access_data is None:
                cls.assertClassSetupFailure('Authentication failed.')
            user_list[user][cls.ACCESS_DATA] = access_data

            images_service = access_data.get_service(
                cls.images_config.endpoint_name)
            images_url_check = images_service.get_endpoint(
                cls.images_config.region)
            # If endpoint validation fails, fail immediately
            if images_url_check is None:
                cls.assertClassSetupFailure('Endpoint validation failed')
            cls.url = (images_service.get_endpoint(
                cls.images_config.region).public_url)
            # If a url override was provided, use it instead
            if cls.images_config.override_url:
                cls.url = cls.images_config.override_url

            images_client = cls.generate_images_client(access_data)
            user_list[user][cls.CLIENT] = images_client

            images_behavior = ImagesBehaviors(images_client, cls.images_config)
            user_list[user][cls.BEHAVIOR] = images_behavior

        return user_list
开发者ID:bhushan5,项目名称:cloudroast,代码行数:46,代码来源:fixtures.py

示例15: setUpClass

# 需要导入模块: from cloudcafe.auth.provider import AuthProvider [as 别名]
# 或者: from cloudcafe.auth.provider.AuthProvider import get_access_data [as 别名]
    def setUpClass(cls):
        """
        Perform actions that setup the necessary resources for testing.

        The following resources are created during this setup:
            - Creates an active server with metadata.
            - Creates an image with metadata and waits for active status.
        """
        super(AuthorizationTests, cls).setUpClass()
        cls.metadata = {'meta_key_1': 'meta_value_1',
                        'meta_key_2': 'meta_value_2'}
        cls.server = cls.server_behaviors.create_active_server(
            metadata=cls.metadata).entity
        cls.resources.add(cls.server.id, cls.servers_client.delete_server)

        image_name = rand_name('testimage')
        cls.image_meta = {'user_key1': 'value1', 'user_key2': 'value2'}
        image_resp = cls.servers_client.create_image(cls.server.id,
                                                     image_name,
                                                     cls.image_meta)
        assert image_resp.status_code == 202
        cls.image_id = cls.parse_image_id(image_resp)
        cls.image_behaviors.wait_for_image_status(
            cls.image_id, NovaImageStatusTypes.ACTIVE)
        cls.resources.add(cls.image_id, cls.images_client.delete_image)

        secondary_user = ComputeAuthorizationConfig()
        compute_endpoint = ComputeEndpointConfig()
        auth_endpoint_config = UserAuthConfig()
        access_data = AuthProvider.get_access_data(
            auth_endpoint_config, secondary_user)

        compute_service = access_data.get_service(
            compute_endpoint.compute_endpoint_name)
        url = compute_service.get_endpoint(
            compute_endpoint.region).public_url

        cls.flavors_client = FlavorsClient(
            url, access_data.token.id_, 'json', 'json')
        cls.servers_client = ServersClient(
            url, access_data.token.id_, 'json', 'json')
        cls.images_client = ImagesClient(
            url, access_data.token.id_, 'json', 'json')
        cls.flavors_client.add_exception_handler(ExceptionHandler())
开发者ID:Prokop,项目名称:cloud_roast,代码行数:46,代码来源:test_authorization.py


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