Modify novaclient to support basic attributes

Added support for parsing OS_PROJECT_DOMAIN_ID, OS_PROJECT_DOMAIN_NAME,
OS_USER_DOMAIN_ID, and OS_USER_DOMAIN_NAME options.

Change-Id: I9e1a3426f174c2e6d9f4f6bf10e9aecb62bad8d0
Closes-Bug: #1744118
This commit is contained in:
shilpa.devharakar 2018-05-23 12:33:07 +05:30
parent 7907528256
commit ab1f6bd763
6 changed files with 71 additions and 3 deletions

View File

@ -10,6 +10,7 @@ cmd2==0.8.0
contextlib2==0.4.0
coverage==4.0
cryptography==2.1
ddt==1.0.1
debtcollector==1.2.0
decorator==3.4.0
deprecation==1.0
@ -87,7 +88,7 @@ pytz==2013.6
PyYAML==3.12
repoze.lru==0.7
requests==2.14.2
requests-mock==1.1.0
requests-mock==1.2.0
requestsexceptions==1.2.0
rfc3986==0.3.1
Routes==2.3.1

View File

@ -270,6 +270,14 @@ class OpenStackComputeShell(object):
'OS_PROJECT_NAME', 'OS_TENANT_NAME', 'NOVA_PROJECT_ID'))
parser.set_defaults(os_project_id=utils.env(
'OS_PROJECT_ID', 'OS_TENANT_ID'))
parser.set_defaults(
os_project_domain_id=utils.env('OS_PROJECT_DOMAIN_ID'))
parser.set_defaults(
os_project_domain_name=utils.env('OS_PROJECT_DOMAIN_NAME'))
parser.set_defaults(
os_user_domain_id=utils.env('OS_USER_DOMAIN_ID'))
parser.set_defaults(
os_user_domain_name=utils.env('OS_USER_DOMAIN_NAME'))
def get_base_parser(self, argv):
parser = NovaClientArgumentParser(
@ -596,6 +604,26 @@ class OpenStackComputeShell(object):
_("You must provide an auth url "
"via either --os-auth-url or env[OS_AUTH_URL]."))
# TODO(Shilpasd): need to provide support in python - novaclient
# for required options for below default auth type plugins:
# 1. v3oidcclientcredential
# 2. v3oidcpassword
# 3. v3oidcauthcode
# 4. v3oidcaccesstoken
# 5. v3oauth1
# 6. v3fedkerb
# 7. v3adfspassword
# 8. v3samlpassword
# 9. v3applicationcredential
# TODO(Shilpasd): need to provide support in python - novaclient
# for below extra keystoneauth auth type plugins:
# We will need to add code to support discovering of versions
# supported by the keystone service based on the auth_url similar
# to the one supported by glanceclient.
# 1. v3password
# 2. v3token
# 3. v3kerberos
# 4. v3totp
with utils.record_time(self.times, args.timings,
'auth_url', args.os_auth_url):
keystone_session = (

View File

@ -16,6 +16,7 @@ import distutils.version as dist_version
import re
import sys
import ddt
import fixtures
from keystoneauth1 import fixture
import mock
@ -35,7 +36,11 @@ FAKE_ENV = {'OS_USERNAME': 'username',
'OS_PASSWORD': 'password',
'OS_TENANT_NAME': 'tenant_name',
'OS_AUTH_URL': 'http://no.where/v2.0',
'OS_COMPUTE_API_VERSION': '2'}
'OS_COMPUTE_API_VERSION': '2',
'OS_PROJECT_DOMAIN_ID': 'default',
'OS_PROJECT_DOMAIN_NAME': 'default',
'OS_USER_DOMAIN_ID': 'default',
'OS_USER_DOMAIN_NAME': 'default'}
FAKE_ENV2 = {'OS_USER_ID': 'user_id',
'OS_PASSWORD': 'password',
@ -349,6 +354,7 @@ class ParserTest(utils.TestCase):
self.assertTrue(args.tic_tac)
@ddt.ddt
class ShellTest(utils.TestCase):
_msg_no_tenant_project = ("You must provide a project name or project"
@ -521,6 +527,23 @@ class ShellTest(utils.TestCase):
else:
self.fail('CommandError not raised')
@ddt.data(
(None, 'project_domain_id', FAKE_ENV['OS_PROJECT_DOMAIN_ID']),
('OS_PROJECT_DOMAIN_ID', 'project_domain_id', ''),
(None, 'project_domain_name', FAKE_ENV['OS_PROJECT_DOMAIN_NAME']),
('OS_PROJECT_DOMAIN_NAME', 'project_domain_name', ''),
(None, 'user_domain_id', FAKE_ENV['OS_USER_DOMAIN_ID']),
('OS_USER_DOMAIN_ID', 'user_domain_id', ''),
(None, 'user_domain_name', FAKE_ENV['OS_USER_DOMAIN_NAME']),
('OS_USER_DOMAIN_NAME', 'user_domain_name', '')
)
@ddt.unpack
def test_basic_attributes(self, exclude, client_arg, env_var):
self.make_env(exclude=exclude, fake_env=FAKE_ENV)
self.shell('list')
client_kwargs = self.mock_client.call_args_list[0][1]
self.assertEqual(env_var, client_kwargs[client_arg])
@requests_mock.Mocker()
def test_nova_endpoint_type(self, m_requests):
self.make_env(fake_env=FAKE_ENV3)

View File

@ -0,0 +1,15 @@
---
fixes:
- |
A fix is made for `bug 1744118`_ which adds the below missing CLI
arguments.
* OS_PROJECT_DOMAIN_ID
* OS_PROJECT_DOMAIN_NAME
* OS_USER_DOMAIN_ID
* OS_USER_DOMAIN_NAME
.. _bug 1744118: https://bugs.launchpad.net/python-novaclient/+bug/1744118

View File

@ -7,7 +7,7 @@ iso8601>=0.1.11 # MIT
oslo.i18n>=3.15.3 # Apache-2.0
oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0
oslo.utils>=3.33.0 # Apache-2.0
PrettyTable<0.8,>=0.7.1 # BSD
PrettyTable<0.8,>=0.7.2 # BSD
simplejson>=3.5.1 # MIT
six>=1.10.0 # MIT
Babel!=2.4.0,>=2.3.4 # BSD

View File

@ -5,6 +5,7 @@ hacking!=0.13.0,<0.14,>=0.12.0 # Apache-2.0
bandit>=1.1.0 # Apache-2.0
coverage!=4.4,>=4.0 # Apache-2.0
ddt>=1.0.1 # MIT
fixtures>=3.0.0 # Apache-2.0/BSD
keyring>=5.5.1 # MIT/PSF
mock>=2.0.0 # BSD