From 4705cce5b97662e93358c31d9fe712c71be14c60 Mon Sep 17 00:00:00 2001 From: Steve Kowalik Date: Mon, 17 Nov 2014 12:37:04 +1030 Subject: [PATCH] register_all_nodes() now accepts keystoneclient os_cloud_config.nodes.register_all_nodes() was a little bad in the fact that it would warn that it was creating a Keystone client, but you couldn't pass one in to silence the warning. Since this warns everytime register-nodes is run, silence it. Change-Id: I5e70df9a91f53f706e414ed041270f2c620977d2 --- os_cloud_config/cmd/register_nodes.py | 2 +- os_cloud_config/cmd/tests/test_register_nodes.py | 4 ++-- os_cloud_config/nodes.py | 4 ++-- os_cloud_config/tests/test_nodes.py | 1 + 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/os_cloud_config/cmd/register_nodes.py b/os_cloud_config/cmd/register_nodes.py index 5d80fd5..20b0654 100644 --- a/os_cloud_config/cmd/register_nodes.py +++ b/os_cloud_config/cmd/register_nodes.py @@ -71,7 +71,7 @@ def main(): nodes.register_all_nodes( args.service_host, nodes_list, client=client, remove=args.remove, - blocking=True) + blocking=True, keystone_client=keystone_client) except Exception: logging.exception("Unexpected error during command execution") return 1 diff --git a/os_cloud_config/cmd/tests/test_register_nodes.py b/os_cloud_config/cmd/tests/test_register_nodes.py index ca4d995..d3f95a5 100644 --- a/os_cloud_config/cmd/tests/test_register_nodes.py +++ b/os_cloud_config/cmd/tests/test_register_nodes.py @@ -46,7 +46,7 @@ class RegisterNodesTest(base.TestCase): register_mock.assert_called_once_with( "seed", {}, client='nova_bm_client_mock', remove=False, - blocking=True) + blocking=True, keystone_client='keystone_client_mock') using_ironic_mock.assert_called_once_with( keystone='keystone_client_mock') get_keystone_client_mock.assert_called_once_with() @@ -76,7 +76,7 @@ class RegisterNodesTest(base.TestCase): register_mock.assert_called_once_with( "seed", {}, client='ironic_client_mock', remove=False, - blocking=True) + blocking=True, keystone_client='keystone_client_mock') using_ironic_mock.assert_called_once_with( keystone='keystone_client_mock') get_keystone_client_mock.assert_called_once_with() diff --git a/os_cloud_config/nodes.py b/os_cloud_config/nodes.py index 92bfc6e..af50496 100644 --- a/os_cloud_config/nodes.py +++ b/os_cloud_config/nodes.py @@ -237,9 +237,9 @@ def _clean_up_extra_nodes(ironic_in_use, seen, client, remove=False): def register_all_nodes(service_host, nodes_list, client=None, remove=False, - blocking=True): + blocking=True, keystone_client=None): LOG.debug('Registering all nodes.') - ironic_in_use = using_ironic(keystone=None) + ironic_in_use = using_ironic(keystone=keystone_client) if ironic_in_use: if client is None: LOG.warn('Creating ironic client inline is deprecated, please ' diff --git a/os_cloud_config/tests/test_nodes.py b/os_cloud_config/tests/test_nodes.py index 8312c74..81fb0bc 100644 --- a/os_cloud_config/tests/test_nodes.py +++ b/os_cloud_config/tests/test_nodes.py @@ -201,6 +201,7 @@ class NodesTest(base.TestCase): port_call = mock.call(node_uuid=ironic.node.create.return_value.uuid, address='aaa') power_off_call = mock.call(ironic.node.create.return_value.uuid, 'off') + using_ironic.assert_called_once_with(keystone=None) ironic.node.create.assert_has_calls([pxe_node, mock.ANY]) ironic.port.create.assert_has_calls([port_call]) ironic.node.set_power_state.assert_has_calls([power_off_call])