summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshangxdy <shang.xiaodong@zte.com.cn>2017-09-14 19:45:53 +0800
committershangxdy <shang.xiaodong@zte.com.cn>2017-09-14 19:45:53 +0800
commitc1c67048665a6186490b0039407f3d4c8088182f (patch)
treea07b3072044965c0afe36b620f3e053ca9db51cd
parent87920ff99ba0a2ba5cbe0532a4f6d94846525f51 (diff)
Add required parameters validation for nested service
Add validation for SDC from ONAP when use parse in design time: ignore nested parameters(inputs and outputs) validation and only print warning message. JIRA: PARSER-141 Change-Id: Idd3b35a197594e9a7ff38024f16acfa650728bd1 Signed-off-by: shangxdy <shang.xiaodong@zte.com.cn>
-rw-r--r--tosca2heat/tosca-parser/toscaparser/common/exception.py4
-rw-r--r--tosca2heat/tosca-parser/toscaparser/tosca_template.py13
2 files changed, 11 insertions, 6 deletions
diff --git a/tosca2heat/tosca-parser/toscaparser/common/exception.py b/tosca2heat/tosca-parser/toscaparser/common/exception.py
index 9fb331d..67a9f7f 100644
--- a/tosca2heat/tosca-parser/toscaparser/common/exception.py
+++ b/tosca2heat/tosca-parser/toscaparser/common/exception.py
@@ -20,7 +20,7 @@ import traceback
from toscaparser.utils.gettextutils import _
-log = logging.getLogger(__name__)
+log = logging.getLogger('tosca')
class TOSCAException(Exception):
@@ -207,7 +207,7 @@ class ExceptionCollector(object):
@staticmethod
def removeException(exception_type):
- if ExceptionCollector.collecting:
+ if ExceptionCollector.collecting and ExceptionCollector.exceptions:
for i, e in enumerate(ExceptionCollector.exceptions):
if isinstance(e, exception_type):
del ExceptionCollector.exceptions[i]
diff --git a/tosca2heat/tosca-parser/toscaparser/tosca_template.py b/tosca2heat/tosca-parser/toscaparser/tosca_template.py
index 30432af..b0df424 100644
--- a/tosca2heat/tosca-parser/toscaparser/tosca_template.py
+++ b/tosca2heat/tosca-parser/toscaparser/tosca_template.py
@@ -18,6 +18,8 @@ from copy import deepcopy
from toscaparser.common.exception import ExceptionCollector
from toscaparser.common.exception import InvalidTemplateVersion
from toscaparser.common.exception import MissingRequiredFieldError
+from toscaparser.common.exception import MissingRequiredInputError
+from toscaparser.common.exception import MissingRequiredOutputError
from toscaparser.common.exception import MissingRequiredParameterError
from toscaparser.common.exception import UnknownFieldError
from toscaparser.common.exception import ValidationError
@@ -316,11 +318,14 @@ class ToscaTemplate(object):
% {'path': path}))
def verify_template(self):
+ if self.no_required_paras_check:
+ ExceptionCollector.removeException(
+ MissingRequiredParameterError)
+ ExceptionCollector.removeException(
+ MissingRequiredInputError)
+ ExceptionCollector.removeException(
+ MissingRequiredOutputError)
if ExceptionCollector.exceptionsCaught():
- if self.no_required_paras_check:
- ExceptionCollector.removeException(
- MissingRequiredParameterError)
-
if self.input_path:
exceptions = ValidationError(
message=(_('\nThe input "%(path)s" failed validation with '