From 1e12c6b9b28c49ed02ab8d2f156a6cf52cc305d7 Mon Sep 17 00:00:00 2001 From: aribeiro Date: Mon, 8 Feb 2021 14:41:39 +0000 Subject: Add new SOL004 ETSI Validator Support for onboarding ETSI v3.3.1 SOL004 VNF CSAR Packages with minimum CNF enhancements from 4.1.1 Issue-ID: SDC-3337 Signed-off-by: aribeiro Change-Id: I0fefb43b8462133ae82d10418c79f9e2b126defb --- .../services/impl/etsi/ETSIService.java | 6 ++++ .../services/impl/etsi/ETSIServiceImpl.java | 38 ++++++++++++++-------- 2 files changed, 31 insertions(+), 13 deletions(-) (limited to 'openecomp-be/lib/openecomp-sdc-vendor-software-product-lib') diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIService.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIService.java index 7332505b25..8b56b3fbc0 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIService.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-api/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIService.java @@ -92,4 +92,10 @@ public interface ETSIService { * @return Semver representing highest compatible specification version */ Semver getHighestCompatibleSpecificationVersion(final FileContentHandler handler); + + /** + * Verifies if SOL004 3.3.1 manifest file has onap_cnf_helm non mano entry + * @return true if manifest files has onap_cnf_helm non mano entry + */ + boolean hasCnfEnhancements(final FileContentHandler fileContentHandler) throws IOException; } diff --git a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImpl.java b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImpl.java index 8ec76fe14b..951cfc7d1f 100644 --- a/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImpl.java +++ b/openecomp-be/lib/openecomp-sdc-vendor-software-product-lib/openecomp-sdc-vendor-software-product-core/src/main/java/org/openecomp/sdc/vendorsoftwareproduct/services/impl/etsi/ETSIServiceImpl.java @@ -21,6 +21,7 @@ package org.openecomp.sdc.vendorsoftwareproduct.services.impl.etsi; import static org.openecomp.sdc.tosca.csar.CSARConstants.ARTIFACTS_FOLDER; +import static org.openecomp.sdc.tosca.csar.CSARConstants.ETSI_VERSION_2_6_1; import static org.openecomp.sdc.tosca.csar.CSARConstants.MAIN_SERVICE_TEMPLATE_MF_FILE_NAME; import static org.openecomp.sdc.tosca.csar.CSARConstants.MANIFEST_PNF_METADATA; import static org.openecomp.sdc.tosca.csar.CSARConstants.TOSCA_META_ORIG_PATH_FILE_NAME; @@ -29,8 +30,8 @@ import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ENTRY_DEFINITIONS; import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ETSI_ENTRY_CHANGE_LOG; import static org.openecomp.sdc.tosca.csar.ToscaMetaEntry.ETSI_ENTRY_MANIFEST; import static org.openecomp.sdc.tosca.csar.ToscaMetadataFileInfo.TOSCA_META_PATH_FILE_NAME; -import static org.openecomp.sdc.tosca.csar.CSARConstants.ETSI_VERSION_2_6_1; +import com.vdurmont.semver4j.Semver; import java.io.IOException; import java.io.InputStream; import java.nio.file.Path; @@ -42,11 +43,11 @@ import java.util.Map; import java.util.Objects; import java.util.Optional; import java.util.stream.Collectors; - import org.apache.commons.collections.MapUtils; import org.onap.sdc.tosca.datatypes.model.ServiceTemplate; import org.onap.sdc.tosca.services.YamlUtil; import org.openecomp.core.utilities.file.FileContentHandler; +import org.openecomp.sdc.be.config.NonManoArtifactType; import org.openecomp.sdc.be.config.NonManoConfiguration; import org.openecomp.sdc.be.config.NonManoConfigurationManager; import org.openecomp.sdc.be.config.NonManoFolderType; @@ -59,8 +60,6 @@ import org.openecomp.sdc.tosca.csar.SOL004ManifestOnboarding; import org.openecomp.sdc.tosca.csar.ToscaMetadata; import org.openecomp.sdc.tosca.datatypes.ToscaServiceModel; -import com.vdurmont.semver4j.Semver; - public class ETSIServiceImpl implements ETSIService { private static final Logger LOGGER = LoggerFactory.getLogger(ETSIServiceImpl.class); @@ -83,15 +82,7 @@ public class ETSIServiceImpl implements ETSIService { @Override public Optional> moveNonManoFileToArtifactFolder(final FileContentHandler handler) throws IOException { - final Manifest manifest; - try { - manifest = getManifest(handler); - } catch (final IOException ex) { - if (LOGGER.isErrorEnabled()) { - LOGGER.error("An error occurred while getting the manifest file", ex); - } - throw ex; - } + final Manifest manifest = loadManifest(handler); final Path originalManifestPath; try { originalManifestPath = getOriginalManifestPath(handler); @@ -224,6 +215,27 @@ public class ETSIServiceImpl implements ETSIService { } + @Override + public boolean hasCnfEnhancements(final FileContentHandler fileContentHandler) throws IOException { + final Manifest manifest = loadManifest(fileContentHandler); + return manifest.getNonManoSources().entrySet().stream() + .filter(manifestNonManoSourceEntry -> NonManoArtifactType.ONAP_CNF_HELM.getType() + .equalsIgnoreCase(manifestNonManoSourceEntry.getKey())).findFirst().isPresent(); + } + + private Manifest loadManifest(final FileContentHandler handler) throws IOException { + final Manifest manifest; + try { + manifest = getManifest(handler); + } catch (final IOException ex) { + if (LOGGER.isErrorEnabled()) { + LOGGER.error("An error occurred while getting the manifest file", ex); + } + throw ex; + } + return manifest; + } + private boolean isMetaFilePresent(Map handler) { return handler.containsKey(TOSCA_META_PATH_FILE_NAME) || handler.containsKey(TOSCA_META_ORIG_PATH_FILE_NAME); } -- cgit 1.2.3-korg