def get_access_data(endpoint_config=None, user_config=None): endpoint_config = endpoint_config or UserAuthConfig() user_config = user_config or UserConfig() if endpoint_config.strategy.lower() == 'keystone': return IdentityServiceBehaviors.get_access_data( user_config.username, user_config.password, user_config.tenant_name, endpoint_config.auth_endpoint) 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
def get_access_data(endpoint_config=None, user_config=None): endpoint_config = endpoint_config or UserAuthConfig() user_config = user_config or UserConfig() if endpoint_config.strategy.lower() == 'keystone': return IdentityServiceBehaviors.get_access_data( user_config.username, user_config.password, user_config.tenant_name, endpoint_config.auth_endpoint) 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
def get_access_data(endpoint_config=None, user_config=None): endpoint_config = endpoint_config or UserAuthConfig() user_config = user_config or UserConfig() if endpoint_config.strategy.lower() == 'keystone': return IdentityServiceBehaviors.get_access_data( user_config.username, user_config.password, user_config.tenant_name, endpoint_config.auth_endpoint) 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() == 'rax_auth_mfa': passcode = user_config.passcode if passcode is None: # TODO: This is a place holder for adding the functionality to # use an external service (e.g. - SMS) to provide the passcode pass token_client = RaxToken_MFA_API_Client( url=endpoint_config.auth_endpoint, serialize_format='json', deserialize_format='json') token_behaviors = RaxToken_MFA_API_Behaviors(token_client) return token_behaviors.get_access_data( username=user_config.username, password=user_config.password, tenant_id=user_config.tenant_id, passcode=passcode) 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
def get_access_data(endpoint_config=None, user_config=None): endpoint_config = endpoint_config or UserAuthConfig() user_config = user_config or UserConfig() if endpoint_config.strategy.lower() == 'keystone': return IdentityServiceBehaviors.get_access_data( user_config.username, user_config.password, user_config.tenant_name, endpoint_config.auth_endpoint) 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() == 'rax_auth_mfa': passcode = user_config.passcode if passcode is None: # TODO: This is a place holder for adding the functionality to # use an external service (e.g. - SMS) to provide the passcode pass token_client = RaxToken_MFA_API_Client( url=endpoint_config.auth_endpoint, serialize_format='json', deserialize_format='json') token_behaviors = RaxToken_MFA_API_Behaviors(token_client) return token_behaviors.get_access_data( username=user_config.username, password=user_config.password, tenant_id=user_config.tenant_id, passcode=passcode) 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
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.api_key, identity_config.tenant_id) 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()
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 get_rackspace_access_data( cls, username, api_key, tenant_id, auth_endpoint): client = RaxTokenAPI_Client(auth_endpoint, 'json', 'json') behaviors = RaxTokenAPI_Behaviors(client) return behaviors.get_access_data(username, api_key, tenant_id)