Exemplo n.º 1
0
    def get_access_data(self, endpoint_config=None, user_config=None):
        endpoint_config = endpoint_config or UserAuthConfig()
        user_config = user_config or UserConfig()

        if endpoint_config.strategy.lower() == 'keystone':
            token_client = OSTokenAPI_Client(
                endpoint_config.auth_endpoint, 'json', 'json')
            token_behaviors = OSTokenAPI_Behaviors(token_client)
            return token_behaviors.get_access_data(user_config.username,
                                                   user_config.password,
                                                   user_config.tenant_name)

        elif endpoint_config.strategy.lower() == 'rax_auth':
            token_client = RaxTokenAPI_Client(
                endpoint_config.auth_endpoint, 'json', 'json')
            token_behaviors = RaxTokenAPI_Behaviors(token_client)
            return token_behaviors.get_access_data(user_config.username,
                                                   user_config.api_key,
                                                   user_config.tenant_id)

        elif endpoint_config.strategy.lower() == 'saio_tempauth':
            auth_client = SaioAuthAPI_Client(endpoint_config.auth_endpoint)
            auth_behaviors = SaioAuthAPI_Behaviors(auth_client)
            return auth_behaviors.get_access_data(
                user_config.username, user_config.password)

        else:
            raise NotImplementedError
Exemplo n.º 2
0
 def _create_client(self, username, password):
     """
     Create a client for the given test account
     """
     endpoint = self.endpoint_config.auth_endpoint
     token_client = OSTokenAPI_Client(endpoint, 'json', 'json')
     token_behaviors = OSTokenAPI_Behaviors(token_client)
     access_data = token_behaviors.get_access_data(username, password,
                                                   self.tenant_id)
     autoscale_temp_client = AutoscalingAPIClient(
         url=self.url,
         auth_token=access_data.token.id_,
         serialize_format='json',
         deserialize_format='json')
     return autoscale_temp_client
Exemplo n.º 3
0
 def _create_client(self, username, password):
     """
     Create a client for the given test account
     """
     endpoint = self.endpoint_config.auth_endpoint
     token_client = OSTokenAPI_Client(endpoint, 'json', 'json')
     token_behaviors = OSTokenAPI_Behaviors(token_client)
     access_data = token_behaviors.get_access_data(username,
                                                   password,
                                                   self.tenant_id)
     autoscale_temp_client = AutoscalingAPIClient(url=self.url,
                                                  auth_token=access_data.token.id_,
                                                  serialize_format='json',
                                                  deserialize_format='json')
     return autoscale_temp_client
Exemplo n.º 4
0
 def get_access_data(self, endpoint_config, user_config):
     if endpoint_config.strategy.lower() == 'keystone':
         token_client = OSTokenAPI_Client(endpoint_config.auth_endpoint,
                                          'json', 'json')
         token_behaviors = OSTokenAPI_Behaviors(token_client)
         return token_behaviors.get_access_data(user_config.username,
                                                user_config.password,
                                                user_config.tenant_name)
     elif endpoint_config.strategy.lower() == 'rax_auth':
         token_client = TokenAPI_Client(endpoint_config.auth_endpoint,
                                        'json', 'json')
         token_behaviors = TokenAPI_Behaviors(token_client)
         return token_behaviors.get_access_data(user_config.username,
                                                user_config.api_key,
                                                user_config.tenant_id)
     else:
         raise NotImplementedError
 def setUpClass(cls):
     """
     Create a client for a test account that does not have the autoscale endpoint
     in its service catalog
     """
     super(AutoscaleReposeUnauthTests, cls).setUpClass()
     cls.url = cls.url.replace(cls.tenant_id, cls.non_autoscale_tenant)
     endpoint = cls.endpoint_config.auth_endpoint
     token_client = OSTokenAPI_Client(
         endpoint, 'json', 'json')
     token_behaviors = OSTokenAPI_Behaviors(token_client)
     access_data = token_behaviors.get_access_data(cls.non_autoscale_username,
                                                   cls.non_autoscale_password,
                                                   cls.non_autoscale_tenant)
     cls.autoscale_temp_client = AutoscalingAPIClient(
         url=cls.url, auth_token=access_data.token.id_, serialize_format='json',
         deserialize_format='json')
