Merge "support OS_ENDPOINT_TYPE in nova client"
This commit is contained in:
commit
d485d755ec
novaclient
@ -353,12 +353,18 @@ class OpenStackComputeShell(object):
|
||||
parser.add_argument('--volume_service_name',
|
||||
help=argparse.SUPPRESS)
|
||||
|
||||
parser.add_argument('--endpoint-type',
|
||||
parser.add_argument('--os-endpoint-type',
|
||||
metavar='<endpoint-type>',
|
||||
dest='endpoint_type',
|
||||
default=utils.env('NOVA_ENDPOINT_TYPE',
|
||||
default=DEFAULT_NOVA_ENDPOINT_TYPE),
|
||||
help=(_('Defaults to env[NOVA_ENDPOINT_TYPE] or ')
|
||||
+ DEFAULT_NOVA_ENDPOINT_TYPE + '.'))
|
||||
default=utils.env('OS_ENDPOINT_TYPE',
|
||||
default=DEFAULT_NOVA_ENDPOINT_TYPE)),
|
||||
help=_('Defaults to env[NOVA_ENDPOINT_TYPE], '
|
||||
'env[OS_ENDPOINT_TYPE] or ')
|
||||
+ DEFAULT_NOVA_ENDPOINT_TYPE + '.')
|
||||
|
||||
parser.add_argument('--endpoint-type',
|
||||
help=argparse.SUPPRESS)
|
||||
# NOTE(dtroyer): We can't add --endpoint_type here due to argparse
|
||||
# thinking usage-list --end is ambiguous; but it
|
||||
# works fine with only --endpoint-type present
|
||||
|
@ -36,6 +36,13 @@ FAKE_ENV2 = {'OS_USER_ID': 'user_id',
|
||||
'OS_TENANT_ID': 'tenant_id',
|
||||
'OS_AUTH_URL': 'http://no.where'}
|
||||
|
||||
FAKE_ENV3 = {'OS_USER_ID': 'user_id',
|
||||
'OS_PASSWORD': 'password',
|
||||
'OS_TENANT_ID': 'tenant_id',
|
||||
'OS_AUTH_URL': 'http://no.where',
|
||||
'NOVA_ENDPOINT_TYPE': 'novaURL',
|
||||
'OS_ENDPOINT_TYPE': 'osURL'}
|
||||
|
||||
|
||||
class ShellTest(utils.TestCase):
|
||||
|
||||
@ -192,6 +199,27 @@ class ShellTest(utils.TestCase):
|
||||
else:
|
||||
self.fail('CommandError not raised')
|
||||
|
||||
@mock.patch('novaclient.client.Client')
|
||||
def test_nova_endpoint_type(self, mock_client):
|
||||
self.make_env(fake_env=FAKE_ENV3)
|
||||
self.shell('list')
|
||||
client_kwargs = mock_client.call_args_list[0][1]
|
||||
self.assertEqual(client_kwargs['endpoint_type'], 'novaURL')
|
||||
|
||||
@mock.patch('novaclient.client.Client')
|
||||
def test_os_endpoint_type(self, mock_client):
|
||||
self.make_env(exclude='NOVA_ENDPOINT_TYPE', fake_env=FAKE_ENV3)
|
||||
self.shell('list')
|
||||
client_kwargs = mock_client.call_args_list[0][1]
|
||||
self.assertEqual(client_kwargs['endpoint_type'], 'osURL')
|
||||
|
||||
@mock.patch('novaclient.client.Client')
|
||||
def test_default_endpoint_type(self, mock_client):
|
||||
self.make_env()
|
||||
self.shell('list')
|
||||
client_kwargs = mock_client.call_args_list[0][1]
|
||||
self.assertEqual(client_kwargs['endpoint_type'], 'publicURL')
|
||||
|
||||
@mock.patch('sys.stdin', side_effect=mock.MagicMock)
|
||||
@mock.patch('getpass.getpass', return_value='password')
|
||||
def test_password(self, mock_getpass, mock_stdin):
|
||||
|
Loading…
x
Reference in New Issue
Block a user