'console_scripts': [
'vnfsdk = vnfsdk_pkgtools.cli.__main__:main'],
'vnfsdk.pkgtools.validator': [
- 'aria = vnfsdk_pkgtools.validator.aria_validator:AriaValidator [aria]'
+ 'aria = vnfsdk_pkgtools.validator.aria_validator:AriaValidator [aria]',
+ 'toscaparser = vnfsdk_pkgtools.validator.toscaparser_validator:ToscaparserValidator',
]
},
--- /dev/null
+# Copyright (c) 2018 Intel Corp. All rights reserved.
+#
+# 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.
+#
+
+import logging
+import os
+
+from vnfsdk_pkgtools.packager import csar
+from vnfsdk_pkgtools.validator import toscaparser_validator
+
+CSAR_PATH = 'tests/resources/test_import.csar'
+
+def test_validate(tmpdir):
+ reader = csar._CSARReader(CSAR_PATH, str(tmpdir.mkdir('validate')), logging)
+ validator = toscaparser_validator.ToscaparserValidator()
+ validator.validate(reader)
+ assert hasattr(validator, 'tosca')
help='CSAR file location')
csar_validate.add_argument(
'-p', '--parser',
- default='aria',
+ default='toscaparser',
help='use which csar parser to validate')
return parser.parse_args(args_list)
--- /dev/null
+# Copyright (c) 2018 Intel Corp. All rights reserved.
+#
+# 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.
+#
+
+import logging
+import os
+
+from toscaparser.common.exception import ValidationError
+from toscaparser.tosca_template import ToscaTemplate
+
+from vnfsdk_pkgtools import validator
+
+LOG = logging.getLogger(__name__)
+
+
+class ToscaparserValidator(validator.ValidatorBase):
+ def __init__(self):
+ super(ToscaparserValidator, self).__init__()
+
+ def validate(self, reader):
+ entry_path = os.path.join(reader.destination,
+ reader.entry_definitions)
+ try:
+ #TODO set debug_mode due to upstream bug
+ # https://jira.opnfv.org/browse/PARSER-181
+ self.tosca = ToscaTemplate(path=entry_path,
+ no_required_paras_check=True,
+ debug_mode=True)
+ except ValidationError as e:
+ LOG.error(e.message)
+ raise e