Exemplo n.º 6
0
 def get_access_data(self, endpoint_config, user_config):
     if endpoint_config.strategy.lower() == 'keystone':
         token_client = OSTokenAPI_Client(
             endpoint_config.auth_endpoint, 'json', 'json')
         token_behaviors = OSTokenAPI_Behaviors(token_client)
         return token_behaviors.get_access_data(user_config.username,
                                                user_config.password,
                                                user_config.tenant_name)
     elif endpoint_config.strategy.lower() == 'rax_auth':
         token_client = TokenAPI_Client(
             endpoint_config.auth_endpoint, 'json', 'json')
         token_behaviors = TokenAPI_Behaviors(token_client)
         return token_behaviors.get_access_data(user_config.username,
                                                user_config.api_key,
                                                user_config.tenant_id)
     else:
         raise NotImplementedError
Exemplo n.º 7
0
 def setUpClass(cls):
     """
     Create a client for a test account that does not have the Auto Scale
     endpoint in its service catalog.
     """
     super(AutoscaleReposeUnauthTests, cls).setUpClass()
     cls.url = cls.url.replace(cls.tenant_id, cls.non_autoscale_tenant)
     endpoint = cls.endpoint_config.auth_endpoint
     token_client = OSTokenAPI_Client(endpoint, 'json', 'json')
     token_behaviors = OSTokenAPI_Behaviors(token_client)
     access_data = token_behaviors.get_access_data(
         cls.non_autoscale_username, cls.non_autoscale_password,
         cls.non_autoscale_tenant)
     cls.autoscale_temp_client = AutoscalingAPIClient(
         url=cls.url,
         auth_token=access_data.token.id_,
         serialize_format='json',
         deserialize_format='json')
Exemplo n.º 8
0
 def setUpClass(cls):
     super(AuthenticationFixture, cls).setUpClass()
     cls.auth_client = TokenAPI_Client(
         url=cls.keystone.authentication_endpoint,
         serialize_format=cls.marshalling.serializer,
         deserialize_format=cls.marshalling.deserializer)
     cls.auth_behaviors = TokenAPI_Behaviors(cls.auth_client)
     cls.version_client = VersionClient(
         url=cls.cloudkeep.base_url,
         serialize_format=cls.marshalling.serializer,
         deserialize_format=cls.marshalling.deserializer)
