Merge "allow --endpoint-type internal|admin|public"
This commit is contained in:
commit
7a1066fb79
@ -651,6 +651,11 @@ class OpenStackComputeShell(object):
|
|||||||
if not endpoint_type:
|
if not endpoint_type:
|
||||||
endpoint_type = DEFAULT_NOVA_ENDPOINT_TYPE
|
endpoint_type = DEFAULT_NOVA_ENDPOINT_TYPE
|
||||||
|
|
||||||
|
# This allow users to use endpoint_type as (internal, public or admin)
|
||||||
|
# just like other openstack clients (glance, cinder etc)
|
||||||
|
if endpoint_type in ['internal', 'public', 'admin']:
|
||||||
|
endpoint_type += 'URL'
|
||||||
|
|
||||||
if not service_type:
|
if not service_type:
|
||||||
os_compute_api_version = (options.os_compute_api_version or
|
os_compute_api_version = (options.os_compute_api_version or
|
||||||
DEFAULT_OS_COMPUTE_API_VERSION)
|
DEFAULT_OS_COMPUTE_API_VERSION)
|
||||||
|
@ -45,6 +45,13 @@ FAKE_ENV3 = {'OS_USER_ID': 'user_id',
|
|||||||
'NOVA_ENDPOINT_TYPE': 'novaURL',
|
'NOVA_ENDPOINT_TYPE': 'novaURL',
|
||||||
'OS_ENDPOINT_TYPE': 'osURL'}
|
'OS_ENDPOINT_TYPE': 'osURL'}
|
||||||
|
|
||||||
|
FAKE_ENV4 = {'OS_USER_ID': 'user_id',
|
||||||
|
'OS_PASSWORD': 'password',
|
||||||
|
'OS_TENANT_ID': 'tenant_id',
|
||||||
|
'OS_AUTH_URL': 'http://no.where/v2.0',
|
||||||
|
'NOVA_ENDPOINT_TYPE': 'internal',
|
||||||
|
'OS_ENDPOINT_TYPE': 'osURL'}
|
||||||
|
|
||||||
|
|
||||||
def _create_ver_list(versions):
|
def _create_ver_list(versions):
|
||||||
return {'versions': {'values': versions}}
|
return {'versions': {'values': versions}}
|
||||||
@ -248,6 +255,15 @@ class ShellTest(utils.TestCase):
|
|||||||
client_kwargs = mock_client.call_args_list[0][1]
|
client_kwargs = mock_client.call_args_list[0][1]
|
||||||
self.assertEqual(client_kwargs['endpoint_type'], 'novaURL')
|
self.assertEqual(client_kwargs['endpoint_type'], 'novaURL')
|
||||||
|
|
||||||
|
@mock.patch('novaclient.client.Client')
|
||||||
|
@requests_mock.Mocker()
|
||||||
|
def test_endpoint_type_like_other_clients(self, mock_client, m_requests):
|
||||||
|
self.make_env(fake_env=FAKE_ENV4)
|
||||||
|
self.register_keystone_discovery_fixture(m_requests)
|
||||||
|
self.shell('list')
|
||||||
|
client_kwargs = mock_client.call_args_list[0][1]
|
||||||
|
self.assertEqual(client_kwargs['endpoint_type'], 'internalURL')
|
||||||
|
|
||||||
@mock.patch('novaclient.client.Client')
|
@mock.patch('novaclient.client.Client')
|
||||||
@requests_mock.Mocker()
|
@requests_mock.Mocker()
|
||||||
def test_os_endpoint_type(self, mock_client, m_requests):
|
def test_os_endpoint_type(self, mock_client, m_requests):
|
||||||
|
Loading…
Reference in New Issue
Block a user