From 19632dbac0c64ea0024967be8d330ebdadff7b33 Mon Sep 17 00:00:00 2001 From: Ethan Lynn Date: Tue, 3 Jan 2017 17:04:33 +0800 Subject: [PATCH] Fix senlin resources update failure Since senlinclient changed a little bit to call resource update, this patch correct the parameters to call senlin resource update. Change-Id: I24d00d07f2c4323c0bedd7272065ca872383536e Closes-Bug: #1653855 --- heat/engine/resources/openstack/senlin/cluster.py | 3 ++- heat/engine/resources/openstack/senlin/node.py | 3 ++- heat/engine/resources/openstack/senlin/policy.py | 3 ++- heat/engine/resources/openstack/senlin/profile.py | 3 ++- heat/tests/openstack/senlin/test_cluster.py | 2 +- heat/tests/openstack/senlin/test_node.py | 2 +- heat/tests/openstack/senlin/test_policy.py | 3 ++- heat/tests/openstack/senlin/test_profile.py | 3 ++- 8 files changed, 14 insertions(+), 8 deletions(-) diff --git a/heat/engine/resources/openstack/senlin/cluster.py b/heat/engine/resources/openstack/senlin/cluster.py index df99328456..9c8ee9b578 100644 --- a/heat/engine/resources/openstack/senlin/cluster.py +++ b/heat/engine/resources/openstack/senlin/cluster.py @@ -213,7 +213,8 @@ class Cluster(resource.Resource): **params) return resp['action'] elif action == 'cluster_update': - resp = self.client().update_cluster(self.resource_id, + cluster_obj = self.client().get_cluster(self.resource_id) + resp = self.client().update_cluster(cluster_obj, **params) return resp.location.split('/')[-1] diff --git a/heat/engine/resources/openstack/senlin/node.py b/heat/engine/resources/openstack/senlin/node.py index 2b5156a065..0c217b60a4 100644 --- a/heat/engine/resources/openstack/senlin/node.py +++ b/heat/engine/resources/openstack/senlin/node.py @@ -124,8 +124,9 @@ class Node(resource.Resource): if prop_diff: if self.PROFILE in prop_diff: prop_diff['profile_id'] = prop_diff.pop(self.PROFILE) + node_obj = self.client().get_node(self.resource_id) node = self.client().update_node( - self.resource_id, **prop_diff) + node_obj, **prop_diff) action_id = node.location.split('/')[-1] return action_id diff --git a/heat/engine/resources/openstack/senlin/policy.py b/heat/engine/resources/openstack/senlin/policy.py index b64313eacb..784cdabf5f 100644 --- a/heat/engine/resources/openstack/senlin/policy.py +++ b/heat/engine/resources/openstack/senlin/policy.py @@ -175,7 +175,8 @@ class Policy(resource.Resource): def handle_update(self, json_snippet, tmpl_diff, prop_diff): if self.NAME in prop_diff: param = {'name': prop_diff[self.NAME]} - self.client().update_policy(self.resource_id, **param) + policy_obj = self.client().get_policy(self.resource_id) + self.client().update_policy(policy_obj, **param) actions = dict() if self.BINDINGS in prop_diff: old = self.properties[self.BINDINGS] or [] diff --git a/heat/engine/resources/openstack/senlin/profile.py b/heat/engine/resources/openstack/senlin/profile.py index cd4ed8438e..5e5b503d28 100644 --- a/heat/engine/resources/openstack/senlin/profile.py +++ b/heat/engine/resources/openstack/senlin/profile.py @@ -83,7 +83,8 @@ class Profile(resource.Resource): def handle_update(self, json_snippet, tmpl_diff, prop_diff): if prop_diff: - self.client().update_profile(self.resource_id, **prop_diff) + profile_obj = self.client().get_profile(self.resource_id) + self.client().update_profile(profile_obj, **prop_diff) def _show_resource(self): profile = self.client().get_profile(self.resource_id) diff --git a/heat/tests/openstack/senlin/test_cluster.py b/heat/tests/openstack/senlin/test_cluster.py index f68e463798..9d161fec2f 100644 --- a/heat/tests/openstack/senlin/test_cluster.py +++ b/heat/tests/openstack/senlin/test_cluster.py @@ -171,7 +171,7 @@ class SenlinClusterTest(common.HeatTestCase): 'name': 'new_name' } self.senlin_mock.update_cluster.assert_called_once_with( - cluster.resource_id, **cluster_update_kwargs) + self.fake_cl, **cluster_update_kwargs) self.assertEqual(2, self.senlin_mock.get_action.call_count) def test_cluster_update_desire_capacity(self): diff --git a/heat/tests/openstack/senlin/test_node.py b/heat/tests/openstack/senlin/test_node.py index 9f632d77bf..4da1a0d87b 100644 --- a/heat/tests/openstack/senlin/test_node.py +++ b/heat/tests/openstack/senlin/test_node.py @@ -150,7 +150,7 @@ class SenlinNodeTest(common.HeatTestCase): 'name': 'new_name' } self.senlin_mock.update_node.assert_called_once_with( - node.resource_id, **node_update_kwargs) + self.fake_node, **node_update_kwargs) self.assertEqual(2, self.senlin_mock.get_action.call_count) def test_node_update_failed(self): diff --git a/heat/tests/openstack/senlin/test_policy.py b/heat/tests/openstack/senlin/test_policy.py index 139105be51..0562fde9fb 100644 --- a/heat/tests/openstack/senlin/test_policy.py +++ b/heat/tests/openstack/senlin/test_policy.py @@ -164,10 +164,11 @@ class SenlinPolicyTest(common.HeatTestCase): 'action': 'fake_action1'} self.senlin_mock.cluster_detach_policy.return_value = { 'action': 'fake_action2'} + self.senlin_mock.get_policy.return_value = self.fake_p scheduler.TaskRunner(policy.update, new_cluster)() self.assertEqual((policy.UPDATE, policy.COMPLETE), policy.state) self.senlin_mock.update_policy.assert_called_once_with( - policy.resource_id, name='new_name') + self.fake_p, name='new_name') self.senlin_mock.cluster_detach_policy.assert_called_once_with( 'c1', policy.resource_id) self.senlin_mock.cluster_attach_policy.assert_called_with( diff --git a/heat/tests/openstack/senlin/test_profile.py b/heat/tests/openstack/senlin/test_profile.py index 14abe881ba..2a0001a9d3 100644 --- a/heat/tests/openstack/senlin/test_profile.py +++ b/heat/tests/openstack/senlin/test_profile.py @@ -108,8 +108,9 @@ class SenlinProfileTest(common.HeatTestCase): def test_profile_update(self): profile = self._create_profile(self.t) prop_diff = {'metadata': {'foo': 'bar'}} + self.senlin_mock.get_profile.return_value = self.fake_p profile.handle_update(json_snippet=None, tmpl_diff=None, prop_diff=prop_diff) self.senlin_mock.update_profile.assert_called_once_with( - profile.resource_id, **prop_diff) + self.fake_p, **prop_diff)