diff options
author | julien zhang <zhang.jun3g@zte.com.cn> | 2017-07-17 12:42:12 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@opnfv.org> | 2017-07-17 12:42:12 +0000 |
commit | 30149ea784b60fc12de3e8a70aca23a16011ca70 (patch) | |
tree | 819c4ee6241f8323b517c371256c3c6d1247b5a5 /tosca2heat/tosca-parser/toscaparser/triggers.py | |
parent | c7491340551cdd9d757d63b4bbe79132506e386a (diff) | |
parent | 040e0718bcfac3cd01cf4ccae82bef2c0d01087b (diff) |
Merge "synchronize upstream about tosca-parser"
Diffstat (limited to 'tosca2heat/tosca-parser/toscaparser/triggers.py')
-rw-r--r-- | tosca2heat/tosca-parser/toscaparser/triggers.py | 26 |
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) |