From 2d72ba511782131e1beeccd5048895206b528208 Mon Sep 17 00:00:00 2001 From: yatin Date: Mon, 9 Oct 2017 16:51:56 +0530 Subject: [PATCH] Use keystone v3 session with novaclient Keystone v2.0 is removed so we have to use keystone v3. Use already defined keystone v3 session for creating novaclient instance. Also, remove the version check for novaclient 6 as we now having novaclient >9.0.0. Change-Id: I4a98e9dad0e2a7601145c9155191c876f920abfd Closes-Bug: #1721366 --- instack_undercloud/tests/test_undercloud.py | 10 ++++++---- instack_undercloud/undercloud.py | 8 +------- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/instack_undercloud/tests/test_undercloud.py b/instack_undercloud/tests/test_undercloud.py index e3c7aea95..992ebcd66 100644 --- a/instack_undercloud/tests/test_undercloud.py +++ b/instack_undercloud/tests/test_undercloud.py @@ -696,6 +696,7 @@ class TestPostConfig(base.BaseTestCase): @mock.patch('instack_undercloud.undercloud._migrate_to_convergence') @mock.patch('instack_undercloud.undercloud._ensure_node_resource_classes') @mock.patch('instack_undercloud.undercloud._member_role_exists') + @mock.patch('instack_undercloud.undercloud._get_session') @mock.patch('ironicclient.client.get_client', autospec=True) @mock.patch('novaclient.client.Client', autospec=True) @mock.patch('swiftclient.client.Connection', autospec=True) @@ -710,8 +711,9 @@ class TestPostConfig(base.BaseTestCase): mock_configure_ssh_keys, mock_get_auth_values, mock_copy_stackrc, mock_delete, mock_mistral_client, mock_swift_client, mock_nova_client, mock_ir_client, - mock_member_role_exists, mock_resource_classes, - mock_migrate_to_convergence, mock_make_client): + mock_get_session, mock_member_role_exists, + mock_resource_classes, mock_migrate_to_convergence, + mock_make_client): instack_env = { 'UNDERCLOUD_ENDPOINT_MISTRAL_PUBLIC': 'http://192.168.24.1:8989/v2', @@ -720,6 +722,7 @@ class TestPostConfig(base.BaseTestCase): 'http://bletchley:5000/') mock_instance_nova = mock.Mock() mock_nova_client.return_value = mock_instance_nova + mock_get_session.return_value = mock.MagicMock() mock_instance_swift = mock.Mock() mock_swift_client.return_value = mock_instance_swift mock_instance_mistral = mock.Mock() @@ -737,8 +740,7 @@ class TestPostConfig(base.BaseTestCase): undercloud._post_config(instack_env, True) mock_nova_client.assert_called_with( - 2, 'aturing', '3nigma', project_name='hut8', - auth_url='http://bletchley:5000/') + 2, session=mock_get_session.return_value) self.assertTrue(mock_copy_stackrc.called) mock_configure_ssh_keys.assert_called_with(mock_instance_nova) calls = [mock.call(mock_instance_nova, flavors[0], 'baremetal', None), diff --git a/instack_undercloud/undercloud.py b/instack_undercloud/undercloud.py index a20401367..93ce18146 100644 --- a/instack_undercloud/undercloud.py +++ b/instack_undercloud/undercloud.py @@ -38,7 +38,6 @@ from keystoneclient import discover import keystoneauth1.identity.generic as ks_auth from mistralclient.api import base as mistralclient_base from mistralclient.api import client as mistralclient -import novaclient as nc from novaclient import client as novaclient from novaclient import exceptions import os_client_config @@ -1681,12 +1680,7 @@ def _post_config(instack_env, upgrade): _copy_stackrc() user, password, project, auth_url = _get_auth_values() sess = _get_session() - # TODO(andreykurilin): remove this check with support of novaclient 6.0.0 - if nc.__version__[0] == "6": - nova = novaclient.Client(2, user, password, project, auth_url=auth_url) - else: - nova = novaclient.Client(2, user, password, auth_url=auth_url, - project_name=project) + nova = novaclient.Client(2, session=sess) ironic = ir_client.get_client(1, session=sess, os_ironic_api_version='1.21')