File defined in ZIP VSP package as PM_DICTIONARY will be now mapped to PM_DICTIONARY type in VF. Also PmDictionaryValidator is run on files with PM_DICTIONARY type in ZIP Manifest file, instead of file naming convention.
Issue-ID: SDC-3390
Signed-off-by: Adam Wudzinski <adam.wudzinski@nokia.com>
Change-Id: I2e21353b9e80b6bb68c4c6d408ad1ffa33314e7b
@Override
public void validate(GlobalValidationContext globalContext) {
}
-}
\ No newline at end of file
+}
/*
* Copyright © 2016-2018 European Support Limited
+ * Modifications copyright (c) 2021 Nokia
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
}
- String manifest = candidateService.createManifest(vspDetails, structure);
+ ManifestContent zipManifestFile = readManifestFromZip(fileContentMap);
+ String manifest = null;
+ if (zipManifestFile == null) {
+ manifest = candidateService.createManifest(vspDetails, structure);
+ } else {
+ manifest = candidateService.createManifestFromExisting(vspDetails, structure, zipManifestFile);
+ }
fileContentMap.addFile(SdcCommon.MANIFEST_NAME, manifest.getBytes());
Optional<ByteArrayInputStream> zipByteArrayInputStream = candidateService
return response;
}
+ private ManifestContent readManifestFromZip(FileContentHandler fileContentMap) {
+ ManifestContent zipManifestFile = null;
+ try (InputStream zipFileManifest = fileContentMap.getFileContentAsStream(SdcCommon.MANIFEST_NAME)) {
+ zipManifestFile = JsonUtil.json2Object(zipFileManifest, ManifestContent.class);
+ } catch (Exception e) {
+ LOGGER.error("Invalid package content", e);
+ }
+ return zipManifestFile;
+ }
+
private FileContentHandler addDummyHeatBase(InputStream zipFileManifest, FileContentHandler fileContentMap) {
ManifestContent manifestContent =
JsonUtil.json2Object(zipFileManifest, ManifestContent.class);
class FileExtensionUtils {
- private static final Set<String> VALID_PM_DICTIONARY_EXTENSIONS = Set.of(
- "pmdict.yml",
- "pmdict.yaml",
- "pm_dict.yml",
- "pm_dict.yaml",
- "pmdictionary.yml",
- "pmdictionary.yaml",
- "pm_dictionary.yml",
- "pm_dictionary.yaml"
- );
private static final Set<String> VALID_YAML_EXTENSIONS = Set.of(
".yaml",
".yml",
);
static boolean isYaml(String fileName) {
- return isValidExt(fileName, VALID_YAML_EXTENSIONS);
- }
-
- static boolean isPmDictionary(String fileName) {
- return isValidExt(fileName, VALID_PM_DICTIONARY_EXTENSIONS);
- }
-
- private static boolean isValidExt(String fileName, Set<String> validExtensions) {
String fileNameLower = fileName.toLowerCase();
- return validExtensions.stream()
+ return FileExtensionUtils.VALID_YAML_EXTENSIONS.stream()
.anyMatch(fileNameLower::endsWith);
}
+
}
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2021 Nokia Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.validation.impl.validators;
+
+import org.openecomp.core.validation.types.GlobalValidationContext;
+import org.openecomp.sdc.heat.datatypes.manifest.FileData;
+import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
+import org.openecomp.sdc.heat.services.manifest.ManifestUtil;
+import org.openecomp.sdc.validation.util.ValidationUtil;
+
+import java.util.Map;
+import java.util.Set;
+import java.util.function.Predicate;
+import java.util.stream.Collectors;
+
+class GlobalContextUtil {
+
+ private GlobalContextUtil() {}
+
+ static Set<String> findPmDictionaryFiles(GlobalValidationContext globalContext) {
+ if (isManifestMissing(globalContext)) {
+ return Set.of();
+ }
+
+ Map<String, FileData.Type> filesWithTypes = readAllFilesWithTypes(globalContext);
+ return filterPmDictionaryFiles(filesWithTypes);
+ }
+
+ private static boolean isManifestMissing(GlobalValidationContext globalContext) {
+ return globalContext.getFileContent("MANIFEST.json")
+ .isEmpty();
+ }
+
+ private static Set<String> filterPmDictionaryFiles(Map<String, FileData.Type> filesWithTypes) {
+ return filesWithTypes.entrySet().stream()
+ .filter(isPmDictionaryType())
+ .map(Map.Entry::getKey)
+ .collect(Collectors.toSet());
+ }
+
+ private static Map<String, FileData.Type> readAllFilesWithTypes(GlobalValidationContext globalContext) {
+ ManifestContent manifestContent = ValidationUtil.validateManifest(globalContext);
+ return ManifestUtil.getFileTypeMap(manifestContent);
+ }
+
+ private static Predicate<Map.Entry<String, FileData.Type>> isPmDictionaryType() {
+ return entry -> entry.getValue()
+ .equals(FileData.Type.PM_DICTIONARY);
+ }
+}
* ============LICENSE_START=======================================================
* SDC
* ================================================================================
- * Copyright (C) 2020 Nokia Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 Nokia Intellectual Property. 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.
import io.vavr.control.Option;
import io.vavr.control.Try;
-import java.io.InputStream;
-import java.util.List;
import org.onap.validation.yaml.YamlContentValidator;
import org.onap.validation.yaml.error.YamlDocumentValidationError;
import org.openecomp.core.validation.ErrorMessageCode;
import org.openecomp.sdc.datatypes.error.ErrorLevel;
import org.openecomp.sdc.validation.Validator;
+import java.io.InputStream;
+import java.util.List;
+import java.util.Set;
+
public class PmDictionaryValidator implements Validator {
private static final ErrorMessageCode PM_DICT_ERROR_CODE = new ErrorMessageCode("PM_DICT");
@Override
public void validate(GlobalValidationContext globalContext) {
- globalContext.getFiles().stream()
- .filter(FileExtensionUtils::isPmDictionary)
- .map(fileName -> new ValidationHelper(globalContext, fileName))
- .forEach(ValidationHelper::validate);
+ Set<String> pmDictionaryFiles = GlobalContextUtil.findPmDictionaryFiles(globalContext);
+ validatePmDictionaryFiles(globalContext, pmDictionaryFiles);
+ }
+
+
+ private void validatePmDictionaryFiles(GlobalValidationContext globalContext, Set<String> pmDictionaryFiles) {
+ pmDictionaryFiles.stream()
+ .map(fileName -> new ValidationHelper(globalContext, fileName))
+ .forEach(ValidationHelper::validate);
}
private static class ValidationHelper {
public void validate() {
Option.ofOptional(globalContext.getFileContent(fileName))
- .peek(this::validateFileContent)
- .onEmpty(() -> addErrorToContext(formatMessage("File is empty")));
+ .peek(this::validateFileContent)
+ .onEmpty(() -> addErrorToContext(formatMessage("File is empty")));
}
private void validateFileContent(InputStream inputStream) {
Try.of(inputStream::readAllBytes)
- .mapTry(fileContent -> new YamlContentValidator().validate(fileContent))
- .onSuccess(this::reportValidationErrorsIfPresent)
- .onFailure(e -> addErrorToContext(formatMessage(e.getMessage())));
+ .mapTry(fileContent -> new YamlContentValidator().validate(fileContent))
+ .onSuccess(this::reportValidationErrorsIfPresent)
+ .onFailure(e -> addErrorToContext(formatMessage(e.getMessage())));
}
private void reportValidationErrorsIfPresent(List<YamlDocumentValidationError> validationErrors) {
validationErrors.stream()
- .map(this::prepareValidationMessage)
- .forEach(this::addErrorToContext);
+ .map(this::prepareValidationMessage)
+ .forEach(this::addErrorToContext);
}
private String prepareValidationMessage(YamlDocumentValidationError error) {
final String errorMessage = String.format("Document Number: %s, Path: %s, Problem: %s",
- error.getYamlDocumentNumber(),
- error.getPath(),
- error.getMessage()
+ error.getYamlDocumentNumber(),
+ error.getPath(),
+ error.getMessage()
);
return formatMessage(errorMessage);
}
private String formatMessage(String message) {
return ErrorMessagesFormatBuilder
- .getErrorWithParameters(PM_DICT_ERROR_CODE, message);
+ .getErrorWithParameters(PM_DICT_ERROR_CODE, message);
}
private void addErrorToContext(String message) {
/*
* Copyright © 2016-2017 European Support Limited
- * Copyright © 2020 Nokia
+ * Copyright © 2020-2021 Nokia
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.util.Collection;
import java.util.Map;
import java.util.Optional;
+import java.util.Set;
public class YamlValidator implements Validator {
private static final ErrorMessageCode ERROR_CODE_YML_1 = new ErrorMessageCode("YML1");
@Override
public void validate(GlobalValidationContext globalContext) {
+ Set<String> pmDictionaryFiles = GlobalContextUtil.findPmDictionaryFiles(globalContext);
+
Collection<String> files = globalContext.files(
(fileName, globalValidationContext) -> FileExtensionUtils.isYaml(fileName)
- && !FileExtensionUtils.isPmDictionary(fileName));
+ && !pmDictionaryFiles.contains(fileName));
files.forEach(fileName -> validate(fileName, globalContext));
}
".properties"
);
- private static final Set<String> VALID_PM_DICTIONARY_EXTENSIONS = Set.of(
- "pmdict.yml",
- "pmdict.yaml",
- "pm_dict.yml",
- "pm_dict.yaml",
- "pmdictionary.yml",
- "pmdictionary.yaml",
- "pm_dictionary.yml",
- "pm_dictionary.yaml"
- );
- private static final Set<String> INVALID_PM_DICTIONARY_EXTENSIONS = Set.of(
- "pmdict.txt",
- "pmdict.java",
- "pm.yml"
- );
-
private static final Set<String> TEST_FILE_PREFIXES = Set.of(
"test",
"test_file"
assertTrue(allInvalidFilesNotMatched);
}
- @Test
- void shouldMatchProperPmDictionaryExtensions() {
- final boolean allValidFilesMatched = constructTestFilenamesWithExtensions(VALID_PM_DICTIONARY_EXTENSIONS)
- .allMatch(FileExtensionUtils::isPmDictionary);
-
- assertTrue(allValidFilesMatched);
- }
-
- @Test
- void shouldNotMatchImproperPmDictionaryExtensions() {
- final boolean allInvalidFilesNotMatched = constructTestFilenamesWithExtensions(INVALID_PM_DICTIONARY_EXTENSIONS)
- .noneMatch(FileExtensionUtils::isPmDictionary);
-
- assertTrue(allInvalidFilesNotMatched);
- }
-
private Stream<String> constructTestFilenamesWithExtensions(Set<String> extensions) {
return extensions.stream()
.flatMap(ext -> prepareFilenamesWithExtension(ext).stream());
return TEST_FILE_PREFIXES.stream()
.map(prefix -> prefix + extension);
}
-}
\ No newline at end of file
+}
--- /dev/null
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Copyright (C) 2021 Nokia Intellectual Property. 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.sdc.validation.impl.validators;
+
+import org.junit.jupiter.api.Test;
+import org.openecomp.core.validation.types.GlobalValidationContext;
+import org.openecomp.sdc.validation.util.ValidationTestUtil;
+
+import java.util.Set;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+class GlobalContextUtilTest {
+ private static final String TEST_MANIFEST_PATH = "/org/openecomp/validation/validators/global_context_util/";
+
+ @Test
+ void shouldReturnOnlyFilesWithPmDictionaryType() {
+ // given
+ GlobalValidationContext globalContext = ValidationTestUtil.createGlobalContextFromPath(TEST_MANIFEST_PATH);
+
+ // when
+ Set<String> pmDictionaryFiles = GlobalContextUtil.findPmDictionaryFiles(globalContext);
+
+ // then
+ assertEquals(1, pmDictionaryFiles.size());
+ }
+
+}
* ============LICENSE_START=======================================================
* SDC
* ================================================================================
- * Copyright (C) 2020 Nokia Intellectual Property. All rights reserved.
+ * Copyright (C) 2020-2021 Nokia Intellectual Property. 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.
public class PmDictionaryValidatorTest {
private static final String RESOURCE_PATH = "/org/openecomp/validation/validators/pm_dictionary_validator";
- private static final String VALID_PM_DICTIONARY_YAML = "valid_pm_dictionary.yaml";
- private static final String INVALID_PM_DICTIONARY_YAML = "invalid_pm_dictionary.yaml";
+ private static final String VALID_PM_DICTIONARY_PACKAGE_PATH = "valid_file/";
+ private static final String INVALID_PM_DICTIONARY_PACKAGE_PATH = "invalid_file/";
+ private static final String WRONG_PM_DICTIONARY_TYPE_PACKAGE_PATH = "wrong_file_type/";
+ private static final String PM_DICTIONARY_FILE_NAME = "pmdict.yaml";
+
@Test
- public void shouldNotReturnErrorsWhenValidPmDict() {
+ void shouldNotReturnErrorsWhenValidPmDict() {
+ // when
Map<String, MessageContainer> messages = runValidation(
- RESOURCE_PATH + "/" + VALID_PM_DICTIONARY_YAML);
+ RESOURCE_PATH + "/" + VALID_PM_DICTIONARY_PACKAGE_PATH);
+ // then
assertNotNull(messages);
assertEquals(0, messages.size());
}
@Test
- public void shouldReturnErrorsWhenInvalidPmDict() {
+ void shouldReturnErrorsWhenInvalidPmDict() {
+ // when
+ Map<String, MessageContainer> messages = runValidation(
+ RESOURCE_PATH + "/" + INVALID_PM_DICTIONARY_PACKAGE_PATH);
+
+ // then
+ assertNotNull(messages);
+ assertNotNull(messages.get(PM_DICTIONARY_FILE_NAME));
+ assertEquals(4, messages.get(PM_DICTIONARY_FILE_NAME).getErrorMessageList().size());
+ }
+
+ @Test
+ void shouldNotReturnErrorsWhenInvalidPmDictButWrongPmDictionaryTypeInManifest() {
+ // when
Map<String, MessageContainer> messages = runValidation(
- RESOURCE_PATH + "/" + INVALID_PM_DICTIONARY_YAML);
+ RESOURCE_PATH + "/" + WRONG_PM_DICTIONARY_TYPE_PACKAGE_PATH);
+ // then
assertNotNull(messages);
- assertNotNull(messages.get(INVALID_PM_DICTIONARY_YAML));
- assertEquals(4, messages.get(INVALID_PM_DICTIONARY_YAML).getErrorMessageList().size());
+ assertEquals(0, messages.size());
}
private Map<String, MessageContainer> runValidation(String path) {
PmDictionaryValidator validator = new PmDictionaryValidator();
return ValidationTestUtil.testValidator(validator, path);
}
-}
\ No newline at end of file
+}
--- /dev/null
+{
+ "name": "Health VNF",
+ "description": "Health VNF onboarding package.",
+ "data": [
+ {
+ "file": "health_base_node.yaml",
+ "type": "HEAT",
+ "isBase": "true",
+ "data": [
+ {
+ "file": "health_base_node.env",
+ "type": "HEAT_ENV"
+ }
+ ]
+ },
+ {
+ "file": "pmdict.yaml",
+ "type": "PM_DICTIONARY"
+ }
+ ]
+}
+
--- /dev/null
+{
+ "name": "Health VNF",
+ "description": "Health VNF onboarding package.",
+ "data": [
+ {
+ "file": "health_base_node.yaml",
+ "type": "HEAT",
+ "isBase": "true",
+ "data": [
+ {
+ "file": "health_base_node.env",
+ "type": "HEAT_ENV"
+ }
+ ]
+ },
+ {
+ "file": "pmdict.yaml",
+ "type": "PM_DICTIONARY"
+ }
+ ]
+}
+
--- /dev/null
+parameters:
+ health_node_name_0: health_app_vm
+ health_node_image_name: ubuntu-java
+ health_node_flavor_name: aa.001-0002
+ key_name: galix_key
+ private_net_id: onap-wro
--- /dev/null
+heat_template_version: '2013-05-23'
+
+description: Heat template that deploys PnP PNF simulator
+
+parameters:
+ health_node_name_0:
+ type: string
+ label: Node name
+ description: Name of the node
+ # Flavors of each node
+ health_node_flavor_name:
+ type: string
+ label: Flavor
+ description: Type of instance (flavor) to be used for health node
+ # Images of each node
+ health_node_image_name:
+ type: string
+ label: Image name
+ description: OpenStack VM image to be used for node
+ # Others
+ private_net_id:
+ type: string
+ label: Private network name or ID
+ description: Private network
+ key_name:
+ type: string
+ label: Key pair name
+ description: Public/Private key pair name
+ vnf_id:
+ type: string
+ label: VNF ID
+ description: The VNF ID is provided by ONAP
+ vnf_name:
+ type: string
+ description: Unique name for this VNF instance
+ vf_module_id:
+ type: string
+ label: module ID
+ description: The Module ID is provided by ONAP
+ vf_module_name:
+ type: string
+ description: Unique name for VNF Module instance
+ dcae_collector_ip_0:
+ type: string
+
+resources:
+ health_node:
+ type: OS::Nova::Server
+ properties:
+ name: { get_param: health_node_name_0 }
+ key_name: { get_param: key_name }
+ image: { get_param: health_node_image_name }
+ flavor: { get_param: health_node_flavor_name }
+ networks:
+ - network: { get_param: private_net_id }
+ metadata:
+ vnf_name: { get_param: vnf_name }
+ vnf_id: { get_param: vnf_id }
+ vf_module_name: { get_param: vf_module_name }
+ vf_module_id: { get_param: vf_module_id }
+
+outputs:
+ oam_management_v4_address:
+ value: {get_attr: [health_node, networks, { get_param: private_net_id }, 0]}
+
--- /dev/null
+{
+ "name": "Health VNF",
+ "description": "Health VNF onboarding package.",
+ "data": [
+ {
+ "file": "health_base_node.yaml",
+ "type": "HEAT",
+ "isBase": "true",
+ "data": [
+ {
+ "file": "health_base_node.env",
+ "type": "HEAT_ENV"
+ }
+ ]
+ },
+ {
+ "file": "pmdict.yaml",
+ "type": "PM_DICTIONARY"
+ }
+ ]
+}
+
--- /dev/null
+parameters:
+ health_node_name_0: health_app_vm
+ health_node_image_name: ubuntu-java
+ health_node_flavor_name: aa.001-0002
+ key_name: galix_key
+ private_net_id: onap-wro
--- /dev/null
+heat_template_version: '2013-05-23'
+
+description: Heat template that deploys PnP PNF simulator
+
+parameters:
+ health_node_name_0:
+ type: string
+ label: Node name
+ description: Name of the node
+ # Flavors of each node
+ health_node_flavor_name:
+ type: string
+ label: Flavor
+ description: Type of instance (flavor) to be used for health node
+ # Images of each node
+ health_node_image_name:
+ type: string
+ label: Image name
+ description: OpenStack VM image to be used for node
+ # Others
+ private_net_id:
+ type: string
+ label: Private network name or ID
+ description: Private network
+ key_name:
+ type: string
+ label: Key pair name
+ description: Public/Private key pair name
+ vnf_id:
+ type: string
+ label: VNF ID
+ description: The VNF ID is provided by ONAP
+ vnf_name:
+ type: string
+ description: Unique name for this VNF instance
+ vf_module_id:
+ type: string
+ label: module ID
+ description: The Module ID is provided by ONAP
+ vf_module_name:
+ type: string
+ description: Unique name for VNF Module instance
+ dcae_collector_ip_0:
+ type: string
+
+resources:
+ health_node:
+ type: OS::Nova::Server
+ properties:
+ name: { get_param: health_node_name_0 }
+ key_name: { get_param: key_name }
+ image: { get_param: health_node_image_name }
+ flavor: { get_param: health_node_flavor_name }
+ networks:
+ - network: { get_param: private_net_id }
+ metadata:
+ vnf_name: { get_param: vnf_name }
+ vnf_id: { get_param: vnf_id }
+ vf_module_name: { get_param: vf_module_name }
+ vf_module_id: { get_param: vf_module_id }
+
+outputs:
+ oam_management_v4_address:
+ value: {get_attr: [health_node, networks, { get_param: private_net_id }, 0]}
+
--- /dev/null
+---
+# PM Dictionary Schema
+pmMetaData: { presence: required, structure: {
+ pmHeader: { presence: required, structure: {
+ pmDefVsn: { presence: required, comment: “Version of the PM Dictionary artifact that contains this measurement. Vendor defined.”},
+ pmDefSchemaVsn: { presence: required, comment: “PM Dictionary schema version from the VES Event Registration specification.”},
+ nfType: { presence: required, comment: “NF type to whom this measurement applies. This should match the nfName-vendor string used in the fileReady or perf3gpp eventName.”}
+ } } ,
+ pmFields: { presence: required, structure: {
+ measType: { presence: required, comment: “Measurement name used in PM file, in 3GPP format where specified, else vendor defined. Names for 3GPP-defined 4G measurements are specified in 3GPP TS 32.425 item e). Names for 3GPP-defined 5G measurements are specified in 3GPP TS 28.552 item e). Vendor defined names are preceded with VS.”},
+ iMeasType: { presence: required, comment: “Vendor defined integer identifier for the measType, used for efficiency in GPB. Must be combined with measInfoId to identify a specific measurement.”},
+ measDescription: { presence: required, comment: “Text description of the purpose of the measurement, what information does the measurement provide.”},
+ measCondition: { presence: required, comment: “Text description of the condition that causes the measurement to be updated.”},
+ measResultType: { presence: required, value: [integer], comment: “Data type of the measurement result.”},
+ measResultRange: { presence: optional, comment: “Range of the measurement result. Only necessary when the range is smaller than the full range of the data type.”},
+ measResultUnits: { presence: required, value: [seconds, minutes, nanoseconds, microseconds, dB, number, kilobytes, bytes, ethernetFrames, packets, users], comment: “Units of measure of the measurement result.”},
+ measObjClass: { presence: required, comment: “Object class of the measurement.”},
+ measCollectionMethod: { presence: required, value: [CC, SI, DER, Gauge, Average], comment: “Measurement collection method of the measurement. CC, SI, DER and Gauge are as defined in 3GPP. Average contains the average value of the measurement during the granularity period.”},
+ measLastChange: { presence: required, comment: “Version of the PM Dictionary artifact the last time this measurement was added, modified or deleted.”},
+ measChangeType: { presence: required, value: [added, modified, deleted], comment: “Indicates the type of change that occurred during the measLastChange.”},
+ measInfoId: { presence: required, comment: “Name for a group of related measurements, in 3GPP format where specified, else vendor defined. Family names for 3GPP-defined 4G measurements are specified in 3GPP TS 32.425 Section 3.1. Family names for 3GPP-defined 5G measurements are specified in 3GPP TS 28.552 Section 3.4.”},
+ iMeasInfoId: { presence: required, comment: “Vendor defined integer identifier for the measInfoId, used for efficiency in GPB.”},
+ measFamily: { presence: required, comment: “Abbreviation for a family of measurements, in 3GPP format where specified, else vendor defined.”},
+ measAdditionalFields: { presence: required, comment: “This section contains vendor specific measurement fields.”, structure: {
+ measAggregationLevels: { presence: required, value: [NRBTS, NRCellCU, NRCellDU, IPNO, IPSEC, ETHIF], comment: “A list of one or more aggregations levels that Nokia recommends for this measurement. For example, if the value is NRBTS NRCellCU, then Nokia recommends that this measurement be aggregated on the 5G BTS level and the 5G CU Cell level.”},
+ measTriggerType: { presence: optional, value: [Event, Sample], comment: “Indicates whether this measurement is triggered by an event or is sampled.”}
+ } }
+ } }
+} }
+---
+pmMetaData:
+ pmHeader:
+ nfType: gnb-Nokia
+ pmDefSchemaVsn: 2.0
+ pmDefVsn: 5G19_1906_002
+ pmFields:
+ iMeasInfoId: 2204
+ iMeasType: 1
+ measCollectionMethod: CC
+ measCondition: "This measurement is updated when X2AP: SgNB Modification Required message is sent to MeNB with the SCG Change Indication set as PSCellChange."
+ measDescription: "This counter indicates the number of intra gNB intra frequency PSCell change attempts."
+ measFamily: NINFC
+ measInfoId: "NR Intra Frequency PSCell Change"
+ measLastChange: 5G18A_1807_003
+ measObjClass: NGCELL
+ measResultRange: 0-4096
+ measResultType: integer
+ measResultUnits: number
+ measType: VS.NINFC.IntraFrPscelChAttempt
+ measAdditionalFields:
+ vendorField1: X
+ vendorField2: B
+ measAggregationLevels: NRCellCU
+ measChangeType: added
+---
+pmMetaData:
+ pmHeader:
+ nfType: gnb-Nokia
+ pmDefSchemaVsn: 2.0
+ pmDefVsn: 5G19_1906_002
+ pmFields:
+ iMeasInfoId: 2204
+ iMeasType: 2
+ measCollectionMethod: CC
+ measCondition: "This measurement is updated when the TDCoverall timer has elapsed before gNB receives the X2AP: SgNB Modification Confirm message."
+ measDescription: "This measurement the number of intra gNB intra frequency PSCell change failures due to TDCoverall timer expiry."
+ measFamily: NINFC
+ measInfoId: "NR Intra Frequency PSCell Change"
+ measLastChange: 5G18A_1807_003
+ measObjClass: NGCELL
+ measResultRange: 0-4096
+ measResultType: integer
+ measResultUnits: number
+ measType: VS.NINFC.IntraFrPscelChFailTdcExp
+ measAdditionalFields:
+ vendorField1: Y
+ measAggregationLevels: NRCellCU
+ measChangeType: added
+---
+pmMetaData:
+ pmHeader:
+ nfType: gnb-Nokia
+ pmDefSchemaVsn: 2.0
+ pmDefVsn: 5G19_1906_002
+ pmFields:
+ iMeasInfoId: 2206
+ iMeasType: 1
+ measCollectionMethod: CC
+ measCondition: "This measurement is updated when MeNB replies to X2AP: SgNB Modification Required message with the X2AP: SgNB Modification Refuse message."
+ measDescription: "This counter indicates the number of intra gNB intra frequency PSCell change failures due to MeNB refusal."
+ measFamily: NINFC
+ measInfoId: "NR Intra Frequency PSCell Change"
+ measLastChange: 5G19_1906_002
+ measObjClass: NGCELL
+ measResultRange: 0-4096
+ measResultType: integer
+ measResultUnits: number
+ measType: VS.NINFC.IntraFrPscelChFailMenbRef
+ measAdditionalFields:
+ vendorField1: Z
+ vendorField2: A
+ measAggregationLevels: NRCellCU
+ measChangeType: added
+...
+
+++ /dev/null
----
-# PM Dictionary schema specifying and describing the meta information
-# used to define perf3gpp measurements in the PM Dictionary
-pmMetaData:
- presence: required
- structure:
- pmHeader:
- presence: required
- structure:
- nfType:
- presence: required
- comment: NF type; should match the nfName-vendor string used in the fileReady
- or perf3gpp eventName
- pmDefSchemaVsn:
- presence: required
- value: 2.0
- comment: PM Dictionary Schema Version from the VES Event Registration specification
- pmDefVsn:
- presence: required
- comment: vendor-defined PM Dictionary version
- pmFields:
- presence: required
- structure:
- iMeasInfoId:
- presence: required
- comment: vendor-defined integer measurement group identifier
- iMeasType:
- presence: required
- comment: vendor-defined integer identifier for the measType; must be combined
- with measInfoId to identify a specific measurement.
- measChangeType:
- presence: required
- value:
- - added
- - modified
- - deleted
- comment: indicates the type of change that occurred during measLastChange
- measCollectionMethod:
- presence: required
- value:
- - CC
- - SI
- - DER
- - Gauge
- - Average
- comment: the measurement collection method; CC, SI, DER and Gauge are as
- defined in 3GPP; average contains the average value of the measurement
- during the granularity period
- measCondition:
- presence: required
- comment: description of the condition causing the measurement
- measDescription:
- presence: required
- comment: description of the measurement information and purpose
- measFamily:
- presence: required
- comment: abbreviation for a family of measurements, in 3GPP format, or vendor
- defined
- measInfoId:
- presence: required
- comment: name for a group of related measurements in 3GPP format or vendor
- defined
- measLastChange:
- presence: required
- comment: version of the PM Dictionary the last time this measurement was
- added, modified or deleted
- measObjClass:
- presence: required
- value:
- - NGBTS
- - NGCELL
- - IPNO
- - IPSEC
- - ETHIF
- comment: measurement object class
- measResultRange:
- presence: optional
- comment: range of the measurement result; only necessary when the range
- is smaller than the full range of the data type
- measResultType:
- presence: required
- value:
- - float
- - uint32
- - uint64
- comment: data type of the measurement result
- measResultUnits:
- presence: required
- value:
- - seconds
- - minutes
- - nanoseconds
- - microseconds
- - dB
- - number
- - kilobytes
- - bytes
- - ethernetFrames
- - packets
- - users
- comment: units of measure for the measurement result
- measType:
- presence: required
- comment: measurement name in 3GPP or vendor-specific format; vendor specific
- names are preceded with VS
- measAdditionalFields:
- presence: required
- comment: vendor-specific PM Dictionary fields
- structure:
- vendorField1:
- presence: required
- value:
- - X
- - Y
- - Z
- comment: vendor field 1 description
- vendorField2:
- presence: optional
- value:
- - A
- - B
- comment: vendor field 2 description.
-...
-# PM Dictionary perf3gpp measurements for the gnb-Nokia NF (bracket style yaml)
----
-pmMetaData:
- pmHeader:
- nfType: gnb-Nokia
- pmDefSchemaVsn: 2.0
- pmDefVsn: 5G19_1906_002
- pmFields:
- iMeasInfoId: 2204
- iMeasType: 1
- measCollectionMethod: CC
- measCondition: "This measurement is updated when X2AP: SgNB Modification Required message is sent to MeNB
- with the SCG Change Indication set as PSCellChange."
- measDescription: "This counter indicates the number of intra gNB intra frequency PSCell change attempts."
- measFamily: NINFC
- measInfoId: "NR Intra Frequency PSCell Change"
- measLastChange: 5G18A_1807_003
- measObjClass: NGCELL
- measResultRange: 0-4096
- measResultType: float
- measChangeType: added
- measResultUnits: number
- measType: VS.NINFC.IntraFrPscelChAttempt
- measAdditionalFields:
- vendorField1: X
- vendorField2: B
-...
----
-pmMetaData:
- pmHeader:
- nfType: gnb-Nokia
- pmDefSchemaVsn: 2.0
- pmDefVsn: 5G19_1906_002
- pmFields:
- iMeasInfoId: 2204
- iMeasType: 2
- measCollectionMethod: CC
- measCondition: "This measurement is updated when the TDCoverall timer has elapsed before gNB receives the X2AP: SgNB Modification Confirm message."
- measDescription: "This measurement the number of intra gNB intra frequency PSCell change failures due to TDCoverall timer expiry."
- measFamily: NINFC
- measInfoId: "NR Intra Frequency PSCell Change"
- measLastChange: 5G18A_1807_003
- measObjClass: NGCELL
- measResultRange: 0-4096
- measResultType: float
- measChangeType: added
- measResultUnits: number
- measType: VS.NINFC.IntraFrPscelChFailTdcExp
- measAdditionalFields:
- vendorField1:
- - Y
- - X
-...
----
-pmMetaData:
- pmHeader:
- nfType: gnb-Nokia
- pmDefSchemaVsn: 2.0
- pmDefVsn: 5G19_1906_002
- pmFields:
- iMeasInfoId: 2206
- iMeasType: 1
- measCondition: "This measurement is updated when MeNB replies to X2AP: SgNB Modification Required message with the X2AP: SgNB Modification Refuse message."
- measCollectionMethod: CC
- measDescription: "This counter indicates the number of intra gNB intra frequency PSCell change failures due to MeNB refusal."
- measFamily: NINFC
- measInfoId: "NR Intra Frequency PSCell Change"
- measLastChange: 5G19_1906_002
- measObjClass: NGCELL
- measResultRange: 0-4096
- measResultType: float
- measChangeType: added
- measResultUnits: number
- measType: VS.NINFC.IntraFrPscelChFailMenbRef
- measAdditionalFields:
- vendorField1:
- - X
- - Y
- vendorField2: A
-...
----
-pmMetaData:
- pmHeader:
- nfType: gnb-Nokia
- pmDefSchemaVsn: 2.0
- pmDefVsn: 5G19_1906_002
- pmFields:
- iMeasInfoId: 2206
- iMeasType: 1
- measCondition: "This measurement is updated when MeNB replies to X2AP: SgNB Modification Required message with the X2AP: SgNB Modification Refuse message."
- measCollectionMethod: CC
- measDescription: "This counter indicates the number of intra gNB intra frequency PSCell change failures due to MeNB refusal."
- measFamily: NINFC
- measInfoId: "NR Intra Frequency PSCell Change"
- measLastChange: 5G19_1906_002
- measObjClass: NGCELL
- measResultRange: 0-4096
- measResultType: float
- measChangeType: added
- measResultUnits: number
- measType: VS.NINFC.IntraFrPscelChFailMenbRef
- measAdditionalFields:
- vendorField1:
- - X
- - Z
- vendorField2: A
-...
--- /dev/null
+{
+ "name": "Health VNF",
+ "description": "Health VNF onboarding package.",
+ "data": [
+ {
+ "file": "health_base_node.yaml",
+ "type": "HEAT",
+ "isBase": "true",
+ "data": [
+ {
+ "file": "health_base_node.env",
+ "type": "HEAT_ENV"
+ }
+ ]
+ },
+ {
+ "file": "pmdict.yaml",
+ "type": "OTHER"
+ }
+ ]
+}
--- /dev/null
+parameters:
+ health_node_name_0: health_app_vm
+ health_node_image_name: ubuntu-java
+ health_node_flavor_name: aa.001-0002
+ key_name: galix_key
+ private_net_id: onap-wro
--- /dev/null
+heat_template_version: '2013-05-23'
+
+description: Heat template that deploys PnP PNF simulator
+
+parameters:
+ health_node_name_0:
+ type: string
+ label: Node name
+ description: Name of the node
+ # Flavors of each node
+ health_node_flavor_name:
+ type: string
+ label: Flavor
+ description: Type of instance (flavor) to be used for health node
+ # Images of each node
+ health_node_image_name:
+ type: string
+ label: Image name
+ description: OpenStack VM image to be used for node
+ # Others
+ private_net_id:
+ type: string
+ label: Private network name or ID
+ description: Private network
+ key_name:
+ type: string
+ label: Key pair name
+ description: Public/Private key pair name
+ vnf_id:
+ type: string
+ label: VNF ID
+ description: The VNF ID is provided by ONAP
+ vnf_name:
+ type: string
+ description: Unique name for this VNF instance
+ vf_module_id:
+ type: string
+ label: module ID
+ description: The Module ID is provided by ONAP
+ vf_module_name:
+ type: string
+ description: Unique name for VNF Module instance
+ dcae_collector_ip_0:
+ type: string
+
+resources:
+ health_node:
+ type: OS::Nova::Server
+ properties:
+ name: { get_param: health_node_name_0 }
+ key_name: { get_param: key_name }
+ image: { get_param: health_node_image_name }
+ flavor: { get_param: health_node_flavor_name }
+ networks:
+ - network: { get_param: private_net_id }
+ metadata:
+ vnf_name: { get_param: vnf_name }
+ vnf_id: { get_param: vnf_id }
+ vf_module_name: { get_param: vf_module_name }
+ vf_module_id: { get_param: vf_module_id }
+
+outputs:
+ oam_management_v4_address:
+ value: {get_attr: [health_node, networks, { get_param: private_net_id }, 0]}
--- /dev/null
+---
+# PM Dictionary Schema
+pmMetaData: { presence: required, structure: {
+ pmHeader: { presence: required, structure: {
+ pmDefVsn: { presence: required, comment: “Version of the PM Dictionary artifact that contains this measurement. Vendor defined.”},
+ pmDefSchemaVsn: { presence: required, comment: “PM Dictionary schema version from the VES Event Registration specification.”},
+ nfType: { presence: required, comment: “NF type to whom this measurement applies. This should match the nfName-vendor string used in the fileReady or perf3gpp eventName.”}
+ } } ,
+ pmFields: { presence: required, structure: {
+ measType: { presence: required, comment: “Measurement name used in PM file, in 3GPP format where specified, else vendor defined. Names for 3GPP-defined 4G measurements are specified in 3GPP TS 32.425 item e). Names for 3GPP-defined 5G measurements are specified in 3GPP TS 28.552 item e). Vendor defined names are preceded with VS.”},
+ iMeasType: { presence: required, comment: “Vendor defined integer identifier for the measType, used for efficiency in GPB. Must be combined with measInfoId to identify a specific measurement.”},
+ measDescription: { presence: required, comment: “Text description of the purpose of the measurement, what information does the measurement provide.”},
+ measCondition: { presence: required, comment: “Text description of the condition that causes the measurement to be updated.”},
+ measResultType: { presence: required, value: [integer], comment: “Data type of the measurement result.”},
+ measResultRange: { presence: optional, comment: “Range of the measurement result. Only necessary when the range is smaller than the full range of the data type.”},
+ measResultUnits: { presence: required, value: [seconds, minutes, nanoseconds, microseconds, dB, number, kilobytes, bytes, ethernetFrames, packets, users], comment: “Units of measure of the measurement result.”},
+ measObjClass: { presence: required, comment: “Object class of the measurement.”},
+ measCollectionMethod: { presence: required, value: [CC, SI, DER, Gauge, Average], comment: “Measurement collection method of the measurement. CC, SI, DER and Gauge are as defined in 3GPP. Average contains the average value of the measurement during the granularity period.”},
+ measLastChange: { presence: required, comment: “Version of the PM Dictionary artifact the last time this measurement was added, modified or deleted.”},
+ measChangeType: { presence: required, value: [added, modified, deleted], comment: “Indicates the type of change that occurred during the measLastChange.”},
+ measInfoId: { presence: required, comment: “Name for a group of related measurements, in 3GPP format where specified, else vendor defined. Family names for 3GPP-defined 4G measurements are specified in 3GPP TS 32.425 Section 3.1. Family names for 3GPP-defined 5G measurements are specified in 3GPP TS 28.552 Section 3.4.”},
+ iMeasInfoId: { presence: required, comment: “Vendor defined integer identifier for the measInfoId, used for efficiency in GPB.”},
+ measFamily: { presence: required, comment: “Abbreviation for a family of measurements, in 3GPP format where specified, else vendor defined.”},
+ measAdditionalFields: { presence: required, comment: “This section contains vendor specific measurement fields.”, structure: {
+ measAggregationLevels: { presence: required, value: [NRBTS, NRCellCU, NRCellDU, IPNO, IPSEC, ETHIF], comment: “A list of one or more aggregations levels that Nokia recommends for this measurement. For example, if the value is NRBTS NRCellCU, then Nokia recommends that this measurement be aggregated on the 5G BTS level and the 5G CU Cell level.”},
+ measTriggerType: { presence: optional, value: [Event, Sample], comment: “Indicates whether this measurement is triggered by an event or is sampled.”}
+ } }
+ } }
+} }
+---
+pmMetaData:
+ pmFields:
+ iMeasInfoId: 2204
+ iMeasType: 1
+ measCollectionMethod: CC
+ measCondition: "This measurement is updated when X2AP: SgNB Modification Required message is sent to MeNB with the SCG Change Indication set as PSCellChange."
+ measDescription: "This counter indicates the number of intra gNB intra frequency PSCell change attempts."
+ measFamily: NINFC
+ measInfoId: "NR Intra Frequency PSCell Change"
+ measLastChange: 5G18A_1807_003
+ measObjClass: NGCELL
+ measResultRange: 0-4096
+ measResultType: integer
+ measResultUnits: number
+ measType: VS.NINFC.IntraFrPscelChAttempt
+ measAdditionalFields:
+ vendorField1: X
+ vendorField2: B
+ measAggregationLevels: NRCellCU
+ measChangeType: added
+---
+pmMetaData:
+ pmHeader:
+ nfType: gnb-Nokia
+ pmDefSchemaVsn: 2.0
+ pmDefVsn: 5G19_1906_002
+ pmFields:
+ iMeasInfoId: 2204
+ iMeasType: 2
+ measCollectionMethod: CC
+ measCondition: "This measurement is updated when the TDCoverall timer has elapsed before gNB receives the X2AP: SgNB Modification Confirm message."
+ measDescription: "This measurement the number of intra gNB intra frequency PSCell change failures due to TDCoverall timer expiry."
+ measFamily: NINFC
+ measInfoId: "NR Intra Frequency PSCell Change"
+ measLastChange: 5G18A_1807_003
+ measObjClass: NGCELL
+ measResultRange: 0-4096
+ measResultType: integer
+ measResultUnits: number
+ measType: VS.NINFC.IntraFrPscelChFailTdcExp
+ measAdditionalFields:
+ vendorField1: Y
+ measAggregationLevels: NRCellCU
+ measChangeType: added
+---
+pmMetaData:
+ pmHeader:
+ nfType: gnb-Nokia
+ pmDefSchemaVsn: 2.0
+ pmDefVsn: 5G19_1906_002
+ pmFields:
+ iMeasInfoId: 2206
+ iMeasType: 1
+ measCollectionMethod: CC
+ measCondition: "This measurement is updated when MeNB replies to X2AP: SgNB Modification Required message with the X2AP: SgNB Modification Refuse message."
+ measDescription: "This counter indicates the number of intra gNB intra frequency PSCell change failures due to MeNB refusal."
+ measFamily: NINFC
+ measInfoId: "NR Intra Frequency PSCell Change"
+ measLastChange: 5G19_1906_002
+ measObjClass: NGCELL
+ measResultRange: 0-4096
+ measResultType: integer
+ measResultUnits: number
+ measType: VS.NINFC.IntraFrPscelChFailMenbRef
+ measAdditionalFields:
+ vendorField1: Z
+ vendorField2: A
+ measAggregationLevels: NRCellCU
+ measChangeType: added
+...
+
* 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.
+ *
+ * Modifications copyright (c) 2021 Nokia
*/
package org.openecomp.sdc.vendorsoftwareproduct.services.filedatastructuremodule;
String createManifest(VspDetails vspDetails, FilesDataStructure structure);
+ String createManifestFromExisting(VspDetails vspDetails, FilesDataStructure structure, ManifestContent existingManifest);
+
Optional<List<ErrorMessage>> validateFileDataStructure(FilesDataStructure filesDataStructure);
void updateValidationData(String vspId, Version version, ValidationStructureList validationData);
* SDC
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modifications copyright (c) 2021 Nokia
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
public interface ManifestCreator {
Optional<ManifestContent> createManifest(VspDetails vspDetails, FilesDataStructure filesDataStructure);
+ Optional<ManifestContent> createManifestFromExisting(VspDetails vspDetails, FilesDataStructure filesDataStructure, ManifestContent existingManifest);
+
Optional<ManifestContent> createManifest(VspDetails vspDetails, FileContentHandler
fileContentHandler, AnalyzedZipHeatFiles analyzedZipHeatFiles);
/*
* Copyright © 2016-2018 European Support Limited
+ * Modifications copyright (c) 2021 Nokia
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
.withMessage(Messages.CREATE_MANIFEST_FROM_ZIP.getErrorMessage()).build())));
}
+ @Override
+ public String createManifestFromExisting(VspDetails vspDetails, FilesDataStructure structure, ManifestContent existingManifest) {
+ return JsonUtil.object2Json(manifestCreator.createManifestFromExisting(vspDetails, structure, existingManifest)
+ .orElseThrow(() -> new CoreException(new ErrorCode.ErrorCodeBuilder()
+ .withMessage(Messages.CREATE_MANIFEST_FROM_ZIP.getErrorMessage()).build())));
+ }
+
@Override
public Optional<ManifestContent> createManifest(VspDetails vspDetails,
FileContentHandler fileContentHandler,
/*
* Copyright © 2016-2017 European Support Limited
+ * Modifications copyright (c) 2021 Nokia
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
addModulesToManifestFileDataList(filesDataStructure, fileDataList);
addNestedToManifest(filesDataStructure, fileDataList);
addArtifactsToManifestFileDataList(filesDataStructure, fileDataList);
+
+ ManifestContent manifestContent = createManifest(vspDetails, fileDataList);
+ return Optional.of(manifestContent);
+ }
+
+ @Override
+ public Optional<ManifestContent> createManifestFromExisting(VspDetails vspDetails, FilesDataStructure filesDataStructure, ManifestContent existingManifest) {
+ if (Objects.isNull(filesDataStructure)) {
+ return Optional.empty();
+ }
+
+ List<FileData> fileDataList = new ArrayList<>();
+ addModulesToManifestFileDataList(filesDataStructure, fileDataList);
+ addNestedToManifest(filesDataStructure, fileDataList);
+ addArtifactsToManifestFileDataList(filesDataStructure, fileDataList, existingManifest);
+
ManifestContent manifestContent = createManifest(vspDetails, fileDataList);
return Optional.of(manifestContent);
}
+ private void addArtifactsToManifestFileDataList(FilesDataStructure filesDataStructure, List<FileData> fileDataList, ManifestContent existingManifest) {
+ Collection<String> forArtifacts = CollectionUtils
+ .union(filesDataStructure.getArtifacts(), filesDataStructure.getUnassigned());
+ if (CollectionUtils.isNotEmpty(forArtifacts)) {
+ for (String artifact : forArtifacts) {
+ if (isCloudSpecificArtifact(artifact)) {
+ fileDataList.add(createBaseFileData(FileData.Type.CLOUD_TECHNOLOGY_SPECIFIC_ARTIFACT, artifact));
+ } else if (isControllerBlueprintArchive(artifact)) {
+ fileDataList.add(createBaseFileData(FileData.Type.CONTROLLER_BLUEPRINT_ARCHIVE, artifact));
+ } else if (isHelm(artifact)) {
+ fileDataList.add(createBaseFileData(FileData.Type.HELM, artifact));
+ } else if (isPmDictionary(artifact, existingManifest)) {
+ fileDataList.add(createBaseFileData(FileData.Type.PM_DICTIONARY, artifact));
+ }
+ else {
+ fileDataList.add(createBaseFileData(FileData.Type.OTHER, artifact));
+ }
+ }
+ }
+ }
+
+ private boolean isPmDictionary(String artifact, ManifestContent existingManifest) {
+ return existingManifest.getData()
+ .stream()
+ .filter(fileData -> fileData.getType()
+ .equals(FileData.Type.PM_DICTIONARY))
+ .map(FileData::getFile)
+ .anyMatch(pmDictionaryFile -> pmDictionaryFile.equals(artifact));
+ }
+
private void addNestedToManifest(
FilesDataStructure filesDataStructure, List<FileData> fileDataList) {
if (CollectionUtils.isNotEmpty(filesDataStructure.getNested())) {
fileDataList.add(createBaseFileData(FileData.Type.CONTROLLER_BLUEPRINT_ARCHIVE, artifact));
} else if (isHelm(artifact)) {
fileDataList.add(createBaseFileData(FileData.Type.HELM, artifact));
- }
- else {
+ } else {
fileDataList.add(createBaseFileData(FileData.Type.OTHER, artifact));
}
}
* SDC
* ================================================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications copyright (c) 2021 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.
package org.openecomp.sdc.vendorsoftwareproduct.services.impl.filedatastructuremodule;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.openecomp.sdc.heat.datatypes.manifest.FileData;
+import org.openecomp.sdc.heat.datatypes.manifest.ManifestContent;
+import org.openecomp.sdc.vendorsoftwareproduct.dao.type.VspDetails;
+import org.openecomp.sdc.vendorsoftwareproduct.types.candidateheat.FilesDataStructure;
-import java.util.ArrayList;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
+import java.util.Optional;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
public class ManifestCreatorNamingConventionImplTest extends ManifestCreatorNamingConventionImpl {
private static final String ARTIFACT_3 = "cloudtech_aws_configtemplate.zip";
private static final String ARTIFACT_4 = "k8s_charts.zip";
private static final String ARTIFACT_5 = "cloudtech_openstack_configtemplate.zip";
+ private static final String PMDICT_YAML = "pmdict.yaml";
+
@Test
- public void testIsCloudSpecificArtifact() {
+ void testIsCloudSpecificArtifact() {
assertTrue(isCloudSpecificArtifact(ARTIFACT_1));
assertTrue(isCloudSpecificArtifact(ARTIFACT_2));
assertTrue(isCloudSpecificArtifact(ARTIFACT_3));
assertFalse(isCloudSpecificArtifact(ARTIFACT_4));
assertFalse(isCloudSpecificArtifact(ARTIFACT_5));
}
+
+ @Test
+ void shouldMapPmDictionaryTypeFromExistingManifestToPmDictionaryTypeInNewManifest() {
+ // given
+ VspDetails vspDetails = new VspDetails();
+ FilesDataStructure fileDataStructure = new FilesDataStructure();
+ fileDataStructure.setArtifacts(List.of(PMDICT_YAML));
+ ManifestContent existingManifest = prepareManifestWithPmDictFileWithType(FileData.Type.PM_DICTIONARY);
+
+ // when
+ Optional<ManifestContent> newManifest = new ManifestCreatorNamingConventionImpl()
+ .createManifestFromExisting(vspDetails, fileDataStructure, existingManifest);
+
+ // then
+ assertTrue(newManifest.isPresent());
+ assertTrue(newManifest.get()
+ .getData()
+ .stream()
+ .allMatch(fd -> fd.getType().equals(FileData.Type.PM_DICTIONARY) &&
+ fd.getFile().equals(PMDICT_YAML)));
+ }
+
+ @Test
+ void shouldMapPmDictionaryWithOtherTypeFromExistingManifestToOtherTypeInNewManifest() {
+ // given
+ VspDetails vspDetails = new VspDetails();
+ FilesDataStructure fileDataStructure = new FilesDataStructure();
+ fileDataStructure.setArtifacts(List.of(PMDICT_YAML));
+ ManifestContent existingManifest = prepareManifestWithPmDictFileWithType(FileData.Type.OTHER);
+
+ // when
+ Optional<ManifestContent> newManifest = new ManifestCreatorNamingConventionImpl()
+ .createManifestFromExisting(vspDetails, fileDataStructure, existingManifest);
+
+ // then
+ assertTrue(newManifest.isPresent());
+ assertTrue(newManifest.get()
+ .getData()
+ .stream()
+ .allMatch(fd -> fd.getType().equals(FileData.Type.OTHER) &&
+ fd.getFile().equals(PMDICT_YAML)));
+ }
+
+ private ManifestContent prepareManifestWithPmDictFileWithType(FileData.Type fileType) {
+ ManifestContent existingManifest = new ManifestContent();
+ FileData fileData = new FileData();
+ fileData.setFile(PMDICT_YAML);
+ fileData.setType(fileType);
+ existingManifest.setData(List.of(fileData));
+ return existingManifest;
+ }
}