summaryrefslogtreecommitdiffstats
path: root/openecomp-be/lib
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-be/lib')
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerGroupResourceValidator.java74
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerGroupResourceValidatorTest.java36
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/server_group_called_by_nova_server_negative/input/MANIFEST.json17
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/server_group_called_by_nova_server_negative/input/hot-nimbus-pps_v1.0.env11
-rw-r--r--openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/server_group_called_by_nova_server_negative/input/hot-nimbus-pps_v1.0.yaml55
5 files changed, 148 insertions, 45 deletions
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerGroupResourceValidator.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerGroupResourceValidator.java
index f56d941ba4..a9cbbe565e 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerGroupResourceValidator.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/main/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerGroupResourceValidator.java
@@ -1,6 +1,7 @@
package org.openecomp.sdc.validation.impl.validators.heatresource;
import org.apache.commons.collections4.MapUtils;
+import org.openecomp.core.validation.ErrorMessageCode;
import org.openecomp.core.validation.errors.ErrorMessagesFormatBuilder;
import org.openecomp.core.validation.types.GlobalValidationContext;
import org.openecomp.sdc.common.errors.Messages;
@@ -25,12 +26,15 @@ import java.util.Objects;
*/
public class NovaServerGroupResourceValidator implements ResourceValidator {
private static MdcDataDebugMessage mdcDataDebugMessage = new MdcDataDebugMessage();
+ private static final ErrorMessageCode ERROR_CODE_HNG1 = new ErrorMessageCode("HNG1");
+ private static final ErrorMessageCode ERROR_CODE_HNG2 = new ErrorMessageCode("HNG2");
+ private static final ErrorMessageCode ERROR_CODE_HNG3 = new ErrorMessageCode("HNG3");
public void validate(String fileName, Map.Entry<String, Resource> resourceEntry,
GlobalValidationContext globalContext, ValidationContext validationContext) {
validateNovaServerGroupPolicy(fileName, resourceEntry, globalContext);
- validateServerGroupIsUsed
- (fileName, resourceEntry, globalContext, (HeatResourceValidationContext) validationContext);
+ validateServerGroupIsUsed(fileName, resourceEntry, globalContext,
+ (HeatResourceValidationContext) validationContext);
}
@SuppressWarnings("unchecked")
@@ -42,7 +46,7 @@ public class NovaServerGroupResourceValidator implements ResourceValidator {
Resource resource = resourceEntry.getValue();
Object policies =
- resource.getProperties() == null ? null : resource.getProperties().get("policies");
+ resource.getProperties() == null ? null : resource.getProperties().get("policies");
if (Objects.nonNull(policies) && policies instanceof List) {
List<Object> policiesList = (List<Object>) policies;
@@ -50,17 +54,19 @@ public class NovaServerGroupResourceValidator implements ResourceValidator {
Object policy = policiesList.get(0);
if (!isGivenPolicyValid(policy)) {
globalContext.addMessage(fileName, ErrorLevel.ERROR, ErrorMessagesFormatBuilder
- .getErrorWithParameters(Messages.WRONG_POLICY_IN_SERVER_GROUP.getErrorMessage(),
- resourceEntry.getKey()),
- LoggerTragetServiceName.VALIDATE_NOVA_SEVER_GROUP_POLICY,
- LoggerErrorDescription.WRONG_POLICY_SERVER_GROUP);
+ .getErrorWithParameters(
+ ERROR_CODE_HNG1, Messages.WRONG_POLICY_IN_SERVER_GROUP.getErrorMessage(),
+ resourceEntry.getKey()),
+ LoggerTragetServiceName.VALIDATE_NOVA_SEVER_GROUP_POLICY,
+ LoggerErrorDescription.WRONG_POLICY_SERVER_GROUP);
}
} else {
globalContext.addMessage(fileName, ErrorLevel.ERROR, ErrorMessagesFormatBuilder
- .getErrorWithParameters(Messages.WRONG_POLICY_IN_SERVER_GROUP.getErrorMessage(),
- resourceEntry.getKey()),
- LoggerTragetServiceName.VALIDATE_NOVA_SEVER_GROUP_POLICY,
- LoggerErrorDescription.WRONG_POLICY_SERVER_GROUP);
+ .getErrorWithParameters(ERROR_CODE_HNG1,
+ Messages.WRONG_POLICY_IN_SERVER_GROUP.getErrorMessage(),
+ resourceEntry.getKey()),
+ LoggerTragetServiceName.VALIDATE_NOVA_SEVER_GROUP_POLICY,
+ LoggerErrorDescription.WRONG_POLICY_SERVER_GROUP);
}
}
@@ -83,45 +89,43 @@ public class NovaServerGroupResourceValidator implements ResourceValidator {
HeatResourceValidationContext validationContext) {
Map<String, Map<String, List<String>>> pointedServerGroups =
- validationContext.getFileLevelResourceDependencies().get(HeatResourcesTypes
- .NOVA_SERVER_GROUP_RESOURCE_TYPE.getHeatResource());
+ validationContext.getFileLevelResourceDependencies().get(HeatResourcesTypes
+ .NOVA_SERVER_GROUP_RESOURCE_TYPE.getHeatResource());
if (MapUtils.isEmpty(pointedServerGroups)) {
globalContext
- .addMessage(
- fileName,
- ErrorLevel.WARNING,
- ErrorMessagesFormatBuilder
- .getErrorWithParameters(
- Messages.RESOURCE_NOT_IN_USE.getErrorMessage(),
- ValidatorConstants.Server_Group, resourceEntry.getKey()),
- LoggerTragetServiceName.VALIDATE_ALL_SERVER_GROUP_OR_SECURITY_GROUP_IN_USE,
- LoggerErrorDescription.SERVER_GROUP_SECURITY_GROUP_NOT_IN_USE);
+ .addMessage(
+ fileName,
+ ErrorLevel.WARNING,
+ ErrorMessagesFormatBuilder
+ .getErrorWithParameters(
+ ERROR_CODE_HNG2, Messages.RESOURCE_NOT_IN_USE.getErrorMessage(),
+ ValidatorConstants.Server_Group, resourceEntry.getKey()),
+ LoggerTragetServiceName.VALIDATE_ALL_SERVER_GROUP_OR_SECURITY_GROUP_IN_USE,
+ LoggerErrorDescription.SERVER_GROUP_SECURITY_GROUP_NOT_IN_USE);
return;
}
handleServerGroupReferences(fileName, resourceEntry, pointedServerGroups, globalContext);
-
-
}
private void handleServerGroupReferences(String fileName, Map.Entry<String, Resource>
- resourceEntry, Map<String, Map<String, List<String>>> pointedServerGroups,
+ resourceEntry, Map<String, Map<String, List<String>>> pointedServerGroups,
GlobalValidationContext globalContext) {
Map<String, List<String>> resourcesPointingToCurrServerGroup =
- pointedServerGroups.get(resourceEntry.getKey());
+ pointedServerGroups.get(resourceEntry.getKey());
if (MapUtils.isEmpty(resourcesPointingToCurrServerGroup)) {
globalContext
- .addMessage(
- fileName,
- ErrorLevel.WARNING,
- ErrorMessagesFormatBuilder
- .getErrorWithParameters(
- Messages.RESOURCE_NOT_IN_USE.getErrorMessage(),
- ValidatorConstants.Server_Group, resourceEntry.getKey()),
- LoggerTragetServiceName.VALIDATE_ALL_SERVER_GROUP_OR_SECURITY_GROUP_IN_USE,
- LoggerErrorDescription.SERVER_GROUP_SECURITY_GROUP_NOT_IN_USE);
+ .addMessage(
+ fileName,
+ ErrorLevel.WARNING,
+ ErrorMessagesFormatBuilder
+ .getErrorWithParameters(
+ ERROR_CODE_HNG3, Messages.RESOURCE_NOT_IN_USE.getErrorMessage(),
+ ValidatorConstants.Server_Group, resourceEntry.getKey()),
+ LoggerTragetServiceName.VALIDATE_ALL_SERVER_GROUP_OR_SECURITY_GROUP_IN_USE,
+ LoggerErrorDescription.SERVER_GROUP_SECURITY_GROUP_NOT_IN_USE);
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerGroupResourceValidatorTest.java b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerGroupResourceValidatorTest.java
index b0e6ebf631..af43dd1d78 100644
--- a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerGroupResourceValidatorTest.java
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/java/org/openecomp/sdc/validation/impl/validators/heatresource/NovaServerGroupResourceValidatorTest.java
@@ -17,35 +17,51 @@ public class NovaServerGroupResourceValidatorTest {
HeatResourceValidator baseValidator = new HeatResourceValidator();
NovaServerGroupResourceValidator resourceValidator = new NovaServerGroupResourceValidator();
-
+ private static final String PATH = "/org/openecomp/validation/validators/heat_validator/";
@Test
public void testPolicyIsAffinityOrAntiAffinity() throws IOException {
Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
- resourceValidator, HeatResourcesTypes.NOVA_SERVER_GROUP_RESOURCE_TYPE.getHeatResource(),
- "/org/openecomp/validation/validators/heat_validator/policy_is_affinity_or_anti_affinity/negative_test/input");
+ resourceValidator, HeatResourcesTypes.NOVA_SERVER_GROUP_RESOURCE_TYPE.getHeatResource(),
+ PATH + "policy_is_affinity_or_anti_affinity/negative_test/input");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
Assert.assertEquals(messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().size(), 1);
Assert.assertEquals(
- messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
- "ERROR: Wrong policy in server group - pcrf_server_policies_1");
+ messages.get("hot-nimbus-psm_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
+ "ERROR: [HNG1]: Wrong policy in server group - pcrf_server_policies_1");
}
@Test
public void testServerGroupCalledByServer() throws IOException {
- Map<String, MessageContainer> messages =ValidationTestUtil.testValidator(baseValidator,
- resourceValidator, HeatResourcesTypes.NOVA_SERVER_GROUP_RESOURCE_TYPE.getHeatResource(),
- "/org/openecomp/validation/validators/heat_validator/server_group_called_by_nova_server/input");
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, HeatResourcesTypes.NOVA_SERVER_GROUP_RESOURCE_TYPE.getHeatResource(),
+ PATH + "server_group_called_by_nova_server/input");
+
+ Assert.assertNotNull(messages);
+ Assert.assertEquals(messages.size(), 1);
+
+ Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 1);
+ Assert.assertEquals(
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: [HNG3]: ServerGroup not in use, Resource Id [not_used_server_group]");
+
+ }
+
+ @Test
+ public void testNonServerGroup() throws IOException {
+ Map<String, MessageContainer> messages = ValidationTestUtil.testValidator(baseValidator,
+ resourceValidator, HeatResourcesTypes.NOVA_SERVER_RESOURCE_TYPE.getHeatResource(),
+ PATH + "server_group_called_by_nova_server_negative/input");
Assert.assertNotNull(messages);
Assert.assertEquals(messages.size(), 1);
Assert.assertEquals(messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().size(), 1);
Assert.assertEquals(
- messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
- "WARNING: ServerGroup not in use, Resource Id [not_used_server_group]");
+ messages.get("hot-nimbus-pps_v1.0.yaml").getErrorMessageList().get(0).getMessage(),
+ "WARNING: [HNG2]: ServerGroup not in use, Resource Id [nova_server]");
}
}
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/server_group_called_by_nova_server_negative/input/MANIFEST.json b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/server_group_called_by_nova_server_negative/input/MANIFEST.json
new file mode 100644
index 0000000000..1e719efb31
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/server_group_called_by_nova_server_negative/input/MANIFEST.json
@@ -0,0 +1,17 @@
+{
+ "name": "hot-mog",
+ "description": "HOT template to create hot mog server",
+ "version": "2013-05-23",
+ "data": [
+ {
+ "file": "hot-nimbus-pps_v1.0.yaml",
+ "type": "HEAT",
+ "data": [
+ {
+ "file": "hot-nimbus-pps_v1.0.env",
+ "type": "HEAT_ENV"
+ }
+ ]
+ }
+ ]
+} \ No newline at end of file
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/server_group_called_by_nova_server_negative/input/hot-nimbus-pps_v1.0.env b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/server_group_called_by_nova_server_negative/input/hot-nimbus-pps_v1.0.env
new file mode 100644
index 0000000000..340be2b815
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/server_group_called_by_nova_server_negative/input/hot-nimbus-pps_v1.0.env
@@ -0,0 +1,11 @@
+parameters:
+ pcrf_pps_server_names: ZRDM1PCRF01PPS001,ZRDM1PCRF01PPS002,ZRDM1PCRF01PPS003,ZRDM1PCRF01PPS004,ZRDM1PCRF01PPS005,ZRDM1PCRF01PPS006
+ pcrf_pps_image_name: PCRF_8.995-ATTM1.0.3.qcow2
+ pcrf_pps_flavor_name: lc.3xlarge
+ availabilityzone_name: nova
+ pcrf_cps_net_name: Mobisupport-25193-I-INT1_int_pcrf_net_0
+ pcrf_cps_net_ips: 172.26.16.7,172.26.16.8,172.26.16.9,172.26.16.10,172.26.16.11,172.26.16.12
+ pcrf_cps_net_mask: 255.255.255.0
+ pcrf_security_group_name: nimbus_security_group
+ pcrf_vnf_id: 730797234b4a40aa99335157b02871cd
+
diff --git a/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/server_group_called_by_nova_server_negative/input/hot-nimbus-pps_v1.0.yaml b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/server_group_called_by_nova_server_negative/input/hot-nimbus-pps_v1.0.yaml
new file mode 100644
index 0000000000..ff83b01a44
--- /dev/null
+++ b/openecomp-be/lib/openecomp-sdc-validation-lib/openecomp-sdc-validation-impl/src/test/resources/org/openecomp/validation/validators/heat_validator/server_group_called_by_nova_server_negative/input/hot-nimbus-pps_v1.0.yaml
@@ -0,0 +1,55 @@
+heat_template_version: 2013-05-23
+
+description: heat template that creates PCRF Policy Server stack
+
+parameters:
+ pcrf_pps_server_names:
+ type: comma_delimited_list
+ label: PCRF PS server names
+ description: PCRF PS server names
+ pcrf_pps_image_name:
+ type: string
+ label: PCRF PS image name
+ description: PCRF PS image name
+ pcrf_pps_flavor_name:
+ type: string
+ label: PCRF PS flavor name
+ description: flavor name of PCRF PS instance
+ availabilityzone_name:
+ type: string
+ label: availabilityzone name
+ description: availabilityzone name
+ pcrf_cps_net_name:
+ type: string
+ label: CPS network name
+ description: CPS network name
+ pcrf_cps_net_ips:
+ type: comma_delimited_list
+ label: CPS network ips
+ description: CPS network ips
+ pcrf_cps_net_mask:
+ type: string
+ label: CPS network mask
+ description: CPS network mask
+ pcrf_security_group_name:
+ type: string
+ label: security group name
+ description: the name of security group
+ pcrf_vnf_id:
+ type: string
+ label: PCRF VNF Id
+ description: PCRF VNF Id
+ image_name:
+ type: string
+ label: PCRF VNF Id
+ description: PCRF VNF Id
+
+resources:
+ nova_server:
+ type: OS::Nova::Server
+ properties:
+ scheduler_hints: { group: { get_resource: used_server_group } }
+ image: {get_param: image_name}
+
+
+