From 603036b5a67365dd9319a95345f059eab637cc77 Mon Sep 17 00:00:00 2001 From: yanyanhu Date: Thu, 17 Sep 2015 04:42:29 -0400 Subject: [PATCH] Fix a bug in _create_nodes The index value in node name is incorrect. This patch fixes this issue. Change-Id: I452656bbd30f37bc80acaac39a495d2a3bee311f --- senlin/engine/actions/cluster_action.py | 2 +- senlin/tests/unit/engine/actions/test_cluster_action.py | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/senlin/engine/actions/cluster_action.py b/senlin/engine/actions/cluster_action.py index 3fed21d1..6ef9265c 100644 --- a/senlin/engine/actions/cluster_action.py +++ b/senlin/engine/actions/cluster_action.py @@ -99,7 +99,7 @@ class ClusterAction(base.Action): 'index': index + m, 'metadata': {} } - name = 'node-%s-%003d' % (cluster.id[:8], index) + name = 'node-%s-%003d' % (cluster.id[:8], index + m) node = node_mod.Node(name, cluster.profile_id, cluster.id, context=self.context, **kwargs) diff --git a/senlin/tests/unit/engine/actions/test_cluster_action.py b/senlin/tests/unit/engine/actions/test_cluster_action.py index ecdeb8ad..810c6379 100644 --- a/senlin/tests/unit/engine/actions/test_cluster_action.py +++ b/senlin/tests/unit/engine/actions/test_cluster_action.py @@ -238,6 +238,14 @@ class ClusterActionTest(base.SenlinTestCase): self.assertEqual([node1.id, node2.id], action.data['nodes']) self.assertEqual({'region': 'regionOne'}, node1.data['placement']) self.assertEqual({'region': 'regionTwo'}, node2.data['placement']) + mock_node_calls = [] + for i in [1, 2]: + mock_node_calls.append(mock.call('node-01234567-00%s' % i, + mock.ANY, '01234567-123434', + user=mock.ANY, project=mock.ANY, + domain=mock.ANY, index=i, + context=mock.ANY, metadata={})) + mock_node.assert_has_calls(mock_node_calls) @mock.patch.object(db_api, 'cluster_get') @mock.patch.object(node_mod, 'Node')