Honor the env var OS_SERVICE_ENDPOINT so to be able to use adminURL or publicURL
Blueprint: endpoint-type Change-Id: I5fd719165324148da3dda6a2f375d486be78cb8d
This commit is contained in:
parent
8b808bc943
commit
e4232f242d
|
@ -87,6 +87,7 @@ class ClientManager:
|
|||
auth_url=options.auth_url,
|
||||
region_name=options.region_name,
|
||||
insecure=self.insecure,
|
||||
endpoint_type=options.endpoint_type,
|
||||
service_type="volume")
|
||||
return self.cinder
|
||||
|
||||
|
@ -130,6 +131,7 @@ class ClientManager:
|
|||
os_tenant_name=options.tenant_name,
|
||||
os_auth_url=options.auth_url,
|
||||
os_region_name=options.region_name,
|
||||
endpoint_type=options.endpoint_type,
|
||||
force_auth=False))
|
||||
|
||||
self.glance = gclient.Client(endpoint=endpoint, token=token)
|
||||
|
@ -149,6 +151,7 @@ class ClientManager:
|
|||
project_id=options.tenant_name,
|
||||
auth_url=options.auth_url,
|
||||
region_name=options.region_name,
|
||||
endpoint_type=options.endpoint_type,
|
||||
insecure=self.insecure)
|
||||
|
||||
return self.nova
|
||||
|
|
|
@ -38,13 +38,14 @@ class OpenstackOptions:
|
|||
>> create_from_dict(dict)
|
||||
"""
|
||||
def __init__(self, user_name, tenant_name, auth_url, password,
|
||||
tenant_id=None, region_name=None):
|
||||
tenant_id=None, region_name=None, endpoint_type=None):
|
||||
self.user_name = user_name
|
||||
self.tenant_name = tenant_name
|
||||
self.auth_url = auth_url
|
||||
self.password = password
|
||||
self.tenant_id = tenant_id
|
||||
self.region_name = region_name
|
||||
self.endpoint_type = endpoint_type
|
||||
|
||||
@property
|
||||
def os_options(self):
|
||||
|
@ -55,7 +56,8 @@ class OpenstackOptions:
|
|||
"""
|
||||
return {'tenant_id': self.tenant_id,
|
||||
'tenant_name': self.tenant_name,
|
||||
'region_name': self.region_name}
|
||||
'region_name': self.region_name,
|
||||
'endpoint_type': self.endpoint_type}
|
||||
|
||||
@staticmethod
|
||||
def create_from_env():
|
||||
|
@ -70,7 +72,8 @@ class OpenstackOptions:
|
|||
auth_url=src_dict['OS_AUTH_URL'],
|
||||
password=src_dict['OS_PASSWORD'],
|
||||
tenant_id=src_dict.get('OS_TENANT_ID', None),
|
||||
region_name=src_dict.get('OS_REGION_NAME', None)
|
||||
region_name=src_dict.get('OS_REGION_NAME', None),
|
||||
endpoint_type=src_dict.get('OS_ENDPOINT_TYPE', None)
|
||||
)
|
||||
except Exception as e:
|
||||
raise Exception('Missing Openstack connection parameter: {0}'
|
||||
|
|
|
@ -21,3 +21,8 @@ class TestOsClients(unittest.TestCase):
|
|||
def test_create_nova(self):
|
||||
client = ClientManager(self.fake_options, None, None, None)
|
||||
client.create_nova()
|
||||
|
||||
def test_create_swift_public(self):
|
||||
options = OpenstackOptions("user", "tenant", "url", "password", endpoint_type="adminURL")
|
||||
client = ClientManager(options, None, None, None)
|
||||
client.create_swift()
|
Loading…
Reference in New Issue