Skip to content

Commit

Permalink
Merge pull request #299 from StackStorm/STORM-337/rename_mapping_to_p…
Browse files Browse the repository at this point in the history
…arameters

RFR: Fix: Rename mapping to parameters for action section in rule model
  • Loading branch information
lakshmi-kannan committed Jul 30, 2014
2 parents d8fa997 + 67e17a5 commit 07551b2
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions contrib/examples/rules/sample-rule.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
"type": {
"name": "st2.test.action"
},
"mapping": {
"ip2": "{{system.k1}}",
"ip1": "{{trigger.t1_p}}"
"parameters": {
"ip1": "{{trigger.t1_p}}",
"ip2": "{{system.k1}}"
}
},

Expand Down
8 changes: 4 additions & 4 deletions st2common/st2common/models/api/reactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class RuleAPI(StormBaseAPI):
e.g.
"action":
{ "type": {"id": "2345678901"}
, "mapping":
, "parameters":
{ "command": "{{ system.foo }}"
, "args": "--email {{ trigger.from }} --subject \'{{ user[stanley].ALERT_SUBJECT }}\'"}
}
Expand All @@ -97,7 +97,7 @@ def from_model(kls, model):
rule.trigger = model.trigger
rule.criteria = dict(model.criteria)
rule.action = {'type': model.action.action,
'mapping': dict(model.action.data_mapping)}
'parameters': dict(model.action.parameters)}
rule.enabled = model.enabled
return rule

Expand All @@ -110,8 +110,8 @@ def to_model(kls, rule):
model.action = ActionExecutionSpecDB()
if 'type' in rule.action:
model.action.action = rule.action['type']
if 'mapping' in rule.action:
model.action.data_mapping = rule.action['mapping']
if 'parameters' in rule.action:
model.action.parameters = rule.action['parameters']
model.enabled = rule.enabled
return model

Expand Down
2 changes: 1 addition & 1 deletion st2common/st2common/models/db/reactor.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class TriggerInstanceDB(StormFoundationDB):

class ActionExecutionSpecDB(me.EmbeddedDocument):
action = me.DictField()
data_mapping = me.DictField()
parameters = me.DictField()


class RuleDB(StormBaseDB):
Expand Down
2 changes: 1 addition & 1 deletion st2common/tests/test_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def _create_save_rule(trigger, action=None, enabled=True):
created.criteria = {}
created.action = ActionExecutionSpecDB()
created.action.action = reference.get_ref_from_model(action)
created.action.data_mapping = {}
created.action.parameters = {}
return Rule.add_or_update(created)

@staticmethod
Expand Down
2 changes: 1 addition & 1 deletion st2reactor/st2reactor/rules/enforcer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def enforce(self):
rule_enforcement = RuleEnforcementDB()
rule_enforcement.trigger_instance = reference.get_ref_from_model(self.trigger_instance)
rule_enforcement.rule = reference.get_ref_from_model(self.rule)
data = self.data_transformer(self.rule.action.data_mapping)
data = self.data_transformer(self.rule.action.parameters)
LOG.info('Invoking action %s for trigger_instance %s with data %s.',
RuleEnforcer.__get_action_name(self.rule.action), self.trigger_instance.id,
json.dumps(data))
Expand Down
2 changes: 1 addition & 1 deletion st2reactorcontroller/tests/controllers/test_rules.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
'type': {
'name': 'st2.test.action'
},
'mapping': {
'parameters': {
'ip2': '{{rule.k1}}',
'ip1': '{{trigger.t1_p}}'
}
Expand Down

0 comments on commit 07551b2

Please sign in to comment.