Add monitoring node in tosca-parser

This patch will focus on:

1. Defining a monitoring node as an EXPERIMENTAL feature
2. Enhancing trigger to further support monitoring policy
3. Validating trigger policy

Change-Id: Idd5268b7ff0a19b57ea927f23c76db24220c462d
This commit is contained in:
doantungbk
2017-02-09 21:43:33 -08:00
parent c43d164445
commit 3d21f12576
2 changed files with 20 additions and 2 deletions

View File

@@ -918,6 +918,11 @@ policy_types:
description: The TOSCA Policy Type definition that is used to govern
scaling of TOSCA nodes or groups of nodes.
tosca.policies.Monitoring:
derived_from: tosca.policies.Root
description: The TOSCA Policy Type definition that is used to govern
monitoring of TOSCA nodes or groups of nodes.
tosca.policies.Update:
derived_from: tosca.policies.Root
description: The TOSCA Policy Type definition that is used to govern

View File

@@ -16,12 +16,15 @@ import logging
from toscaparser.common.exception import ExceptionCollector
from toscaparser.common.exception import UnknownFieldError
from toscaparser.entity_template import EntityTemplate
from toscaparser.utils import validateutils
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')
CONDITION_KEYNAMES = (METER_NAME, CONSTRAINT, PERIOD, EVALUATIONS, METHOD,
THRESHOLD, COMPARISON_OPERATOR) = \
('meter_name', 'constraint', 'period', 'evaluations',
'method', 'threshold', 'comparison_operator')
log = logging.getLogger('tosca')
@@ -34,6 +37,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 +70,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)