summaryrefslogtreecommitdiffstats
path: root/tosca2heat/tosca-parser/toscaparser/triggers.py
diff options
context:
space:
mode:
authorshangxdy <shang.xiaodong@zte.com.cn>2017-07-17 16:29:36 +0800
committershangxdy <shang.xiaodong@zte.com.cn>2017-07-17 16:29:36 +0800
commit040e0718bcfac3cd01cf4ccae82bef2c0d01087b (patch)
tree0835e86f3e1a0c63db180335e94628915a229ee5 /tosca2heat/tosca-parser/toscaparser/triggers.py
parent859e2826074aa51e0334d4607ccfcde5972e882e (diff)
synchronize upstream about tosca-parser
synchronize tosca-parser with version of 0.81 JIRA: PARSER-128 Change-Id: Ib00e391bd6c1f4c69776796eb7b28062f14b92fc Signed-off-by: shangxdy <shang.xiaodong@zte.com.cn>
Diffstat (limited to 'tosca2heat/tosca-parser/toscaparser/triggers.py')
-rw-r--r--tosca2heat/tosca-parser/toscaparser/triggers.py26
1 files changed, 20 insertions, 6 deletions
diff --git a/tosca2heat/tosca-parser/toscaparser/triggers.py b/tosca2heat/tosca-parser/toscaparser/triggers.py
index 9edeef4..8e47eee 100644
--- a/tosca2heat/tosca-parser/toscaparser/triggers.py
+++ b/tosca2heat/tosca-parser/toscaparser/triggers.py
@@ -16,12 +16,16 @@ import logging
from toscaparser.common.exception import ExceptionCollector
from toscaparser.common.exception import UnknownFieldError
from toscaparser.entity_template import EntityTemplate
-
-SECTIONS = (DESCRIPTION, EVENT, SCHEDULE, TARGET_FILTER, CONDITION, ACTION) = \
- ('description', 'event_type', 'schedule',
- 'target_filter', 'condition', 'action')
-CONDITION_KEYNAMES = (CONTRAINT, PERIOD, EVALUATIONS, METHOD) = \
- ('constraint', 'period', 'evaluations', 'method')
+from toscaparser.utils import validateutils
+
+SECTIONS = (DESCRIPTION, EVENT, SCHEDULE, METER_NAME, METADATA,
+ TARGET_FILTER, CONDITION, ACTION) = \
+ ('description', 'event_type', 'schedule', 'meter_name',
+ 'metadata', 'target_filter', 'condition', 'action')
+CONDITION_KEYNAMES = (CONSTRAINT, PERIOD, EVALUATIONS, METHOD,
+ THRESHOLD, COMPARISON_OPERATOR) = \
+ ('constraint', 'period', 'evaluations',
+ 'method', 'threshold', 'comparison_operator')
log = logging.getLogger('tosca')
@@ -34,6 +38,7 @@ class Triggers(EntityTemplate):
self.trigger_tpl = trigger_tpl
self._validate_keys()
self._validate_condition()
+ self._validate_input()
def get_description(self):
return self.trigger_tpl['description']
@@ -66,3 +71,12 @@ class Triggers(EntityTemplate):
ExceptionCollector.appendException(
UnknownFieldError(what='Triggers "%s"' % self.name,
field=key))
+
+ def _validate_input(self):
+ for key, value in self.get_condition().items():
+ if key in [PERIOD, EVALUATIONS]:
+ validateutils.validate_integer(value)
+ elif key == THRESHOLD:
+ validateutils.validate_numeric(value)
+ elif key in [METER_NAME, METHOD]:
+ validateutils.validate_string(value)