diff options
Diffstat (limited to 'controlloop/common/eventmanager/src')
4 files changed, 129 insertions, 24 deletions
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java index 6afb08d76..be22e76bb 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java @@ -20,11 +20,14 @@ package org.onap.policy.controlloop.eventmanager; +import static org.onap.policy.controlloop.ControlLoopTargetType.PNF; +import static org.onap.policy.controlloop.ControlLoopTargetType.VM; +import static org.onap.policy.controlloop.ControlLoopTargetType.VNF; + import java.io.Serializable; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -36,6 +39,7 @@ import java.util.NoSuchElementException; import java.util.Set; import java.util.UUID; import java.util.stream.Collectors; +import java.util.stream.Stream; import org.apache.commons.lang3.StringUtils; import org.onap.policy.aai.AaiCqResponse; import org.onap.policy.aai.AaiGetVnfResponse; @@ -78,8 +82,11 @@ public class ControlLoopEventManager implements Serializable { public static final String VSERVER_VSERVER_NAME = "vserver.vserver-name"; public static final String GENERIC_VNF_IS_CLOSED_LOOP_DISABLED = "generic-vnf.is-closed-loop-disabled"; public static final String VSERVER_IS_CLOSED_LOOP_DISABLED = "vserver.is-closed-loop-disabled"; + private static final String PNF_IS_IN_MAINT = "pnf.in-maint"; public static final String GENERIC_VNF_PROV_STATUS = "generic-vnf.prov-status"; public static final String VSERVER_PROV_STATUS = "vserver.prov-status"; + public static final String PNF_ID = "pnf.pnf-id"; + public static final String PNF_NAME = "pnf.pnf-name"; public static final String AAI_URL = "aai.url"; public static final String AAI_USERNAME_PROPERTY = "aai.username"; @@ -101,9 +108,8 @@ public class ControlLoopEventManager implements Serializable { static { VALID_TARGETS = Collections.unmodifiableSet(new HashSet<>( - Arrays.asList(VM_NAME, VNF_NAME, VSERVER_VSERVER_NAME, - GENERIC_VNF_VNF_ID, GENERIC_VNF_VNF_NAME) - .stream().map(String::toLowerCase).collect(Collectors.toList()))); + Stream.of(VM_NAME, VNF_NAME, VSERVER_VSERVER_NAME, GENERIC_VNF_VNF_ID, GENERIC_VNF_VNF_NAME, PNF_NAME) + .map(String::toLowerCase).collect(Collectors.toList()))); } public final String closedLoopControlName; @@ -733,13 +739,26 @@ public class ControlLoopEventManager implements Serializable { } private void validateAaiData(VirtualControlLoopEvent event) throws ControlLoopException { - if (event.getAai() == null) { + Map<String, String> eventAai = event.getAai(); + if (eventAai == null) { throw new ControlLoopException("AAI is null"); } - if (event.getAai().get(GENERIC_VNF_VNF_ID) == null && event.getAai().get(VSERVER_VSERVER_NAME) == null - && event.getAai().get(GENERIC_VNF_VNF_NAME) == null) { - throw new ControlLoopException( - "generic-vnf.vnf-id or generic-vnf.vnf-name or vserver.vserver-name information missing"); + switch (event.getTargetType()) { + case VM: + case VNF: + if (eventAai.get(GENERIC_VNF_VNF_ID) == null && eventAai.get(VSERVER_VSERVER_NAME) == null + && eventAai.get(GENERIC_VNF_VNF_NAME) == null) { + throw new ControlLoopException( + "generic-vnf.vnf-id or generic-vnf.vnf-name or vserver.vserver-name information missing"); + } + return; + case PNF: + if (eventAai.get(PNF_NAME) == null) { + throw new ControlLoopException("AAI PNF object key pnf-name is missing"); + } + return; + default: + throw new ControlLoopException("The target type is not supported"); } } @@ -753,14 +772,16 @@ public class ControlLoopEventManager implements Serializable { Map<String, String> aai = event.getAai(); - if (aai.containsKey(VSERVER_IS_CLOSED_LOOP_DISABLED) || aai.containsKey(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED)) { + if (aai.containsKey(VSERVER_IS_CLOSED_LOOP_DISABLED) || aai.containsKey(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED) + || aai.containsKey(PNF_IS_IN_MAINT)) { if (isClosedLoopDisabled(event)) { - throw new AaiException("is-closed-loop-disabled is set to true on VServer or VNF"); + throw new AaiException( + "is-closed-loop-disabled is set to true on VServer or VNF or in-maint is set to true for PNF"); } if (isProvStatusInactive(event)) { - throw new AaiException("prov-status is not ACTIVE on VServer or VNF"); + throw new AaiException("prov-status is not ACTIVE on VServer or VNF or PNF"); } // no need to query, as we already have the data @@ -854,7 +875,8 @@ public class ControlLoopEventManager implements Serializable { public static boolean isClosedLoopDisabled(VirtualControlLoopEvent event) { Map<String, String> aai = event.getAai(); return (isAaiTrue(aai.get(VSERVER_IS_CLOSED_LOOP_DISABLED)) - || isAaiTrue(aai.get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED))); + || isAaiTrue(aai.get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED)) + || isAaiTrue(aai.get(PNF_IS_IN_MAINT))); } /** @@ -1091,6 +1113,34 @@ public class ControlLoopEventManager implements Serializable { } + /** + * Get the specified pnf data from aai. + * @param event the event containing pnf id. + * @return pnf key value data. + * @throws AaiException if an aai error occurs. + */ + public Map<String, String> getPnf(VirtualControlLoopEvent event) throws AaiException { + Map<String, String> aai = event.getAai(); + + if (!aai.containsKey(PNF_NAME)) { + throw new AaiException("Missing unique identifier for PNF AAI object in the event."); + } + + UUID reqId = event.getRequestId(); + String pnfName = event.getAai().get(PNF_NAME); + String aaiHostUrl = PolicyEngineConstants.getManager().getEnvironmentProperty(AAI_URL); + String aaiUser = PolicyEngineConstants.getManager().getEnvironmentProperty(AAI_USERNAME_PROPERTY); + String aaiPassword = PolicyEngineConstants.getManager().getEnvironmentProperty(AAI_PASS_PROPERTY); + + Map<String, String> pnfParams = + new AaiManager(new RestManager()).getPnf(aaiHostUrl, aaiUser, aaiPassword, reqId, pnfName); + + if (pnfParams == null) { + throw new AaiException("Aai response is undefined"); + } + return pnfParams; + } + // the following methods may be overridden by junit tests diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java index 87e76c34f..570274149 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java @@ -37,6 +37,7 @@ import java.util.Properties; import javax.persistence.EntityManager; import javax.persistence.Persistence; +import org.apache.commons.lang3.StringUtils; import org.eclipse.persistence.config.PersistenceUnitProperties; import org.onap.aai.domain.yang.GenericVnf; import org.onap.aai.domain.yang.ServiceInstance; @@ -85,6 +86,7 @@ public class ControlLoopOperationManager implements Serializable { private static final String GENERIC_VNF_VNF_ID = "generic-vnf.vnf-id"; private static final String AAI_SERVICE_INSTANCE_ID_KEY = "service-instance.service-instance-id"; + private static final String PNF_NAME = "pnf.pnf-name"; // // These properties are not changeable, but accessible @@ -123,9 +125,13 @@ public class ControlLoopOperationManager implements Serializable { this.eventManager = em; try { - - if (Boolean.valueOf(PolicyEngineConstants.getManager().getEnvironmentProperty(AAI_CUSTOM_QUERY))) { - this.aaiCqResponse = this.eventManager.getCqResponse((VirtualControlLoopEvent) onset); + if (TargetType.VNF.equals(policy.getTarget().getType()) + || TargetType.VFMODULE.equals(policy.getTarget().getType())) { + String aaiCqEnvProp = + PolicyEngineConstants.getManager().getEnvironmentProperty(AAI_CUSTOM_QUERY); + if (StringUtils.isBlank(aaiCqEnvProp) || Boolean.valueOf(aaiCqEnvProp)) { + this.aaiCqResponse = this.eventManager.getCqResponse((VirtualControlLoopEvent) onset); + } } this.targetEntity = getTarget(policy); @@ -250,7 +256,7 @@ public class ControlLoopOperationManager implements Serializable { switch (policy.getTarget().getType()) { case PNF: - throw new ControlLoopException("PNF target is not supported"); + return getPnfTarget(); case VM: case VNF: return getVfModuleTarget(); @@ -299,6 +305,15 @@ public class ControlLoopOperationManager implements Serializable { throw new ControlLoopException("Target does not match target type"); } + private String getPnfTarget() throws ControlLoopException { + VirtualControlLoopEvent virtualOnsetEvent = (VirtualControlLoopEvent) this.onset; + if (!PNF_NAME.equalsIgnoreCase(onset.getTarget())) { + throw new ControlLoopException( + "Target in the onset event is either null or does not match target key expected in AAI section."); + } + return virtualOnsetEvent.getAai().get(PNF_NAME); + } + /** * Start an operation. * @@ -485,7 +500,8 @@ public class ControlLoopOperationManager implements Serializable { result.put(AAI_SERVICE_INSTANCE_ID_KEY, serviceInstance.getServiceInstanceId()); result.put(GENERIC_VNF_VNF_ID, genericVnf.getVnfId()); } - + } else if (TargetType.PNF.equals(policy.getTarget().getType())) { + result = this.eventManager.getPnf((VirtualControlLoopEvent) onset); } return result; diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java index 8efdb1fcb..c9202904c 100644 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java @@ -66,6 +66,7 @@ import org.onap.policy.common.utils.io.Serializer; import org.onap.policy.controlloop.ControlLoopEventStatus; import org.onap.policy.controlloop.ControlLoopException; import org.onap.policy.controlloop.ControlLoopNotificationType; +import org.onap.policy.controlloop.ControlLoopTargetType; import org.onap.policy.controlloop.SupportUtil; import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.controlloop.VirtualControlLoopNotification; @@ -126,6 +127,7 @@ public class ControlLoopEventManagerTest { PolicyEngineConstants.getManager().setEnvironmentProperty(AAI_USERNAME, "AAI"); PolicyEngineConstants.getManager().setEnvironmentProperty(AAI_PASS, "AAI"); PolicyEngineConstants.getManager().setEnvironmentProperty(AAI_URL, "http://localhost:6666"); + PolicyEngineConstants.getManager().setEnvironmentProperty("aai.customQuery", "false"); } @AfterClass @@ -145,11 +147,12 @@ public class ControlLoopEventManagerTest { onset.setRequestId(UUID.randomUUID()); onset.setTarget("VM_NAME"); onset.setClosedLoopAlarmStart(Instant.now()); - onset.setAai(new HashMap<String, String>()); + onset.setAai(new HashMap<>()); onset.getAai().put("cloud-region.identity-url", "foo"); onset.getAai().put("vserver.selflink", "bar"); onset.getAai().put(VNF_ID, VNF_UUID); onset.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); + onset.setTargetType(ControlLoopTargetType.VNF); PolicyEngineConstants.getManager().setEnvironmentProperty(AAI_URL, "http://localhost:6666"); } @@ -212,6 +215,7 @@ public class ControlLoopEventManagerTest { event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); event.setAai(new HashMap<>()); event.getAai().put(VNF_NAME, ONSET_ONE); + event.setTargetType(ControlLoopTargetType.VNF); ControlLoopEventManager manager = makeManager(event); VirtualControlLoopNotification notification = manager.activate(event); @@ -236,6 +240,7 @@ public class ControlLoopEventManagerTest { event2.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); event2.setAai(new HashMap<>()); event2.getAai().put(VNF_NAME, "onsetTwo"); + event2.setTargetType(ControlLoopTargetType.VNF); status = manager.onNewEvent(event2); @@ -440,6 +445,7 @@ public class ControlLoopEventManagerTest { event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); event.setAai(new HashMap<>()); event.getAai().put(VNF_NAME, ONSET_ONE); + event.setTargetType(ControlLoopTargetType.VNF); ControlLoopEventManager manager = makeManager(event); manager.setActivated(true); @@ -459,6 +465,7 @@ public class ControlLoopEventManagerTest { event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); event.setAai(new HashMap<>()); event.getAai().put(VNF_NAME, ONSET_ONE); + event.setTargetType(ControlLoopTargetType.VNF); ControlLoopEventManager manager = makeManager(event); @@ -505,6 +512,7 @@ public class ControlLoopEventManagerTest { event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); event.setAai(new HashMap<>()); event.getAai().put(VNF_NAME, ONSET_ONE); + event.setTargetType(ControlLoopTargetType.VNF); ControlLoopEventManager manager = makeManager(event); ControlLoopEventManager manager2 = manager; @@ -572,6 +580,8 @@ public class ControlLoopEventManagerTest { event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); event.setAai(new HashMap<>()); event.getAai().put(VNF_NAME, ONSET_ONE); + event.getAai().put(VSERVER_NAME, "test-vserver"); + event.setTargetType(ControlLoopTargetType.VNF); ControlLoopEventManager manager = makeManager(event); ControlLoopEventManager manager2 = manager; @@ -781,6 +791,7 @@ public class ControlLoopEventManagerTest { onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); onsetEvent.setAai(new HashMap<>()); onsetEvent.getAai().put(VNF_NAME, ONSET_ONE); + onsetEvent.setTargetType(ControlLoopTargetType.VNF); VirtualControlLoopEvent abatedEvent = new VirtualControlLoopEvent(); abatedEvent.setClosedLoopControlName(TWO_ONSET_TEST); @@ -846,6 +857,9 @@ public class ControlLoopEventManagerTest { checkSyntaxEvent.setAai(new HashMap<>()); assertEquals(NewEventStatus.SYNTAX_ERROR, manager.onNewEvent(checkSyntaxEvent)); + checkSyntaxEvent.setTargetType(""); + assertEquals(NewEventStatus.SYNTAX_ERROR, manager.onNewEvent(checkSyntaxEvent)); + checkSyntaxEvent.setTarget(""); assertEquals(NewEventStatus.SYNTAX_ERROR, manager.onNewEvent(checkSyntaxEvent)); @@ -900,6 +914,7 @@ public class ControlLoopEventManagerTest { onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); onsetEvent.setAai(new HashMap<>()); onsetEvent.getAai().put(VNF_NAME, ONSET_ONE); + onsetEvent.setTargetType(ControlLoopTargetType.VNF); ControlLoopEventManager manager = makeManager(onsetEvent); assertTrue(0 == manager.getControlLoopTimeout(null)); @@ -926,6 +941,7 @@ public class ControlLoopEventManagerTest { onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); onsetEvent.setAai(new HashMap<>()); onsetEvent.getAai().put(VNF_NAME, ONSET_ONE); + onsetEvent.setTargetType(ControlLoopTargetType.VNF); ControlLoopEventManager manager = makeManager(onsetEvent); @@ -951,6 +967,7 @@ public class ControlLoopEventManagerTest { onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); onsetEvent.setAai(new HashMap<>()); onsetEvent.getAai().put(VNF_NAME, ONSET_ONE); + onsetEvent.setTargetType(ControlLoopTargetType.VNF); ControlLoopEventManager manager = makeManager(onsetEvent); @@ -972,8 +989,8 @@ public class ControlLoopEventManagerTest { ControlLoopEventManager mgr = makeManager(onset); - assertThatThrownBy(() -> mgr.queryAai(onset)).isInstanceOf(AaiException.class) - .hasMessage("is-closed-loop-disabled is set to true on VServer or VNF"); + assertThatThrownBy(() -> mgr.queryAai(onset)).isInstanceOf(AaiException.class).hasMessage( + "is-closed-loop-disabled is set to true on VServer or VNF or in-maint is set to true for PNF"); assertNull(mgr.getVnfResponse()); assertNull(mgr.getVserverResponse()); } @@ -986,7 +1003,7 @@ public class ControlLoopEventManagerTest { ControlLoopEventManager mgr = makeManager(onset); assertThatThrownBy(() -> mgr.queryAai(onset)).isInstanceOf(AaiException.class) - .hasMessage("prov-status is not ACTIVE on VServer or VNF"); + .hasMessage("prov-status is not ACTIVE on VServer or VNF or PNF"); assertNull(mgr.getVnfResponse()); assertNull(mgr.getVserverResponse()); } @@ -1343,6 +1360,8 @@ public class ControlLoopEventManagerTest { event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); event.setAai(new HashMap<>()); event.getAai().put(VNF_ID, ONSET_ONE); + event.getAai().put(VSERVER_NAME, "test-vserver"); + event.setTargetType(ControlLoopTargetType.VNF); return event; } diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java index 480bc290e..b3e2e2181 100644 --- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java +++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManagerTest.java @@ -64,6 +64,7 @@ import org.onap.policy.controlloop.ControlLoopTargetType; import org.onap.policy.controlloop.SupportUtil; import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.controlloop.VirtualControlLoopNotification; +import org.onap.policy.controlloop.policy.ControlLoop; import org.onap.policy.controlloop.policy.ControlLoopPolicy; import org.onap.policy.controlloop.policy.Policy; import org.onap.policy.controlloop.policy.PolicyResult; @@ -108,12 +109,15 @@ public class ControlLoopOperationManagerTest { onset.setClosedLoopAlarmStart(Instant.now()); onset.setAai(new HashMap<>()); onset.getAai().put(VNF_NAME, "testTriggerSource"); + onset.getAai().put(VSERVER_NAME, "testVserverName"); onset.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); + onset.setTargetType(ControlLoopTargetType.VNF); /* Set environment properties */ PolicyEngineConstants.getManager().setEnvironmentProperty("aai.url", "http://localhost:6666"); PolicyEngineConstants.getManager().setEnvironmentProperty("aai.username", "AAI"); PolicyEngineConstants.getManager().setEnvironmentProperty("aai.password", "AAI"); + PolicyEngineConstants.getManager().setEnvironmentProperty("aai.customQuery", "false"); } private static EntityManagerFactory emf; @@ -390,10 +394,12 @@ public class ControlLoopOperationManagerTest { onsetEvent.setClosedLoopControlName(TWO_ONSET_TEST); onsetEvent.setRequestId(requestId); onsetEvent.setTarget(VNF_ID); + onsetEvent.setTargetType(ControlLoopTargetType.VNF); onsetEvent.setClosedLoopAlarmStart(Instant.now()); onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); onsetEvent.setAai(new HashMap<>()); onsetEvent.getAai().put(VNF_NAME, ONSET_ONE); + onsetEvent.getAai().put(VSERVER_NAME, "testVserverName"); ControlLoopEventManager manager = new ControlLoopEventManager(onsetEvent.getClosedLoopControlName(), onsetEvent.getRequestId()); @@ -428,7 +434,8 @@ public class ControlLoopOperationManagerTest { policy.setTarget(savedTarget); policy.getTarget().setType(TargetType.PNF); - assertThatThrownBy(() -> clom.getTarget(policy)).hasMessage("PNF target is not supported"); + assertThatThrownBy(() -> clom.getTarget(policy)).hasMessage( + "Target in the onset event is either null or does not match target key expected in AAI section."); onsetEvent.setTarget("Oz"); onsetEvent.getAai().remove(VNF_NAME); @@ -495,10 +502,12 @@ public class ControlLoopOperationManagerTest { onsetEvent.setClosedLoopControlName(TWO_ONSET_TEST); onsetEvent.setRequestId(requestId); onsetEvent.setTarget(VNF_ID); + onsetEvent.setTargetType(ControlLoopTargetType.VNF); onsetEvent.setClosedLoopAlarmStart(Instant.now()); onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); onsetEvent.setAai(new HashMap<>()); onsetEvent.getAai().put(VNF_NAME, ONSET_ONE); + onsetEvent.getAai().put(VSERVER_NAME, "testVserverName"); ControlLoopEventManager manager = new ControlLoopEventManager(onsetEvent.getClosedLoopControlName(), onsetEvent.getRequestId()); @@ -543,10 +552,12 @@ public class ControlLoopOperationManagerTest { onsetEvent.setClosedLoopControlName(TWO_ONSET_TEST); onsetEvent.setRequestId(requestId); onsetEvent.setTarget(VNF_ID); + onsetEvent.setTargetType(ControlLoopTargetType.VNF); onsetEvent.setClosedLoopAlarmStart(Instant.now()); onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); onsetEvent.setAai(new HashMap<>()); onsetEvent.getAai().put(VNF_NAME, ONSET_ONE); + onsetEvent.getAai().put(VSERVER_NAME, "testVserverName"); ControlLoopEventManager manager = new ControlLoopEventManager(onsetEvent.getClosedLoopControlName(), onsetEvent.getRequestId()); @@ -631,10 +642,12 @@ public class ControlLoopOperationManagerTest { onsetEvent.setClosedLoopControlName(TWO_ONSET_TEST); onsetEvent.setRequestId(requestId); onsetEvent.setTarget(VNF_ID); + onsetEvent.setTargetType(ControlLoopTargetType.VNF); onsetEvent.setClosedLoopAlarmStart(Instant.now()); onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); onsetEvent.setAai(new HashMap<>()); onsetEvent.getAai().put(VNF_NAME, ONSET_ONE); + onsetEvent.getAai().put(VSERVER_NAME, "testVserverName"); ControlLoopEventManager manager = new ControlLoopEventManager(onsetEvent.getClosedLoopControlName(), onsetEvent.getRequestId()); @@ -726,10 +739,12 @@ public class ControlLoopOperationManagerTest { onsetEvent.setClosedLoopControlName(TWO_ONSET_TEST); onsetEvent.setRequestId(requestId); onsetEvent.setTarget(VNF_ID); + onsetEvent.setTargetType(ControlLoopTargetType.VNF); onsetEvent.setClosedLoopAlarmStart(Instant.now()); onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); onsetEvent.setAai(new HashMap<>()); onsetEvent.getAai().put(VNF_NAME, ONSET_ONE); + onsetEvent.getAai().put(VSERVER_NAME, "testVserverName"); ControlLoopEventManager manager = new ControlLoopEventManager(onsetEvent.getClosedLoopControlName(), onsetEvent.getRequestId()); @@ -772,6 +787,7 @@ public class ControlLoopOperationManagerTest { event.setClosedLoopControlName(TWO_ONSET_TEST); event.setRequestId(requestId); event.setTarget(VNF_ID); + event.setTargetType(ControlLoopTargetType.VNF); event.setClosedLoopAlarmStart(Instant.now()); event.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); event.setAai(new HashMap<>()); @@ -801,7 +817,7 @@ public class ControlLoopOperationManagerTest { @Test public void testCommitAbatement() throws Exception { - String yamlString = null; + String yamlString; try (InputStream is = new FileInputStream(new File(TEST_YAML))) { yamlString = IOUtils.toString(is, StandardCharsets.UTF_8); } @@ -811,10 +827,12 @@ public class ControlLoopOperationManagerTest { onsetEvent.setClosedLoopControlName(TWO_ONSET_TEST); onsetEvent.setRequestId(requestId); onsetEvent.setTarget(VNF_ID); + onsetEvent.setTargetType(ControlLoopTargetType.VNF); onsetEvent.setClosedLoopAlarmStart(Instant.now()); onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); onsetEvent.setAai(new HashMap<>()); onsetEvent.getAai().put(VNF_NAME, ONSET_ONE); + onsetEvent.getAai().put(VSERVER_NAME, "testVserverName"); ControlLoopEventManager manager = new ControlLoopEventManager(onsetEvent.getClosedLoopControlName(), onsetEvent.getRequestId()); @@ -850,10 +868,12 @@ public class ControlLoopOperationManagerTest { onsetEvent.setClosedLoopControlName(TWO_ONSET_TEST); onsetEvent.setRequestId(requestId); onsetEvent.setTarget(VNF_ID); + onsetEvent.setTargetType(ControlLoopTargetType.VNF); onsetEvent.setClosedLoopAlarmStart(Instant.now()); onsetEvent.setClosedLoopEventStatus(ControlLoopEventStatus.ONSET); onsetEvent.setAai(new HashMap<>()); onsetEvent.getAai().put(VNF_NAME, ONSET_ONE); + onsetEvent.getAai().put(VSERVER_NAME, "testVserverName"); ControlLoopEventManager manager = new ControlLoopEventManager(onsetEvent.getClosedLoopControlName(), onsetEvent.getRequestId()); |