Replace the definition about action cause in action with it in consts

This patch replaces the definition about action cause in action base
class with the definition in consts module.

Change-Id: I262dc188fd62f764c2e293793992aa0f802f3dae
This commit is contained in:
miaohb 2017-01-06 17:19:17 +08:00
parent e8ac4a2a71
commit 72297dce8b
16 changed files with 103 additions and 108 deletions

View File

@ -31,15 +31,6 @@ from senlin.policies import base as policy_mod
wallclock = time.time
LOG = logging.getLogger(__name__)
# TODO(Qiming): Replace this with definitions in consts
# Action causes
CAUSES = (
CAUSE_RPC, CAUSE_DERIVED,
) = (
'RPC Request',
'Derived Action',
)
class Action(object):
'''An action can be performed on a cluster or a node of a cluster.'''

View File

@ -132,7 +132,7 @@ class ClusterAction(base.Action):
kwargs = {
'name': 'node_create_%s' % node.id[:8],
'cause': base.CAUSE_DERIVED,
'cause': consts.CAUSE_DERIVED,
}
action_id = base.Action.create(self.context, node.id,
consts.NODE_CREATE, **kwargs)
@ -209,7 +209,7 @@ class ClusterAction(base.Action):
for node in nodes:
kwargs = {
'name': 'node_update_%s' % node[:8],
'cause': base.CAUSE_DERIVED,
'cause': consts.CAUSE_DERIVED,
'inputs': {
'new_profile_id': profile_id,
},
@ -291,7 +291,7 @@ class ClusterAction(base.Action):
for node_id in node_ids:
kwargs = {
'name': 'node_delete_%s' % node_id[:8],
'cause': base.CAUSE_DERIVED,
'cause': consts.CAUSE_DERIVED,
}
action_id = base.Action.create(self.context, node_id, action_name,
**kwargs)
@ -408,7 +408,7 @@ class ClusterAction(base.Action):
nid = node.id
kwargs = {
'name': 'node_join_%s' % nid[:8],
'cause': base.CAUSE_DERIVED,
'cause': consts.CAUSE_DERIVED,
'inputs': {'cluster_id': self.target},
}
action_id = base.Action.create(self.context, nid, consts.NODE_JOIN,
@ -560,7 +560,7 @@ class ClusterAction(base.Action):
children = []
for (original, replacement) in node_dict.items():
kwargs = {
'cause': base.CAUSE_DERIVED,
'cause': consts.CAUSE_DERIVED,
}
# node_leave action
@ -617,7 +617,7 @@ class ClusterAction(base.Action):
action_id = base.Action.create(
self.context, node_id, consts.NODE_CHECK,
name='node_check_%s' % node_id[:8],
cause=base.CAUSE_DERIVED,
cause=consts.CAUSE_DERIVED,
)
child.append(action_id)
@ -665,7 +665,7 @@ class ClusterAction(base.Action):
action_id = base.Action.create(
self.context, node_id, consts.NODE_RECOVER,
name='node_recover_%s' % node_id[:8],
cause=base.CAUSE_DERIVED, inputs=inputs,
cause=consts.CAUSE_DERIVED, inputs=inputs,
)
children.append(action_id)
@ -919,7 +919,7 @@ class ClusterAction(base.Action):
action_id = base.Action.create(
self.context, node_id, consts.NODE_OPERATION,
name='node_%s_%s' % (operation, node_id[:8]),
cause=base.CAUSE_DERIVED,
cause=consts.CAUSE_DERIVED,
inputs=inputs,
)
child.append(action_id)

View File

@ -53,7 +53,7 @@ class NodeAction(base.Action):
:returns: A tuple containing the result and the corresponding reason.
"""
cluster_id = self.entity.cluster_id
if cluster_id and self.cause == base.CAUSE_RPC:
if cluster_id and self.cause == consts.CAUSE_RPC:
# Check cluster size constraint if target cluster is specified
cluster = cm.Cluster.load(self.context, cluster_id)
desired = no.Node.count_by_cluster(self.context, cluster_id)
@ -66,7 +66,7 @@ class NodeAction(base.Action):
res = self.entity.do_create(self.context)
if cluster_id and self.cause == base.CAUSE_RPC:
if cluster_id and self.cause == consts.CAUSE_RPC:
# Update cluster's desired_capacity and re-evaluate its status no
# matter the creation is a success or not because the node object
# is # already treated as member of the cluster and the node
@ -85,7 +85,7 @@ class NodeAction(base.Action):
:returns: A tuple containing the result and the corresponding reason.
"""
cluster_id = self.entity.cluster_id
if cluster_id and self.cause == base.CAUSE_RPC:
if cluster_id and self.cause == consts.CAUSE_RPC:
# If node belongs to a cluster, check size constraint
# before deleting it
cluster = cm.Cluster.load(self.context, cluster_id)
@ -104,7 +104,7 @@ class NodeAction(base.Action):
res = self.entity.do_delete(self.context)
if cluster_id and self.cause == base.CAUSE_RPC:
if cluster_id and self.cause == consts.CAUSE_RPC:
# check if desired_capacity should be changed
do_reduce = True
params = {}
@ -230,7 +230,7 @@ class NodeAction(base.Action):
# Since node.cluster_id could be reset to '' during action execution,
# we record it here for policy check and cluster lock release.
saved_cluster_id = self.entity.cluster_id
if (saved_cluster_id and self.cause == base.CAUSE_RPC):
if (saved_cluster_id and self.cause == consts.CAUSE_RPC):
res = senlin_lock.cluster_lock_acquire(
self.context, self.entity.cluster_id, self.id, self.owner,
senlin_lock.NODE_SCOPE, False)
@ -255,7 +255,7 @@ class NodeAction(base.Action):
else:
res, reason = self._execute()
if (res == self.RES_OK and saved_cluster_id and
self.cause == base.CAUSE_RPC):
self.cause == consts.CAUSE_RPC):
self.policy_check(saved_cluster_id, 'AFTER')
if self.data['status'] != pb.CHECK_OK:
res = self.RES_ERROR
@ -264,7 +264,7 @@ class NodeAction(base.Action):
res = self.RES_OK
finally:
senlin_lock.node_lock_release(self.entity.id, self.id)
if saved_cluster_id and self.cause == base.CAUSE_RPC:
if saved_cluster_id and self.cause == consts.CAUSE_RPC:
senlin_lock.cluster_lock_release(saved_cluster_id, self.id,
senlin_lock.NODE_SCOPE)
return res, reason

View File

@ -203,7 +203,7 @@ class Message(base.Receiver):
kwargs = {
'name': 'receiver_%s_%s' % (self.id[:8], message['id'][:8]),
'cause': action_mod.CAUSE_RPC,
'cause': consts.CAUSE_RPC,
'status': action_mod.Action.READY,
'inputs': params
}

View File

@ -774,7 +774,7 @@ class EngineService(service.Service):
# Build an Action for cluster creation
kwargs = {
'name': 'cluster_create_%s' % cluster.id[:8],
'cause': action_mod.CAUSE_RPC,
'cause': consts.CAUSE_RPC,
'status': action_mod.Action.READY,
}
action_id = action_mod.Action.create(ctx, cluster.id,
@ -837,7 +837,7 @@ class EngineService(service.Service):
kwargs = {
'name': 'cluster_update_%s' % cluster.id[:8],
'cause': action_mod.CAUSE_RPC,
'cause': consts.CAUSE_RPC,
'status': action_mod.Action.READY,
'inputs': inputs,
}
@ -898,7 +898,7 @@ class EngineService(service.Service):
params = {
'name': 'cluster_delete_%s' % cluster.id[:8],
'cause': action_mod.CAUSE_RPC,
'cause': consts.CAUSE_RPC,
'status': action_mod.Action.READY,
}
action_id = action_mod.Action.create(ctx, cluster.id,
@ -975,7 +975,7 @@ class EngineService(service.Service):
params = {
'name': 'cluster_add_nodes_%s' % db_cluster.id[:8],
'cause': action_mod.CAUSE_RPC,
'cause': consts.CAUSE_RPC,
'status': action_mod.Action.READY,
'inputs': {'nodes': found},
}
@ -1042,7 +1042,7 @@ class EngineService(service.Service):
params = {
'name': 'cluster_del_nodes_%s' % db_cluster.id[:8],
'cause': action_mod.CAUSE_RPC,
'cause': consts.CAUSE_RPC,
'status': action_mod.Action.READY,
'inputs': {
'candidates': found,
@ -1150,7 +1150,7 @@ class EngineService(service.Service):
nodes = self._validate_replace_nodes(ctx, db_cluster, req.nodes)
kwargs = {
'name': 'cluster_replace_nodes_%s' % db_cluster.id[:8],
'cause': action_mod.CAUSE_RPC,
'cause': consts.CAUSE_RPC,
'status': action_mod.Action.READY,
'inputs': nodes,
}
@ -1235,7 +1235,7 @@ class EngineService(service.Service):
params = {
'name': 'cluster_resize_%s' % db_cluster.id[:8],
'cause': action_mod.CAUSE_RPC,
'cause': consts.CAUSE_RPC,
'status': action_mod.Action.READY,
'inputs': {
consts.ADJUSTMENT_TYPE: adj_type,
@ -1281,7 +1281,7 @@ class EngineService(service.Service):
params = {
'name': 'cluster_scale_out_%s' % db_cluster.id[:8],
'cause': action_mod.CAUSE_RPC,
'cause': consts.CAUSE_RPC,
'status': action_mod.Action.READY,
'inputs': inputs,
}
@ -1321,7 +1321,7 @@ class EngineService(service.Service):
params = {
'name': 'cluster_scale_in_%s' % db_cluster.id[:8],
'cause': action_mod.CAUSE_RPC,
'cause': consts.CAUSE_RPC,
'status': action_mod.Action.READY,
'inputs': inputs,
}
@ -1375,7 +1375,7 @@ class EngineService(service.Service):
params = {
'name': 'cluster_check_%s' % db_cluster.id[:8],
'cause': action_mod.CAUSE_RPC,
'cause': consts.CAUSE_RPC,
'status': action_mod.Action.READY,
'inputs': req.params if req.obj_attr_is_set('params') else {}
}
@ -1404,7 +1404,7 @@ class EngineService(service.Service):
params = {
'name': 'cluster_recover_%s' % db_cluster.id[:8],
'cause': action_mod.CAUSE_RPC,
'cause': consts.CAUSE_RPC,
'status': action_mod.Action.READY,
'inputs': req.params if req.obj_attr_is_set('params') else {}
}
@ -1465,7 +1465,7 @@ class EngineService(service.Service):
kwargs = {
'name': 'cluster_%s_%s' % (req.operation, cluster.id[:8]),
'cause': action_mod.CAUSE_RPC,
'cause': consts.CAUSE_RPC,
'status': action_mod.Action.READY,
'inputs': {
'operation': req.operation,
@ -1578,7 +1578,7 @@ class EngineService(service.Service):
params = {
'name': 'node_create_%s' % node.id[:8],
'cause': action_mod.CAUSE_RPC,
'cause': consts.CAUSE_RPC,
'status': action_mod.Action.READY,
}
action_id = action_mod.Action.create(ctx, node.id,
@ -1655,7 +1655,7 @@ class EngineService(service.Service):
params = {
'name': 'node_update_%s' % db_node.id[:8],
'cause': action_mod.CAUSE_RPC,
'cause': consts.CAUSE_RPC,
'status': action_mod.Action.READY,
'inputs': inputs,
}
@ -1698,7 +1698,7 @@ class EngineService(service.Service):
params = {
'name': 'node_delete_%s' % node.id[:8],
'cause': action_mod.CAUSE_RPC,
'cause': consts.CAUSE_RPC,
'status': action_mod.Action.READY,
}
action_id = action_mod.Action.create(ctx, node.id,
@ -1723,7 +1723,7 @@ class EngineService(service.Service):
kwargs = {
'name': 'node_check_%s' % db_node.id[:8],
'cause': action_mod.CAUSE_RPC,
'cause': consts.CAUSE_RPC,
'status': action_mod.Action.READY
}
if req.obj_attr_is_set('params') and req.params:
@ -1750,7 +1750,7 @@ class EngineService(service.Service):
kwargs = {
'name': 'node_recover_%s' % db_node.id[:8],
'cause': action_mod.CAUSE_RPC,
'cause': consts.CAUSE_RPC,
'status': action_mod.Action.READY
}
if req.obj_attr_is_set('params') and req.params:
@ -1793,7 +1793,7 @@ class EngineService(service.Service):
kwargs = {
'name': 'node_%s_%s' % (req.operation, db_node.id[:8]),
'cause': action_mod.CAUSE_RPC,
'cause': consts.CAUSE_RPC,
'status': action_mod.Action.READY,
'inputs': {
'operation': req.operation,
@ -1877,7 +1877,7 @@ class EngineService(service.Service):
params = {
'name': 'attach_policy_%s' % db_cluster.id[:8],
'cause': action_mod.CAUSE_RPC,
'cause': consts.CAUSE_RPC,
'status': action_mod.Action.READY,
'inputs': {
'policy_id': db_policy.id,
@ -1922,7 +1922,7 @@ class EngineService(service.Service):
params = {
'name': 'detach_policy_%s' % db_cluster.id[:8],
'cause': action_mod.CAUSE_RPC,
'cause': consts.CAUSE_RPC,
'status': action_mod.Action.READY,
'inputs': {'policy_id': db_policy.id},
}
@ -1967,7 +1967,7 @@ class EngineService(service.Service):
params = {
'name': 'update_policy_%s' % db_cluster.id[:8],
'cause': action_mod.CAUSE_RPC,
'cause': consts.CAUSE_RPC,
'status': action_mod.Action.READY,
'inputs': inputs
}
@ -2036,7 +2036,7 @@ class EngineService(service.Service):
# Create an action instance
params = {
'name': req.name,
'cause': action_mod.CAUSE_RPC,
'cause': consts.CAUSE_RPC,
'status': action_mod.Action.READY,
'inputs': req.inputs or {},
}
@ -2263,7 +2263,7 @@ class EngineService(service.Service):
kwargs = {
'name': 'webhook_%s' % receiver.id[:8],
'cause': action_mod.CAUSE_RPC,
'cause': consts.CAUSE_RPC,
'status': action_mod.Action.READY,
'inputs': data
}

View File

@ -63,10 +63,10 @@ class ClusterCheckTest(base.SenlinTestCase):
mock_action.assert_has_calls([
mock.call(action.context, 'NODE_1', 'NODE_CHECK',
name='node_check_NODE_1',
cause=ab.CAUSE_DERIVED),
cause=consts.CAUSE_DERIVED),
mock.call(action.context, 'NODE_2', 'NODE_CHECK',
name='node_check_NODE_2',
cause=ab.CAUSE_DERIVED)
cause=consts.CAUSE_DERIVED)
])
mock_dep.assert_called_once_with(action.context,
['NODE_ACTION_1', 'NODE_ACTION_2'],
@ -127,7 +127,7 @@ class ClusterCheckTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
action.context, 'NODE_1', 'NODE_CHECK',
name='node_check_NODE_1',
cause=ab.CAUSE_DERIVED,
cause=consts.CAUSE_DERIVED,
)
mock_dep.assert_called_once_with(action.context, ['NODE_ACTION_ID'],
'CLUSTER_ACTION_ID')

View File

@ -72,7 +72,7 @@ class NodeActionTest(base.SenlinTestCase):
mock_count.return_value = 11
mock_check.return_value = None
action = node_action.NodeAction(node.id, 'ACTION', self.ctx,
cause=base_action.CAUSE_RPC)
cause=consts.CAUSE_RPC)
# do it
res_code, res_msg = action.do_create()
@ -101,7 +101,7 @@ class NodeActionTest(base.SenlinTestCase):
mock_count.return_value = 11
mock_check.return_value = 'overflow'
action = node_action.NodeAction(node.id, 'ACTION', self.ctx,
cause=base_action.CAUSE_RPC)
cause=consts.CAUSE_RPC)
# do it
res_code, res_msg = action.do_create()
@ -131,7 +131,7 @@ class NodeActionTest(base.SenlinTestCase):
mock_count.return_value = 11
mock_check.return_value = ''
action = node_action.NodeAction(node.id, 'ACTION', self.ctx,
cause=base_action.CAUSE_RPC)
cause=consts.CAUSE_RPC)
# do it
res_code, res_msg = action.do_create()
@ -186,7 +186,7 @@ class NodeActionTest(base.SenlinTestCase):
mock_count.return_value = 2
mock_check.return_value = None
action = node_action.NodeAction(node.id, 'ACTION', self.ctx,
cause=base_action.CAUSE_RPC)
cause=consts.CAUSE_RPC)
# do it
res_code, res_msg = action.do_delete()
@ -214,7 +214,7 @@ class NodeActionTest(base.SenlinTestCase):
mock_count.return_value = 2
mock_check.return_value = 'underflow'
action = node_action.NodeAction(node.id, 'ACTION', self.ctx,
cause=base_action.CAUSE_RPC)
cause=consts.CAUSE_RPC)
res_code, res_msg = action.do_delete()
@ -242,7 +242,7 @@ class NodeActionTest(base.SenlinTestCase):
mock_count.return_value = 2
mock_check.return_value = None
action = node_action.NodeAction(node.id, 'ACTION', self.ctx,
cause=base_action.CAUSE_RPC)
cause=consts.CAUSE_RPC)
res_code, res_msg = action.do_delete()
@ -271,7 +271,7 @@ class NodeActionTest(base.SenlinTestCase):
mock_count.return_value = 2
mock_check.return_value = None
action = node_action.NodeAction(
node.id, 'ACTION', self.ctx, cause=base_action.CAUSE_RPC,
node.id, 'ACTION', self.ctx, cause=consts.CAUSE_RPC,
data={'deletion': {'grace_period': 10}})
# do it
@ -304,7 +304,7 @@ class NodeActionTest(base.SenlinTestCase):
mock_check.return_value = None
action = node_action.NodeAction(
'NID', 'ACTION', self.ctx,
cause=base_action.CAUSE_RPC,
cause=consts.CAUSE_RPC,
data={'deletion': {'reduce_desired_capacity': True}})
# do it
@ -335,7 +335,7 @@ class NodeActionTest(base.SenlinTestCase):
mock_check.return_value = None
action = node_action.NodeAction(
'NID', 'ACTION', self.ctx,
cause=base_action.CAUSE_RPC,
cause=consts.CAUSE_RPC,
data={'deletion': {'reduce_desired_capacity': False}})
# do it
@ -357,7 +357,7 @@ class NodeActionTest(base.SenlinTestCase):
node.do_delete.return_value = True
mock_load.return_value = node
action = node_action.NodeAction(node.id, 'ACTION', self.ctx,
cause=base_action.CAUSE_DERIVED)
cause=consts.CAUSE_DERIVED)
res_code, res_msg = action.do_delete()
@ -371,7 +371,7 @@ class NodeActionTest(base.SenlinTestCase):
node.do_delete.return_value = False
mock_load.return_value = node
action = node_action.NodeAction(node.id, 'ACTION', self.ctx,
cause=base_action.CAUSE_DERIVED)
cause=consts.CAUSE_DERIVED)
res_code, res_msg = action.do_delete()
@ -633,7 +633,7 @@ class NodeActionTest(base.SenlinTestCase):
node = mock.Mock(id=node_id, cluster_id='FAKE_CLUSTER')
mock_load.return_value = node
action = node_action.NodeAction(node_id, 'NODE_FLY', self.ctx,
cause=base_action.CAUSE_DERIVED)
cause=consts.CAUSE_DERIVED)
action.id = 'ACTION_ID'
action.owner = 'OWNER'
mock_exec = self.patchobject(action, '_execute',

View File

@ -12,6 +12,7 @@
import mock
from senlin.common import consts
from senlin.engine.actions import base as ab
from senlin.engine.actions import cluster_action as ca
from senlin.engine import cluster as cm
@ -60,13 +61,13 @@ class ClusterOperationTest(base.SenlinTestCase):
operation='dance')
mock_action.assert_has_calls([
mock.call(action.context, 'NODE_ID_1', 'NODE_OPERATION',
name='node_dance_NODE_ID_', cause=ab.CAUSE_DERIVED,
name='node_dance_NODE_ID_', cause=consts.CAUSE_DERIVED,
inputs={
'operation': 'dance',
'params': {'style': 'tango'}
}),
mock.call(action.context, 'NODE_ID_2', 'NODE_OPERATION',
name='node_dance_NODE_ID_', cause=ab.CAUSE_DERIVED,
name='node_dance_NODE_ID_', cause=consts.CAUSE_DERIVED,
inputs={
'operation': 'dance',
'params': {'style': 'tango'}
@ -114,13 +115,13 @@ class ClusterOperationTest(base.SenlinTestCase):
operation='dance')
mock_action.assert_has_calls([
mock.call(action.context, 'NODE_ID_1', 'NODE_OPERATION',
name='node_dance_NODE_ID_', cause=ab.CAUSE_DERIVED,
name='node_dance_NODE_ID_', cause=consts.CAUSE_DERIVED,
inputs={
'operation': 'dance',
'params': {'style': 'tango'}
}),
mock.call(action.context, 'NODE_ID_2', 'NODE_OPERATION',
name='node_dance_NODE_ID_', cause=ab.CAUSE_DERIVED,
name='node_dance_NODE_ID_', cause=consts.CAUSE_DERIVED,
inputs={
'operation': 'dance',
'params': {'style': 'tango'}

View File

@ -63,7 +63,7 @@ class ClusterRecoverTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
action.context, 'NODE_2', 'NODE_RECOVER',
name='node_recover_NODE_2',
cause=ab.CAUSE_DERIVED,
cause=consts.CAUSE_DERIVED,
inputs={}
)
mock_dep.assert_called_once_with(action.context, ['NODE_RECOVER_ID'],
@ -110,7 +110,7 @@ class ClusterRecoverTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
action.context, 'NODE_1', 'NODE_RECOVER',
name='node_recover_NODE_1',
cause=ab.CAUSE_DERIVED,
cause=consts.CAUSE_DERIVED,
inputs={'operation': 'REBOOT', 'params': None}
)
mock_dep.assert_called_once_with(action.context, ['NODE_RECOVER_ID'],
@ -171,7 +171,7 @@ class ClusterRecoverTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
action.context, 'NODE_1', 'NODE_RECOVER',
name='node_recover_NODE_1',
cause=ab.CAUSE_DERIVED,
cause=consts.CAUSE_DERIVED,
inputs={}
)
mock_dep.assert_called_once_with(action.context, ['NODE_ACTION_ID'],

View File

@ -18,6 +18,7 @@ from keystoneauth1 import loading as ks_loading
from oslo_config import cfg
from oslo_utils import uuidutils
from senlin.common import consts
from senlin.common import exception
from senlin.common.i18n import _
from senlin.drivers import base as driver_base
@ -617,7 +618,7 @@ class TestMessage(base.SenlinTestCase):
message.user = 'user1'
expected_kwargs = {
'name': 'receiver_ID654321_ID123456',
'cause': action_mod.CAUSE_RPC,
'cause': consts.CAUSE_RPC,
'status': action_mod.Action.READY,
'inputs': {}
}

View File

@ -14,6 +14,7 @@ import mock
from oslo_messaging.rpc import dispatcher as rpc
import six
from senlin.common import consts
from senlin.common import exception as exc
from senlin.engine.actions import base as ab
from senlin.engine import service
@ -117,7 +118,7 @@ class ActionTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, 'FAKE_CLUSTER', 'CLUSTER_CREATE',
name='a1',
cause=ab.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=ab.Action.READY,
inputs={})

View File

@ -72,7 +72,7 @@ class ClusterOpTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, '12345678AB', consts.CLUSTER_OPERATION,
name='cluster_dance_12345678',
cause=am.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=am.Action.READY,
inputs={
'operation': 'dance',
@ -179,7 +179,7 @@ class ClusterOpTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, '12345678AB', consts.CLUSTER_OPERATION,
name='cluster_dance_12345678',
cause=am.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=am.Action.READY,
inputs={
'operation': 'dance',
@ -221,7 +221,7 @@ class ClusterOpTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, '12345678AB', consts.CLUSTER_OPERATION,
name='cluster_dance_12345678',
cause=am.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=am.Action.READY,
inputs={
'operation': 'dance',

View File

@ -194,7 +194,7 @@ class ClusterPolicyTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, '12345678abcd', consts.CLUSTER_ATTACH_POLICY,
name='attach_policy_12345678',
cause=action_mod.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=action_mod.Action.READY,
inputs={'policy_id': '87654321abcd', 'enabled': True},
)
@ -259,7 +259,7 @@ class ClusterPolicyTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, '12345678abcd', consts.CLUSTER_DETACH_POLICY,
name='detach_policy_12345678',
cause=action_mod.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=action_mod.Action.READY,
inputs={'policy_id': '87654321abcd'},
)
@ -347,7 +347,7 @@ class ClusterPolicyTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, '12345678abcd', consts.CLUSTER_UPDATE_POLICY,
name='update_policy_12345678',
cause=action_mod.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=action_mod.Action.READY,
inputs={'policy_id': '87654321abcd', 'enabled': False},
)

View File

@ -151,7 +151,7 @@ class ClusterTest(base.SenlinTestCase):
self.ctx,
'12345678ABC', 'CLUSTER_CREATE',
name='cluster_create_12345678',
cause=am.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=am.Action.READY,
)
notify.assert_called_once_with()
@ -292,7 +292,7 @@ class ClusterTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, '12345678AB', 'CLUSTER_UPDATE',
name='cluster_update_12345678',
cause=am.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=am.Action.READY,
inputs={
'new_profile_id': 'ID_NEW',
@ -428,7 +428,7 @@ class ClusterTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, '12345678AB', 'CLUSTER_UPDATE',
name='cluster_update_12345678',
cause=am.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=am.Action.READY,
inputs={
# Note profile_id is not shown in the inputs
@ -463,7 +463,7 @@ class ClusterTest(base.SenlinTestCase):
self.ctx, '12345678AB', 'CLUSTER_UPDATE',
name='cluster_update_12345678',
status=am.Action.READY,
cause=am.CAUSE_RPC,
cause=consts.CAUSE_RPC,
inputs={
# Note metadata is not included in the inputs
'name': 'NEW_NAME',
@ -536,7 +536,7 @@ class ClusterTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, '12345678AB', consts.CLUSTER_ADD_NODES,
name='cluster_add_nodes_12345678',
cause=am.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=am.Action.READY,
inputs={'nodes': ['NODE1', 'NODE2']},
)
@ -738,7 +738,7 @@ class ClusterTest(base.SenlinTestCase):
self.ctx, '1234', consts.CLUSTER_DEL_NODES,
name='cluster_del_nodes_1234',
status=am.Action.READY,
cause=am.CAUSE_RPC,
cause=consts.CAUSE_RPC,
inputs={
'count': 1,
'candidates': ['NODE2'],
@ -908,7 +908,7 @@ class ClusterTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, '12345678ABCDEFGH', consts.CLUSTER_RESIZE,
name='cluster_resize_12345678',
cause=am.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=am.Action.READY,
inputs={
consts.ADJUSTMENT_TYPE: consts.EXACT_CAPACITY,
@ -952,7 +952,7 @@ class ClusterTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, '12345678ABCDEFGH', consts.CLUSTER_RESIZE,
name='cluster_resize_12345678',
cause=am.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=am.Action.READY,
inputs={
consts.ADJUSTMENT_TYPE: consts.CHANGE_IN_CAPACITY,
@ -996,7 +996,7 @@ class ClusterTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, '12345678ABCDEFGH', consts.CLUSTER_RESIZE,
name='cluster_resize_12345678',
cause=am.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=am.Action.READY,
inputs={
consts.ADJUSTMENT_TYPE: consts.CHANGE_IN_PERCENTAGE,
@ -1120,7 +1120,7 @@ class ClusterTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, '12345678ABCDEFGH', consts.CLUSTER_SCALE_OUT,
name='cluster_scale_out_12345678',
cause=am.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=am.Action.READY,
inputs={'count': 1},
)
@ -1158,7 +1158,7 @@ class ClusterTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, '12345678ABCDEFGH', consts.CLUSTER_SCALE_OUT,
name='cluster_scale_out_12345678',
cause=am.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=am.Action.READY,
inputs={},
)
@ -1216,7 +1216,7 @@ class ClusterTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, '12345678ABCD', consts.CLUSTER_SCALE_IN,
name='cluster_scale_in_12345678',
cause=am.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=am.Action.READY,
inputs={'count': 2},
)
@ -1253,7 +1253,7 @@ class ClusterTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, 'FOO', consts.CLUSTER_SCALE_IN,
name='cluster_scale_in_FOO',
cause=am.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=am.Action.READY,
inputs={},
)
@ -1307,7 +1307,7 @@ class ClusterTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, 'CID', consts.CLUSTER_CHECK,
name='cluster_check_CID',
cause=am.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=am.Action.READY,
inputs={'foo': 'bar'},
)
@ -1330,7 +1330,7 @@ class ClusterTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, 'CID', consts.CLUSTER_CHECK,
name='cluster_check_CID',
cause=am.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=am.Action.READY,
inputs={},
)
@ -1367,7 +1367,7 @@ class ClusterTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, 'CID', consts.CLUSTER_RECOVER,
name='cluster_recover_CID',
cause=am.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=am.Action.READY,
inputs={'foo': 'bar'},
)
@ -1406,7 +1406,7 @@ class ClusterTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, 'CID', consts.CLUSTER_RECOVER,
name='cluster_recover_CID',
cause=am.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=am.Action.READY,
inputs={},
)
@ -1625,7 +1625,7 @@ class ClusterTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, 'CID', consts.CLUSTER_REPLACE_NODES,
name='cluster_replace_nodes_CID',
cause=am.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=am.Action.READY,
inputs={'ORIGINAL': 'REPLACE'})
notify.assert_called_once_with()
@ -1794,7 +1794,7 @@ class ClusterTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, '12345678AB', 'CLUSTER_DELETE',
name='cluster_delete_12345678',
cause=am.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=am.Action.READY)
notify.assert_called_once_with()

View File

@ -167,7 +167,7 @@ class NodeTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, 'NODE_ID', consts.NODE_CREATE,
name='node_create_NODE_ID',
cause=action_mod.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=action_mod.Action.READY)
notify.assert_called_once_with()
@ -209,7 +209,7 @@ class NodeTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, 'NODE_ID', consts.NODE_CREATE,
name='node_create_NODE_ID',
cause=action_mod.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=action_mod.Action.READY)
notify.assert_called_once_with()
@ -256,7 +256,7 @@ class NodeTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, 'NODE_ID', consts.NODE_CREATE,
name='node_create_NODE_ID',
cause=action_mod.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=action_mod.Action.READY)
notify.assert_called_once_with()
@ -436,7 +436,7 @@ class NodeTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, 'FAKE_NODE_ID', consts.NODE_UPDATE,
name='node_update_FAKE_NOD',
cause=action_mod.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=action_mod.Action.READY,
inputs={
'name': 'NODE2',
@ -487,7 +487,7 @@ class NodeTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, 'FAKE_NODE_ID', consts.NODE_UPDATE,
name='node_update_FAKE_NOD',
cause=action_mod.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=action_mod.Action.READY,
inputs={
'new_profile_id': 'NEW_PROFILE_ID',
@ -588,7 +588,7 @@ class NodeTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, '12345678AB', consts.NODE_DELETE,
name='node_delete_12345678',
cause=action_mod.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=action_mod.Action.READY)
mock_start.assert_called_once_with()
@ -652,7 +652,7 @@ class NodeTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, '12345678AB', consts.NODE_CHECK,
name='node_check_12345678',
cause=action_mod.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=action_mod.Action.READY,
inputs={'k1': 'v1'})
mock_start.assert_called_once_with()
@ -687,7 +687,7 @@ class NodeTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, '12345678AB', consts.NODE_RECOVER,
name='node_recover_12345678',
cause=action_mod.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=action_mod.Action.READY,
inputs={'k1': 'v1'})
mock_start.assert_called_once_with()
@ -733,7 +733,7 @@ class NodeTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, '12345678AB', consts.NODE_OPERATION,
name='node_dance_12345678',
cause=action_mod.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=action_mod.Action.READY,
inputs={'operation': 'dance', 'params': {'style': 'tango'}})
mock_start.assert_called_once_with()

View File

@ -14,6 +14,7 @@ import mock
from oslo_messaging.rpc import dispatcher as rpc
import six
from senlin.common import consts
from senlin.common import exception
from senlin.engine.actions import base as action_mod
from senlin.engine import dispatcher
@ -57,7 +58,7 @@ class WebhookTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, 'FAKE_CLUSTER', 'DANCE',
name='webhook_01234567',
cause=action_mod.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=action_mod.Action.READY,
inputs={'kee': 'vee', 'foo': 'bar'},
)
@ -88,7 +89,7 @@ class WebhookTest(base.SenlinTestCase):
mock_action.assert_called_once_with(
self.ctx, 'FAKE_CLUSTER', 'DANCE',
name='webhook_01234567',
cause=action_mod.CAUSE_RPC,
cause=consts.CAUSE_RPC,
status=action_mod.Action.READY,
inputs={'foo': 'bar'},
)