Replace os-client-config module by openstacksdk
Because openstacksdk superseded os-client-config module, it is recommended to use this module instead. Story: 2002021 Task: 19662 Change-Id: I6f225416ff4791a00b04655614eb8f24bed8ae7b
This commit is contained in:
parent
d4b7e15123
commit
1c83ae3a99
|
@ -25,8 +25,8 @@ be discovered by the user. The file used here could be created by an installer,
|
||||||
or manually if necessary.
|
or manually if necessary.
|
||||||
|
|
||||||
3. Values provided in client's cloud config file or as an environment
|
3. Values provided in client's cloud config file or as an environment
|
||||||
variables, see documentation of os-client-config
|
variables, see documentation of openstacksdk
|
||||||
https://docs.openstack.org/developer/os-client-config/
|
https://docs.openstack.org/openstacksdk/latest/
|
||||||
|
|
||||||
4. Values provided on the command line. These override all other values.
|
4. Values provided on the command line. These override all other values.
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ import os
|
||||||
import six
|
import six
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
import os_client_config
|
import openstack
|
||||||
from oslo_config import cfg
|
from oslo_config import cfg
|
||||||
from six.moves import configparser
|
from six.moves import configparser
|
||||||
|
|
||||||
|
@ -153,7 +153,7 @@ def set_options(conf, deployer_input, non_admin, image_path, overrides=[],
|
||||||
2. read a file provided by --deployer-input argument
|
2. read a file provided by --deployer-input argument
|
||||||
3. read default DEPLOYER_INPUT if --no-deployer-input is False and no
|
3. read default DEPLOYER_INPUT if --no-deployer-input is False and no
|
||||||
deployer_input was passed
|
deployer_input was passed
|
||||||
4. set values from client's config (os-client-config support) if provided
|
4. set values from client's config (openstacksdk support) if provided
|
||||||
5. set overrides - may override values which were set in the steps above
|
5. set overrides - may override values which were set in the steps above
|
||||||
|
|
||||||
:param conf: TempestConf object
|
:param conf: TempestConf object
|
||||||
|
@ -216,7 +216,7 @@ def set_options(conf, deployer_input, non_admin, image_path, overrides=[],
|
||||||
|
|
||||||
def get_arg_parser():
|
def get_arg_parser():
|
||||||
parser = argparse.ArgumentParser(__doc__)
|
parser = argparse.ArgumentParser(__doc__)
|
||||||
cloud_config = os_client_config.OpenStackConfig()
|
cloud_config = openstack.config.OpenStackConfig()
|
||||||
cloud_config.register_argparse_arguments(parser, sys.argv)
|
cloud_config.register_argparse_arguments(parser, sys.argv)
|
||||||
parser.add_argument('--create', action='store_true', default=False,
|
parser.add_argument('--create', action='store_true', default=False,
|
||||||
help="""Create Tempest resources
|
help="""Create Tempest resources
|
||||||
|
@ -444,7 +444,7 @@ def set_cloud_config_values(non_admin, cloud_creds, conf):
|
||||||
Note: the values may be later overridden by values specified in CLI.
|
Note: the values may be later overridden by values specified in CLI.
|
||||||
|
|
||||||
:type non_admin: Boolean
|
:type non_admin: Boolean
|
||||||
:param cloud_creds: auth data from os-client-config
|
:param cloud_creds: auth data from openstacksdk
|
||||||
:type cloud_creds: dict
|
:type cloud_creds: dict
|
||||||
:param conf: TempestConf object
|
:param conf: TempestConf object
|
||||||
"""
|
"""
|
||||||
|
@ -488,12 +488,17 @@ def get_cloud_creds(args_namespace):
|
||||||
'auth_url': 'http://172.16.52.8:5000/v3',
|
'auth_url': 'http://172.16.52.8:5000/v3',
|
||||||
'password': 'f0921edc3c2b4fc8', 'project_domain_name': 'Default'}
|
'password': 'f0921edc3c2b4fc8', 'project_domain_name': 'Default'}
|
||||||
"""
|
"""
|
||||||
cloud = os_client_config.OpenStackConfig()
|
if args_namespace.os_cloud:
|
||||||
cloud = cloud.get_one_cloud(argparse=args_namespace)
|
cloud = openstack.connect(cloud=args_namespace.os_cloud)
|
||||||
cloud_creds = cloud.config.get('auth')
|
else:
|
||||||
region_name = cloud.config.get('region_name')
|
cloud = openstack.connect(argparse=args_namespace)
|
||||||
|
|
||||||
|
cloud_creds = cloud.config.get_auth_args()
|
||||||
|
region_name = cloud.config.config['region_name']
|
||||||
|
|
||||||
if region_name:
|
if region_name:
|
||||||
cloud_creds['region_name'] = region_name
|
cloud_creds['region_name'] = region_name
|
||||||
|
|
||||||
return cloud_creds
|
return cloud_creds
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -39,16 +39,7 @@ class TestOsClientConfigSupport(BaseConfigTempestTest):
|
||||||
self.assertEqual(exp_pass, password)
|
self.assertEqual(exp_pass, password)
|
||||||
self.assertEqual(exp_project, project_name)
|
self.assertEqual(exp_project, project_name)
|
||||||
|
|
||||||
@mock.patch('os_client_config.cloud_config.CloudConfig')
|
def _override_setup(self):
|
||||||
def _override_setup(self, mock_args):
|
|
||||||
cloud_args = {
|
|
||||||
'username': 'cloud_user',
|
|
||||||
'password': 'cloud_pass',
|
|
||||||
'project_name': 'cloud_project'
|
|
||||||
}
|
|
||||||
mock_function = mock.Mock(return_value=cloud_args)
|
|
||||||
func2mock = 'os_client_config.cloud_config.CloudConfig.config.get'
|
|
||||||
self.useFixture(MonkeyPatch(func2mock, mock_function))
|
|
||||||
mock_function = mock.Mock(return_value={"id": "my_fake_id"})
|
mock_function = mock.Mock(return_value={"id": "my_fake_id"})
|
||||||
func2mock = ('config_tempest.clients.ProjectsClient.'
|
func2mock = ('config_tempest.clients.ProjectsClient.'
|
||||||
'get_project_by_name')
|
'get_project_by_name')
|
||||||
|
@ -95,11 +86,7 @@ class TestOsClientConfigSupport(BaseConfigTempestTest):
|
||||||
def test_init_manager_client_config_region_name(self):
|
def test_init_manager_client_config_region_name(self):
|
||||||
self._obtain_client_config_data(region_name='regionOne')
|
self._obtain_client_config_data(region_name='regionOne')
|
||||||
|
|
||||||
@mock.patch('os_client_config.cloud_config.CloudConfig')
|
def test_init_manager_client_config_get_default(self):
|
||||||
def test_init_manager_client_config_get_default(self, mock_args):
|
|
||||||
mock_function = mock.Mock(return_value={})
|
|
||||||
func2mock = 'os_client_config.cloud_config.CloudConfig.config.get'
|
|
||||||
self.useFixture(MonkeyPatch(func2mock, mock_function))
|
|
||||||
manager = ClientManager(self.conf, self._get_creds(self.conf))
|
manager = ClientManager(self.conf, self._get_creds(self.conf))
|
||||||
# cloud_args is empty => check if default credentials were used
|
# cloud_args is empty => check if default credentials were used
|
||||||
self._check_credentials(manager,
|
self._check_credentials(manager,
|
||||||
|
|
|
@ -28,7 +28,7 @@ Import ``python-tempestconf`` in your project as follows:
|
||||||
``python-tempestconf`` needs cloud credentials in order to create a tempest
|
``python-tempestconf`` needs cloud credentials in order to create a tempest
|
||||||
configuration file. There is a helper method for obtaining cloud credentials
|
configuration file. There is a helper method for obtaining cloud credentials
|
||||||
which uses
|
which uses
|
||||||
`os-client-config <https://docs.openstack.org/os-client-config/latest/user/configuration.html>`_
|
`openstacksdk <https://docs.openstack.org/openstacksdk/latest/user/config/configuration.html>`_
|
||||||
for parsing the cloud for credentials.
|
for parsing the cloud for credentials.
|
||||||
|
|
||||||
The following example shows how to get cloud credentials and how to pass it to
|
The following example shows how to get cloud credentials and how to pass it to
|
||||||
|
|
|
@ -11,7 +11,7 @@ of the following:
|
||||||
|
|
||||||
* source OpenStack RC file before running :command:`discover-tempest-config`
|
* source OpenStack RC file before running :command:`discover-tempest-config`
|
||||||
command, see `Examples of usage with sourced credentials`_
|
command, see `Examples of usage with sourced credentials`_
|
||||||
* use ``clouds.yaml`` file and take advantage of ``os-client-config`` support
|
* use ``clouds.yaml`` file and take advantage of ``openstacksdk`` support
|
||||||
and use a named cloud, see `Examples of usage with a named cloud`_
|
and use a named cloud, see `Examples of usage with a named cloud`_
|
||||||
|
|
||||||
If a user doesn't use ``--create``, no resources, which require admin
|
If a user doesn't use ``--create``, no resources, which require admin
|
||||||
|
@ -48,7 +48,7 @@ step **as a prerequisite**:
|
||||||
|
|
||||||
.. note::
|
.. note::
|
||||||
Thanks to
|
Thanks to
|
||||||
`os-client-config <https://docs.openstack.org/os-client-config/latest/index.html>`_
|
`openstacksdk <https://docs.openstack.org/openstacksdk/latest/>`_
|
||||||
support, ``python-tempestconf`` is able to read cloud credentials from
|
support, ``python-tempestconf`` is able to read cloud credentials from
|
||||||
the shell environment, which means, they **don't need** to be
|
the shell environment, which means, they **don't need** to be
|
||||||
explicitly passed via CLI.
|
explicitly passed via CLI.
|
||||||
|
@ -249,11 +249,11 @@ Examples of usage with a named cloud
|
||||||
------------------------------------
|
------------------------------------
|
||||||
|
|
||||||
``python-tempestconf`` supports
|
``python-tempestconf`` supports
|
||||||
`os-client-config <https://opendev.org/openstack/os-client-config>`__
|
`openstacksdk <https://docs.openstack.org/openstacksdk/latest/>`__
|
||||||
so instead of sourcing an OpenStack RC file a user can use clouds.yml file.
|
so instead of sourcing an OpenStack RC file a user can use clouds.yml file.
|
||||||
Location where this file should be stored and syntax which is used to define
|
Location where this file should be stored and syntax which is used to define
|
||||||
it can be found
|
it can be found
|
||||||
`here <https://docs.openstack.org/os-client-config/latest/user/configuration.html#config-files>`__
|
`here <https://docs.openstack.org/openstacksdk/latest/user/config/configuration.html>`__
|
||||||
|
|
||||||
Let's say there is a ``clouds.yaml`` file located in ``/etc/openstack/`` with
|
Let's say there is a ``clouds.yaml`` file located in ``/etc/openstack/`` with
|
||||||
the following content:
|
the following content:
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
features:
|
||||||
|
- |
|
||||||
|
Openstacksdk module superseded os-client-config
|
||||||
|
module, therefore it is now used for parsing cloud
|
||||||
|
credentials instead of os-client-config module.
|
|
@ -6,6 +6,6 @@ pbr>=1.8 # Apache-2.0
|
||||||
six>=1.10.0 # MIT
|
six>=1.10.0 # MIT
|
||||||
tempest>=14.0.0 # Apache-2.0
|
tempest>=14.0.0 # Apache-2.0
|
||||||
requests>=2.10.0,!=2.12.2 # Apache-2.0
|
requests>=2.10.0,!=2.12.2 # Apache-2.0
|
||||||
os-client-config>=1.26.0 # Apache-2.0
|
openstacksdk>=0.11.3 # Apache-2.0
|
||||||
oslo.config>=3.23.0 # Apache-2.0
|
oslo.config>=3.23.0 # Apache-2.0
|
||||||
PyYAML>=3.12 # MIT
|
PyYAML>=3.12 # MIT
|
||||||
|
|
Loading…
Reference in New Issue