diff options
Diffstat (limited to 'openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl')
4 files changed, 63 insertions, 3 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidator.java index b2c25c2d5f..4f640dff29 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidator.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidator.java @@ -154,6 +154,9 @@ public class NovaServerNamingConventionGuideLineValidator implements ResourceVal Map<String, String> uniqueResourcePortNetworkRole, HeatOrchestrationTemplate heatOrchestrationTemplate, GlobalValidationContext globalValidationContext) { + if (MapUtils.isEmpty(heatOrchestrationTemplate.getResources().get(resourceId).getProperties())) { + return; + } Object propertyNetworkValue = heatOrchestrationTemplate.getResources().get(resourceId).getProperties().get("networks"); if (propertyNetworkValue != null && propertyNetworkValue instanceof List) { @@ -320,15 +323,16 @@ public class NovaServerNamingConventionGuideLineValidator implements ResourceVal private Map<String, String> validateImageAndFlavorFromNovaServer(String fileName, Map.Entry<String, Resource> resourceEntry, GlobalValidationContext globalContext) { + Map<String, String> imageAndFlavorLegalNames = new HashMap<>(); + if (MapUtils.isEmpty(resourceEntry.getValue().getProperties())) { - return null; + return imageAndFlavorLegalNames; } Pair<String, String> imagePair = new ImmutablePair<>("image", ".*_image_name"); Pair<String, String> flavorPair = new ImmutablePair<>("flavor", ".*_flavor_name"); List<Pair<String, String>> imageFlavorPairs = Arrays.asList(imagePair, flavorPair); Map<String, Object> propertiesMap = resourceEntry.getValue().getProperties(); - Map<String, String> imageAndFlavorLegalNames = new HashMap<>(); for (Pair<String, String> imageOrFlavor : imageFlavorPairs) { boolean isErrorInImageOrFlavor = diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidatorTest.java index 26aad3cdf8..759b376b97 100644 --- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidatorTest.java +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/namingconvention/NovaServerNamingConventionGuideLineValidatorTest.java @@ -73,9 +73,21 @@ public class NovaServerNamingConventionGuideLineValidatorTest { } @Test - public void testNovaImageAndFlavorNames() { + public void testNovaImageAndFlavorNamesEmptyProperties() { Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(), + PATH + "heatNovaServerImageAndFlavor/negativeEmptyProperties"); + Assert.assertNotNull(messages); + Assert.assertEquals(1, messages.size()); + Assert.assertEquals(1, messages.get("first.yaml").getErrorMessageList().size()); + Assert.assertEquals(messages.get("first.yaml").getErrorMessageList().get(0).getMessage(), + "WARNING: [NNS13]: Server 'image' Parameter Name not aligned with Guidelines, Parameter Name [fsb2-image], Resource ID [FSB3]. As a result, VF/VFC Profile may miss this information"); + } + + @Test + public void testNovaImageAndFlavorNames() { + Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator, + resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(), PATH + "heatNovaServerImageAndFlavor/positive"); Assert.assertNotNull(messages); Assert.assertEquals(messages.size(), 0); diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/novaserverValidation/heatNovaServerImageAndFlavor/negativeEmptyProperties/MANIFEST.json b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/novaserverValidation/heatNovaServerImageAndFlavor/negativeEmptyProperties/MANIFEST.json new file mode 100644 index 0000000000..d4525527bd --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/novaserverValidation/heatNovaServerImageAndFlavor/negativeEmptyProperties/MANIFEST.json @@ -0,0 +1,14 @@ +{ + "name": "validTest", + "description": "Valid Test", + "version": "1610", + "data": [ + { + "file": "first.yaml", + "type": "HEAT", + "isBase": true, + "data": [ + ] + } + ] +} diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/novaserverValidation/heatNovaServerImageAndFlavor/negativeEmptyProperties/first.yaml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/novaserverValidation/heatNovaServerImageAndFlavor/negativeEmptyProperties/first.yaml new file mode 100644 index 0000000000..19731db73d --- /dev/null +++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/guideLineValidator/novaserverValidation/heatNovaServerImageAndFlavor/negativeEmptyProperties/first.yaml @@ -0,0 +1,30 @@ +heat_template_version: 2013-05-23 + +description: heat expose volume resource + +resources: + FSB2: + type: OS::Nova::Server + properties: + + FSB3: + type: OS::Nova::Server + properties: + name: { get_param: fsb2_name_2 } + block_device_mapping: [{device_name: "vda", volume_id : {get_param: VMME_FSB2_boot_volume }, delete_on_termination: "false" }] + image: { get_param: fsb2-image } + availability_zone: { get_param: availability_zone_0 } + metadata: + VNF_id: { get_param: vnfvfVF_id } + vf_module_id: { get_param: vf_module_id } + networks: + - port: { get_resource: FSB2_Internal1 } + - port: { get_resource: FSB2_Internal2 } + - port: { get_resource: FSB2_OAM } + +outputs: + expose_resource_nove_output: + description: the pcrf_server + value: { get_resource: FSB2 } + + |