Merge "allow --endpoint-type internal|admin|public"

This commit is contained in:
Jenkins 2015-02-26 01:21:18 +00:00 committed by Gerrit Code Review
commit 7a1066fb79
2 changed files with 21 additions and 0 deletions

View File

@ -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)

View File

@ -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):