diff options
author | Lianhao Lu <lianhao.lu@intel.com> | 2018-08-30 14:42:29 +0800 |
---|---|---|
committer | Lianhao Lu <lianhao.lu@intel.com> | 2018-08-30 15:08:20 +0800 |
commit | a2998ffa850a8661a378910d77f670dfebbb6690 (patch) | |
tree | d14e8b4854f8672b9adfe926c20c584bd5560922 /vnfsdk_pkgtools | |
parent | 7debff083837e36ccba3f54fa2962f0d1261f438 (diff) |
Test for vnf requirement R-26881
Implement test for vnf requirement R-26881: The VNF provider MUST
provide the binaries and images needed to instantiate the VNF (VNF and
VNFC images).
Change-Id: Idce2e598e98365b87ad0491975adbb0f76b38604
Issue-ID: VNFSDK-313
Signed-off-by: Lianhao Lu <lianhao.lu@intel.com>
Diffstat (limited to 'vnfsdk_pkgtools')
-rw-r--r-- | vnfsdk_pkgtools/vnfreq/pkg_reqs.py | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/vnfsdk_pkgtools/vnfreq/pkg_reqs.py b/vnfsdk_pkgtools/vnfreq/pkg_reqs.py index 6153fa4..2592017 100644 --- a/vnfsdk_pkgtools/vnfreq/pkg_reqs.py +++ b/vnfsdk_pkgtools/vnfreq/pkg_reqs.py @@ -20,6 +20,7 @@ import six from stevedore import driver from vnfsdk_pkgtools.packager import csar +from vnfsdk_pkgtools.validator import toscaparser_validator as tv from vnfsdk_pkgtools import vnfreq @@ -68,3 +69,29 @@ class R04298(vnfreq.TesterBase): raise vnfreq.VnfRequirementError("No testing scripts found") return 0 + +class R26881(vnfreq.TesterBase): + ID = "R-26881" + DESC = ("The VNF provider MUST provide the binaries and images needed " + "to instantiate the VNF (VNF and VNFC images).") + + def _do_check(self, reader, tosca): + entry_path = os.path.dirname(os.path.join(reader.destination, + reader.entry_definitions)) + valid_artifacts = [] + for node in getattr(tosca.tosca, 'nodetemplates', []): + if tosca.is_type(node, 'tosca.nodes.nfv.Vdu.Compute') or \ + tosca.is_type(node, 'tosca.nodes.nfv.Vdu.VirtualStorage'): + # TODO(llu) nfv-toscaparser now doesn't support artifacts + # yet, we have to hack it for now. + # See https://jira.opnfv.org/browse/PARSER-184. + for name, props in node.entity_tpl.get('artifacts', {}).iteritems(): + file = props.get('file', None) + if file and \ + os.path.isfile(os.path.join(entry_path, file)) or \ + os.path.isfile(os.path.join(reader.destination, file)): + valid_artifacts.append(file) + if not valid_artifacts: + raise vnfreq.VnfRequirementError("No valid binaries or images for VNF instantion found") + return 0 + |