summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLinda Wang <wangwulin@huawei.com>2017-06-24 07:42:20 +0000
committerLinda Wang <wangwulin@huawei.com>2017-06-27 07:58:19 +0000
commit00f3d66bc9af0292b6ab2433eb2a6e1de8467300 (patch)
tree233d9941c353acc64600ed8bdb945730b4157b0f
parentc7ba89444d160cb81656a49cb93416ee5013aa8f (diff)
Enable snaps work using public endpoint
When functest is not run on jumpserver but on other external host without admin network, snaps failed to connect the admin endpoint. So running snaps tests using public endpoint should be allowed. JIRA: SNAPS-110 Change-Id: I8ca8d8c48330b5f427568d3d5fe942f6f2ca9ea9 Signed-off-by: Linda Wang <wangwulin@huawei.com>
-rw-r--r--snaps/openstack/create_user.py1
-rw-r--r--snaps/openstack/os_credentials.py5
-rw-r--r--snaps/openstack/tests/openstack_tests.py5
-rw-r--r--snaps/openstack/utils/keystone_utils.py3
4 files changed, 12 insertions, 2 deletions
diff --git a/snaps/openstack/create_user.py b/snaps/openstack/create_user.py
index b3f93d4..4c96121 100644
--- a/snaps/openstack/create_user.py
+++ b/snaps/openstack/create_user.py
@@ -93,6 +93,7 @@ class OpenStackUser:
identity_api_version=self.__os_creds.identity_api_version,
user_domain_id=self.__os_creds.user_domain_id,
project_domain_id=self.__os_creds.project_domain_id,
+ interface=self.__os_creds.interface,
proxy_settings=self.__os_creds.proxy_settings,
cacert=self.__os_creds.cacert)
diff --git a/snaps/openstack/os_credentials.py b/snaps/openstack/os_credentials.py
index b55e480..072c00a 100644
--- a/snaps/openstack/os_credentials.py
+++ b/snaps/openstack/os_credentials.py
@@ -22,7 +22,7 @@ class OSCreds:
def __init__(self, username, password, auth_url, project_name, identity_api_version=2, image_api_version=2,
network_api_version=2, compute_api_version=2, user_domain_id='default', project_domain_id='default',
- proxy_settings=None, cacert=True):
+ interface="admin", proxy_settings=None, cacert=True):
"""
Constructor
:param username: The user (required)
@@ -35,6 +35,7 @@ class OSCreds:
:param compute_api_version: The OpenStack's API version to use for Nova clients
:param user_domain_id: Used for v3 APIs
:param project_domain_id: Used for v3 APIs
+ :param interface: Used to specify the endpoint type for keystone as public, admin, internal
:param proxy_settings: instance of os_credentials.ProxySettings class
:param cacert: Default to be True for http, or the certification file is specified for https verification,
or set to be False to disable server certificate verification without cert file
@@ -49,6 +50,7 @@ class OSCreds:
self.compute_api_version = compute_api_version
self.user_domain_id = user_domain_id
self.project_domain_id = project_domain_id
+ self.interface = interface
self.proxy_settings = proxy_settings
self.cacert = cacert
@@ -75,6 +77,7 @@ class OSCreds:
', network_api_version=' + str(self.network_api_version) + \
', compute_api_version=' + str(self.compute_api_version) + \
', user_domain_id=' + str(self.user_domain_id) + \
+ ', interface=' + str(self.interface) + \
', proxy_settings=' + str(self.proxy_settings) + \
', cacert=' + str(self.cacert)
diff --git a/snaps/openstack/tests/openstack_tests.py b/snaps/openstack/tests/openstack_tests.py
index c0b3a4a..d0c250f 100644
--- a/snaps/openstack/tests/openstack_tests.py
+++ b/snaps/openstack/tests/openstack_tests.py
@@ -92,6 +92,10 @@ def get_credentials(os_env_file=None, proxy_settings_str=None,
else:
https_cacert = True
+ interface = 'admin'
+ if config.get('OS_INTERFACE'):
+ interface = config.get('OS_INTERFACE')
+
os_creds = OSCreds(username=config['OS_USERNAME'],
password=config['OS_PASSWORD'],
auth_url=config['OS_AUTH_URL'],
@@ -99,6 +103,7 @@ def get_credentials(os_env_file=None, proxy_settings_str=None,
identity_api_version=version,
user_domain_id=user_domain_id,
project_domain_id=proj_domain_id,
+ interface=interface,
proxy_settings=proxy_settings,
cacert=https_cacert)
else:
diff --git a/snaps/openstack/utils/keystone_utils.py b/snaps/openstack/utils/keystone_utils.py
index 8f5effd..061f3f0 100644
--- a/snaps/openstack/utils/keystone_utils.py
+++ b/snaps/openstack/utils/keystone_utils.py
@@ -69,7 +69,8 @@ def keystone_client(os_creds):
:param os_creds: the OpenStack credentials (OSCreds) object
:return: the client
"""
- return Client(version=os_creds.identity_api_version, session=keystone_session(os_creds))
+ return Client(version=os_creds.identity_api_version, session=keystone_session(os_creds),
+ interface=os_creds.interface)
def get_endpoint(os_creds, service_type, endpoint_type='publicURL'):