Exemplo n.º 9
0
    def setUpClass(cls):
        super(ComputeFixture, cls).setUpClass()
        cls.flavors_config = FlavorsConfig()
        cls.images_config = ImagesConfig()
        cls.servers_config = ServersConfig()
        cls.compute_config = ComputeConfig()

        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

        identity_config = TokenAPI_Config()
        token_client = TokenAPI_Client(identity_config.authentication_endpoint,
                                       'json', 'json')
        token_behaviors = TokenAPI_Behaviors(token_client)
        access_data = token_behaviors.get_access_data(identity_config.username,
                                                      identity_config.password,
                                                      identity_config.tenant_name)

        compute_service = access_data.get_service(
            cls.compute_config.compute_endpoint_name)
        url = compute_service.get_endpoint(
            cls.compute_config.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.server_behaviors = ServerBehaviors(cls.servers_client,
                                               cls.servers_config,
                                               cls.images_config,
                                               cls.flavors_config)
        cls.image_behaviors = ImageBehaviors(cls.images_client,
                                             cls.images_config)
        cls.flavors_client.add_exception_handler(ExceptionHandler())
        cls.resources = ResourcePool()
Exemplo n.º 10
0
    def setUpClass(cls):
        super(DBaaSFixture, cls).setUpClass()
        cls.dbaas_config = DBaaSConfig()

        #Add configs here...update ccengine/domain/configuration.py to get these configs
        cls.stability_mode = cls.dbaas_config.stability_mode
        cls.version_url = cls.dbaas_config.version_url
        cls.graphite_endpoint = cls.dbaas_config.graphite_endpoint
        cls.perf_server = cls.dbaas_config.perf_server
        cls.perf_server_user = cls.dbaas_config.perf_server_user
        cls.perf_server_password = cls.dbaas_config.perf_server_password
        cls.host_url = cls.dbaas_config.host
        cls.tenant_id = cls.dbaas_config.tenant_id
        cls.service_url = cls.dbaas_config.host + "/" + cls.tenant_id

        identity_config = TokenAPI_Config()
        token_client = TokenAPI_Client(identity_config.endpoint,
                                       'json', 'json')
        token_behaviors = TokenAPI_Behaviors(token_client)
        access_data = token_behaviors.get_access_data(identity_config.username,
                                                      identity_config.password,
                                                      identity_config.tenant_name)
        dbaas_service = access_data.get_service(identity_config.endpoint)
        cls.auth_url = identity_config.endpoint + "/v2.0/tokens"
        #check for role
        rp_admin_user = cls.dbaas_config.rp_admin_user
        creator_user = cls.dbaas_config.creator_user
        observer_user = cls.dbaas_config.observer_user
        mgmt_username = cls.dbaas_config.mgmt_username

        #TODO: Need to fix this...
        #ah_dict = {EngineConfig.SECTION_NAME: {'serializer': 'xml', 'deserializer': 'xml'}}
        #ah_config = cls.dbaas_config.mcp_override(ah_dict)

        #dbaas_atom_hopper_url = ah_config.compute_api.atom_hopper_url + '/database/events'
        # if cls.dbaas_config.atom_hopper_url is not None:
        #     dbaas_atom_hopper_url = cls.dbaas_config.atom_hopper_url + '/database/events'
        #     cls.dbaas_atomhopper_provider = AtomHopperProvider(dbaas_atom_hopper_url, ah_config)

        if mgmt_username:
            username = cls.dbaas_config.mgmt_username
            api_key = cls.dbaas_config.mgmt_api_key
            mgmt_tenant_id = cls.dbaas_config.mgmt_tenant_id
            mgmt_auth_url = cls.dbaas_config.mgmt_base_url + "/v2.0/tokens"
            mgmt_auth_strategy = "keystone"
            mgmt_service_url = cls.dbaas_config.mgmt_host + "/" + mgmt_tenant_id
            cls.mgmt_client = DBaaSAPIClient(username,
                                             cls.host_url,
                                             api_key,
                                             None,
                                             mgmt_tenant_id,
                                             auth_url=mgmt_auth_url,
                                             service_url=mgmt_service_url,
                                             auth_strategy=mgmt_auth_strategy,
                                             insecure=True,
                                             serialize_format=identity_config.serialize_format,
                                             deserialize_format=identity_config.deserialize_format)

        if creator_user:
            username = cls.dbaas_config.creator_user
            api_key = cls.dbaas_config.creator_pw
            cls.creator_client = DBaaSAPIClient(username,
                                                cls.host_url,
                                                api_key,
                                                None,
                                                cls.tenant_id,
                                                auth_url=cls.auth_url,
                                                service_url=cls.service_url,
                                                auth_strategy="keystone",
                                                insecure=True,
                                                serialize_format=identity_config.serialize_format,
                                                deserialize_format=identity_config.deserialize_format)

        if rp_admin_user:
            username = cls.dbaas_config.rp_admin_user
            api_key = cls.dbaas_config.rp_admin_pw
            cls.admin_client = DBaaSAPIClient(username,
                                              cls.host_url,
                                              api_key,
                                              None,
                                              cls.tenant_id,
                                              auth_url=cls.auth_url,
                                              service_url=cls.service_url,
                                              auth_strategy="keystone",
                                              insecure=True,
                                              serialize_format=identity_config.serialize_format,
                                              deserialize_format=identity_config.deserialize_format)

        if observer_user:
            username = cls.dbaas_config.observer_user
            api_key = cls.dbaas_config.observer_pw
            cls.observer_client = DBaaSAPIClient(username,
                                                 cls.host_url,
                                                 api_key,
                                                 None,
                                                 cls.tenant_id,
                                                 auth_url=cls.auth_url,
                                                 service_url=cls.service_url,
                                                 auth_strategy="keystone",
                                                 insecure=True,
                                                 serialize_format=identity_config.serialize_format,
                                                 deserialize_format=identity_config.deserialize_format)

        #default
        username = identity_config.username
        api_key = identity_config.password
        cls.client = DBaaSAPIClient(username,
                                    cls.host_url,
                                    api_key,
                                    None,
                                    cls.tenant_id,
                                    auth_url=cls.auth_url,
                                    service_url=cls.service_url,
                                    auth_strategy="keystone",
                                    insecure=True,
                                    serialize_format=identity_config.serialize_format,
                                    deserialize_format=identity_config.deserialize_format)
Exemplo n.º 11
0
 def __init__(self):
     self.config = TokenAPI_Config()
     url = self.config.authentication_endpoint
     self.client = TokenAPI_Client(url, 'json', 'json')
     self.behaviors = TokenAPI_Behaviors(self.client)
Exemplo n.º 12
0
    def setUpClass(cls):
        super(DBaaSFixture, cls).setUpClass()
        cls.dbaas_config = DBaaSConfig()
        cls.behavior = DatabaseAPI_Behaviors()
        cls.stability_mode = cls.dbaas_config.stability_mode
        cls.version_url = cls.dbaas_config.version_url
        cls.graphite_endpoint = cls.dbaas_config.graphite_endpoint
        cls.perf_server = cls.dbaas_config.perf_server
        cls.perf_server_user = cls.dbaas_config.perf_server_user
        cls.perf_server_password = cls.dbaas_config.perf_server_password
        cls.host_url = cls.dbaas_config.host
        cls.tenant_id = cls.dbaas_config.tenant_id
        cls.service_url = '{0}/{1}'.format(cls.dbaas_config.host,
                                           cls.tenant_id)

        identity_config = TokenAPI_Config()
        token_client = TokenAPI_Client(identity_config.endpoint,
                                       identity_config.serialize_format,
                                       identity_config.deserialize_format)
        token_behaviors = TokenAPI_Behaviors(token_client)
        access_data = token_behaviors.get_access_data(
            identity_config.username, identity_config.password,
            identity_config.tenant_name)
        dbaas_service = access_data.get_service(identity_config.endpoint)
        cls.auth_url = "{0}/v2.0/tokens".format(identity_config.endpoint)
        #check for role
        rp_admin_user = cls.dbaas_config.rp_admin_user
        creator_user = cls.dbaas_config.creator_user
        observer_user = cls.dbaas_config.observer_user
        mgmt_username = cls.dbaas_config.mgmt_username

        if mgmt_username:
            username = cls.dbaas_config.mgmt_username
            api_key = cls.dbaas_config.mgmt_api_key
            mgmt_tenant_id = cls.dbaas_config.mgmt_tenant_id
            mgmt_auth_url = "{0}/v2.0/tokens".format(
                cls.dbaas_config.mgmt_base_url)
            mgmt_auth_strategy = "keystone"
            mgmt_service_url = "{0}/{1}".format(cls.dbaas_config.mgmt_host,
                                                mgmt_tenant_id)

            cls.mgmt_client = \
                DBaaSAPIClient(username,
                               cls.host_url,
                               api_key,
                               None,
                               mgmt_tenant_id,
                               auth_url=mgmt_auth_url,
                               service_url=mgmt_service_url,
                               auth_strategy=mgmt_auth_strategy,
                               insecure=True,
                               serialize_format=
                               identity_config.serialize_format,
                               deserialize_format=
                               identity_config.deserialize_format)

        if creator_user:
            username = cls.dbaas_config.creator_user
            api_key = cls.dbaas_config.creator_pw
            cls.creator_client = \
                DBaaSAPIClient(username,
                               cls.host_url,
                               api_key,
                               None,
                               cls.tenant_id,
                               auth_url=cls.auth_url,
                               service_url=cls.service_url,
                               auth_strategy="keystone",
                               insecure=True,
                               serialize_format=
                               identity_config.serialize_format,
                               deserialize_format=
                               identity_config.deserialize_format)

        if rp_admin_user:
            username = cls.dbaas_config.rp_admin_user
            api_key = cls.dbaas_config.rp_admin_pw
            cls.admin_client = \
                DBaaSAPIClient(username,
                               cls.host_url,
                               api_key,
                               None,
                               cls.tenant_id,
                               auth_url=cls.auth_url,
                               service_url=cls.service_url,
                               auth_strategy="keystone",
                               insecure=True,
                               serialize_format=
                               identity_config.serialize_format,
                               deserialize_format=
                               identity_config.deserialize_format)

        if observer_user:
            username = cls.dbaas_config.observer_user
            api_key = cls.dbaas_config.observer_pw
            cls.observer_client = \
                DBaaSAPIClient(username,
                               cls.host_url,
                               api_key,
                               None,
                               cls.tenant_id,
                               auth_url=cls.auth_url,
                               service_url=cls.service_url,
                               auth_strategy="keystone",
                               insecure=True,
                               serialize_format=
                               identity_config.serialize_format,
                               deserialize_format=
                               identity_config.deserialize_format)

        #default
        username = identity_config.username
        api_key = identity_config.password
        cls.client = \
            DBaaSAPIClient(username,
                           cls.host_url,
                           api_key,
                           None,
                           cls.tenant_id,
                           auth_url=cls.auth_url,
                           service_url=cls.service_url,
                           auth_strategy="keystone",
                           insecure=True,
                           serialize_format=
                           identity_config.serialize_format,
                           deserialize_format=
                           identity_config.deserialize_format)