Support profile-only to cluster update

This path revises action_cluster_update api.
Then cluster-update api could support 'profile-only' parameter.
partial-blueprint: add-profile-only-to-cluster-update

Change-Id: I51880919b131ce4b6f5ff44ee70d0a97d795f9ed
This commit is contained in:
chohoor 2017-02-21 11:01:00 +08:00
parent 67629a881a
commit 9d689c1510
2 changed files with 26 additions and 0 deletions

View File

@ -258,6 +258,7 @@ class ClusterAction(base.Action):
metadata = self.inputs.get('metadata')
timeout = self.inputs.get('timeout')
profile_id = self.inputs.get('new_profile_id')
profile_only = self.inputs.get('profile_only')
if name is not None:
self.entity.name = name
@ -273,6 +274,14 @@ class ClusterAction(base.Action):
updated_at=timeutils.utcnow(True))
return self.RES_OK, reason
# profile_only's type is bool
if profile_only:
self.entity.profile_id = profile_id
self.entity.eval_status(self.context, consts.CLUSTER_UPDATE,
profile_id=profile_id,
updated_at=timeutils.utcnow(True))
return self.RES_OK, reason
# Update nodes with new profile
result, reason = self._update_nodes(profile_id, self.entity.nodes)
return result, reason

View File

@ -106,6 +106,23 @@ class ClusterUpdateTest(base.SenlinTestCase):
cluster.eval_status.assert_called_once_with(
action.context, consts.CLUSTER_UPDATE, updated_at=mock.ANY)
def test_do_update_profile_only(self, mock_load):
cluster = mock.Mock(id='FAKE_ID', nodes=[], ACTIVE='ACTIVE')
mock_load.return_value = cluster
action = ca.ClusterAction(cluster.id, 'CLUSTER_ACTION', self.ctx)
action.inputs = {'name': 'FAKE_NAME',
'metadata': {'foo': 'bar'},
'timeout': 3600,
'new_profile_id': 'FAKE_PROFILE',
'profile_only': True}
res_code, res_msg = action.do_update()
self.assertEqual(action.RES_OK, res_code)
self.assertEqual('Cluster update completed.', res_msg)
cluster.eval_status.assert_called_once_with(
action.context, consts.CLUSTER_UPDATE, profile_id='FAKE_PROFILE',
updated_at=mock.ANY)
def test_do_update_empty_cluster(self, mock_load):
cluster = mock.Mock(id='FAKE_ID', nodes=[], ACTIVE='ACTIVE')
mock_load.return_value = cluster