template content validation - fix bugs

Change-Id: If9978fbd86be7b949bdd798b9cd302c012954ea9
This commit is contained in:
liathartal 2016-05-26 06:36:04 +00:00
parent 6ae3a547ab
commit 5c574f0b8d
6 changed files with 26 additions and 7 deletions

View File

@ -20,6 +20,8 @@ from vitrage.common import file_utils
from vitrage.evaluator.template import RELATIONSHIP
from vitrage.evaluator.template import Template
from vitrage.evaluator.template_fields import TemplateFields
from vitrage.evaluator.template_validation.template_content_validator import \
content_validation
from vitrage.evaluator.template_validation.template_syntax_validator import \
syntax_validation
@ -66,7 +68,9 @@ class ScenarioRepository(object):
def add_template(self, template_def):
syntax_validation_result = syntax_validation(template_def)
if syntax_validation_result.is_valid:
content_validation_result = content_validation(template_def)
if syntax_validation_result.is_valid and \
content_validation_result.is_valid:
template = Template(template_def)
self.templates[template.name] = template
self._add_template_scenarios(template)

View File

@ -1 +1,14 @@
# Copyright 2016 - Nokia
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
__author__ = 'stack'

View File

@ -1,4 +1,4 @@
# Copyright 2015 - Nokia
# Copyright 2016 - Nokia
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain

View File

@ -1,4 +1,4 @@
# Copyright 2015 - Nokia
# Copyright 2016 - Nokia
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain

View File

@ -17,8 +17,8 @@ from six.moves import reduce
from vitrage.evaluator.actions.base import ActionType
from vitrage.evaluator.template import Template
from vitrage.evaluator.template_fields import TemplateFields
from vitrage.evaluator.template_validation.base import Result
from vitrage.evaluator.template_validation.error_messages import error_msgs
from vitrage.evaluator.template_validation.utils import Result
LOG = log.getLogger(__name__)
@ -36,9 +36,11 @@ def content_validation(template):
result = validate_entities_definition(entities, entity_ids)
relationship_ids = []
relationships = template_definitions[TemplateFields.RELATIONSHIPS]
if result.is_valid and relationships:
if result.is_valid and \
TemplateFields.RELATIONSHIPS in template_definitions:
relationships = template_definitions[TemplateFields.RELATIONSHIPS]
result = validate_relationships_definitions(relationships,
relationship_ids,
entity_ids)

View File

@ -26,8 +26,8 @@ from vitrage.common.constants import edge_labels
from vitrage.common.constants import entities_categories
from vitrage.evaluator.actions.base import action_types
from vitrage.evaluator.template_fields import TemplateFields
from vitrage.evaluator.template_validation.base import Result
from vitrage.evaluator.template_validation.error_messages import error_msgs
from vitrage.evaluator.template_validation.utils import Result
LOG = log.getLogger(__name__)