Pass os_identity_api_version into functional tests
Add 'os_identity_api_version' to keystone_v3_conf_settings. Deduplicate excessive _ironic_osc method. Change-Id: I9b93ec8a299d3a69629bf294d23d1b1d9e23660e Closes-Bug: #1646837
This commit is contained in:
parent
835775e45c
commit
fab6a8bfef
@ -83,7 +83,8 @@ class FunctionalTestBase(base.ClientTestBase):
|
|||||||
conf_settings += ['os_auth_url', 'os_username',
|
conf_settings += ['os_auth_url', 'os_username',
|
||||||
'os_password', 'os_project_name']
|
'os_password', 'os_project_name']
|
||||||
keystone_v3_conf_settings += ['os_user_domain_id',
|
keystone_v3_conf_settings += ['os_user_domain_id',
|
||||||
'os_project_domain_id']
|
'os_project_domain_id',
|
||||||
|
'os_identity_api_version']
|
||||||
else:
|
else:
|
||||||
conf_settings += ['os_auth_token', 'ironic_url']
|
conf_settings += ['os_auth_token', 'ironic_url']
|
||||||
|
|
||||||
@ -126,11 +127,14 @@ class FunctionalTestBase(base.ClientTestBase):
|
|||||||
return base.execute(cmd, action, flags, params,
|
return base.execute(cmd, action, flags, params,
|
||||||
cli_dir=self.client.cli_dir)
|
cli_dir=self.client.cli_dir)
|
||||||
|
|
||||||
def _ironic(self, action, flags='', params='', merge_stderr=False):
|
def _ironic(self, action, cmd='ironic', flags='', params='',
|
||||||
|
merge_stderr=False):
|
||||||
"""Execute ironic command for the given action.
|
"""Execute ironic command for the given action.
|
||||||
|
|
||||||
:param action: the cli command to run using Ironic
|
:param action: the cli command to run using Ironic
|
||||||
:type action: string
|
:type action: string
|
||||||
|
:param cmd: the base of cli command to run
|
||||||
|
:type action: string
|
||||||
:param flags: any optional cli flags to use
|
:param flags: any optional cli flags to use
|
||||||
:type flags: string
|
:type flags: string
|
||||||
:param params: any optional positional args to use
|
:param params: any optional positional args to use
|
||||||
@ -138,9 +142,15 @@ class FunctionalTestBase(base.ClientTestBase):
|
|||||||
:param merge_stderr: whether to merge stderr into the result
|
:param merge_stderr: whether to merge stderr into the result
|
||||||
:type merge_stderr: bool
|
:type merge_stderr: bool
|
||||||
"""
|
"""
|
||||||
flags += ' --os-endpoint-type publicURL'
|
if cmd == 'openstack':
|
||||||
|
config = self._get_config()
|
||||||
|
id_api_version = config['os_identity_api_version']
|
||||||
|
flags += ' --os-identity-api-version {0}'.format(id_api_version)
|
||||||
|
else:
|
||||||
|
flags += ' --os-endpoint-type publicURL'
|
||||||
|
|
||||||
if hasattr(self, 'os_auth_token'):
|
if hasattr(self, 'os_auth_token'):
|
||||||
return self._cmd_no_auth('ironic', action, flags, params)
|
return self._cmd_no_auth(cmd, action, flags, params)
|
||||||
else:
|
else:
|
||||||
for keystone_object in 'user', 'project':
|
for keystone_object in 'user', 'project':
|
||||||
domain_attr = 'os_%s_domain_id' % keystone_object
|
domain_attr = 'os_%s_domain_id' % keystone_object
|
||||||
@ -149,25 +159,8 @@ class FunctionalTestBase(base.ClientTestBase):
|
|||||||
'ks_obj': keystone_object,
|
'ks_obj': keystone_object,
|
||||||
'value': getattr(self, domain_attr)
|
'value': getattr(self, domain_attr)
|
||||||
}
|
}
|
||||||
return self.client.cmd_with_auth('ironic',
|
return self.client.cmd_with_auth(
|
||||||
action, flags, params,
|
cmd, action, flags, params, merge_stderr=merge_stderr)
|
||||||
merge_stderr=merge_stderr)
|
|
||||||
|
|
||||||
def _ironic_osc(self, action, flags='', params='', merge_stderr=False):
|
|
||||||
"""Execute baremetal commands via OpenStack Client."""
|
|
||||||
config = self._get_config()
|
|
||||||
id_api_version = config.get('functional', 'os_identity_api_version')
|
|
||||||
flags += ' --os-identity-api-version {0}'.format(id_api_version)
|
|
||||||
|
|
||||||
for keystone_object in 'user', 'project':
|
|
||||||
domain_attr = 'os_%s_domain_id' % keystone_object
|
|
||||||
if hasattr(self, domain_attr):
|
|
||||||
flags += ' --os-%(ks_obj)s-domain-id %(value)s' % {
|
|
||||||
'ks_obj': keystone_object,
|
|
||||||
'value': getattr(self, domain_attr)
|
|
||||||
}
|
|
||||||
return self.client.cmd_with_auth(
|
|
||||||
'openstack', action, flags, params, merge_stderr=merge_stderr)
|
|
||||||
|
|
||||||
def ironic(self, action, flags='', params='', parse=True):
|
def ironic(self, action, flags='', params='', parse=True):
|
||||||
"""Return parsed list of dicts with basic item info.
|
"""Return parsed list of dicts with basic item info.
|
||||||
|
@ -21,7 +21,7 @@ from ironicclient.tests.functional import base
|
|||||||
class TestCase(base.FunctionalTestBase):
|
class TestCase(base.FunctionalTestBase):
|
||||||
|
|
||||||
def openstack(self, *args, **kwargs):
|
def openstack(self, *args, **kwargs):
|
||||||
return self._ironic_osc(*args, **kwargs)
|
return self._ironic(cmd='openstack', *args, **kwargs)
|
||||||
|
|
||||||
def get_opts(self, fields=None, output_format='json'):
|
def get_opts(self, fields=None, output_format='json'):
|
||||||
"""Get options for OSC output fields format.
|
"""Get options for OSC output fields format.
|
||||||
|
@ -16,7 +16,7 @@ cat <<END >$CONFIG_FILE
|
|||||||
[functional]
|
[functional]
|
||||||
api_version = 1
|
api_version = 1
|
||||||
os_auth_url=$OS_AUTH_URL
|
os_auth_url=$OS_AUTH_URL
|
||||||
os_identity_api_version = $OS_IDENTITY_API_VERSION
|
os_identity_api_version=$OS_IDENTITY_API_VERSION
|
||||||
os_username=$OS_USERNAME
|
os_username=$OS_USERNAME
|
||||||
os_password=$OS_PASSWORD
|
os_password=$OS_PASSWORD
|
||||||
os_project_name=$OS_PROJECT_NAME
|
os_project_name=$OS_PROJECT_NAME
|
||||||
|
Loading…
x
Reference in New Issue
Block a user