From 1480d327ff8559c1d912108f7d3353fed03fcd2c Mon Sep 17 00:00:00 2001 From: daniel Date: Tue, 24 Oct 2017 06:33:31 -0500 Subject: Change vnf-id to vnf-name These changes now allow a lookup of the source vnf-id based on the onset's vnf-name. Issue-Id: POLICY-366 Change-Id: I6f6bd500b892dddbbb9e12156b4486208309e21d Signed-off-by: Daniel Cruz --- .../actor/appc/APPCActorServiceProvider.java | 30 +++++----- .../actor/appc/AppcServiceProviderTest.java | 12 +++- controlloop/common/actors/actor.appclcm/pom.xml | 6 ++ .../actor/appclcm/AppcLcmActorServiceProvider.java | 28 +++++++-- .../actor/appclcm/AppcLcmServiceProviderTest.java | 67 ++++++++++++++++++++-- controlloop/common/eventmanager/pom.xml | 6 ++ .../eventmanager/ControlLoopOperationManager.java | 6 +- .../ControlLoopOperationManagerTest.java | 44 ++++++++++++-- .../onap/policy/simulators/AaiSimulatorJaxRs.java | 6 +- .../policy/template/demo/VCPEControlLoopTest.java | 12 ++-- .../policy/template/demo/VFWControlLoopTest.java | 14 ++--- 11 files changed, 182 insertions(+), 49 deletions(-) (limited to 'controlloop') diff --git a/controlloop/common/actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/APPCActorServiceProvider.java b/controlloop/common/actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/APPCActorServiceProvider.java index 6ae62bbcd..44411ca72 100644 --- a/controlloop/common/actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/APPCActorServiceProvider.java +++ b/controlloop/common/actors/actor.appc/src/main/java/org/onap/policy/controlloop/actor/appc/APPCActorServiceProvider.java @@ -25,6 +25,7 @@ import java.util.List; import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.controlloop.actor.appclcm.AppcLcmActorServiceProvider; +import org.onap.policy.aai.AAIGETVnfResponse; import org.onap.policy.aai.util.AAIException; import org.onap.policy.appc.CommonHeader; import org.onap.policy.appc.Request; @@ -89,7 +90,8 @@ public class APPCActorServiceProvider implements Actor { * @return an APPC request conforming to the legacy API * @throws AAIException */ - public static Request constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation, Policy policy) throws AAIException { + public static Request constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation, + Policy policy, AAIGETVnfResponse vnfResponse) throws AAIException { /* * Construct an APPC request */ @@ -105,24 +107,24 @@ public class APPCActorServiceProvider implements Actor { * specified in the yaml, the target vnf-id is retrieved by * a named query to A&AI. */ - String vnfId; - if (onset.AAI.get("generic-vnf.vnf-id").equalsIgnoreCase(policy.getTarget().getResourceID())) { - vnfId = onset.AAI.get("generic-vnf.vnf-id"); + String sourceVnf = onset.AAI.get("generic-vnf.vnf-id"); + if (sourceVnf == null) { + /* + * Lets see if the vnf-name is provided + */ + sourceVnf = vnfResponse.vnfID; + if (sourceVnf == null) { + throw new AAIException("No vnf-id found"); + } } - else { - vnfId = AppcLcmActorServiceProvider.vnfNamedQuery( - policy.getTarget().getResourceID(), onset.AAI.get("generic-vnf.vnf-id")); - } - - if (vnfId == null) { - throw new AAIException("No vnf id found"); - } - + String targetVnf = AppcLcmActorServiceProvider.vnfNamedQuery( + policy.getTarget().getResourceID(), sourceVnf); + /* * For now Policy generates the PG Streams as a demo, in the * future the payload can be provided by CLAMP */ - request.Payload.put("generic-vnf.vnf-id", vnfId); + request.Payload.put("generic-vnf.vnf-id", targetVnf); PGRequest pgRequest = new PGRequest(); pgRequest.pgStreams = new PGStreams(); diff --git a/controlloop/common/actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java b/controlloop/common/actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java index 7ab368f6f..5a107f814 100644 --- a/controlloop/common/actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java +++ b/controlloop/common/actors/actor.appc/src/test/java/org/onap/policy/controlloop/actor/appc/AppcServiceProviderTest.java @@ -29,6 +29,7 @@ import java.util.UUID; import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; +import org.onap.policy.aai.AAIGETVnfResponse; import org.onap.policy.aai.util.AAIException; import org.onap.policy.appc.Request; import org.onap.policy.appc.Response; @@ -54,6 +55,7 @@ public class AppcServiceProviderTest { private static VirtualControlLoopEvent onsetEvent; private static ControlLoopOperation operation; private static Policy policy; + private static AAIGETVnfResponse aaiResponse; static { /* @@ -65,11 +67,11 @@ public class AppcServiceProviderTest { onsetEvent.requestID = UUID.randomUUID(); onsetEvent.closedLoopEventClient = "tca.instance00001"; onsetEvent.target_type = ControlLoopTargetType.VNF; - onsetEvent.target = "generic-vnf.vnf-id"; + onsetEvent.target = "generic-vnf.vnf-name"; onsetEvent.from = "DCAE"; onsetEvent.closedLoopAlarmStart = Instant.now(); onsetEvent.AAI = new HashMap<>(); - onsetEvent.AAI.put("generic-vnf.vnf-id", "fw0001vm001fw001"); + onsetEvent.AAI.put("generic-vnf.vnf-name", "fw0001vm001fw001"); onsetEvent.closedLoopEventStatus = ControlLoopEventStatus.ONSET; /* Construct an operation with an APPC actor and ModifyConfig operation. */ @@ -92,6 +94,10 @@ public class AppcServiceProviderTest { policy.setRetry(2); policy.setTimeout(300); + /* Construct a mock A&AI response */ + aaiResponse = new AAIGETVnfResponse(); + aaiResponse.vnfID = "vnf01"; + /* Set environment properties */ PolicyEngine.manager.setEnvironmentProperty("aai.url", "http://localhost:6666"); PolicyEngine.manager.setEnvironmentProperty("aai.username", "AAI"); @@ -118,7 +124,7 @@ public class AppcServiceProviderTest { Request appcRequest = null; try { - appcRequest = APPCActorServiceProvider.constructRequest(onsetEvent, operation, policy); + appcRequest = APPCActorServiceProvider.constructRequest(onsetEvent, operation, policy, aaiResponse); } catch (AAIException e) { logger.warn(e.toString()); fail("no vnfid found"); diff --git a/controlloop/common/actors/actor.appclcm/pom.xml b/controlloop/common/actors/actor.appclcm/pom.xml index 1120df33a..481b21a7c 100644 --- a/controlloop/common/actors/actor.appclcm/pom.xml +++ b/controlloop/common/actors/actor.appclcm/pom.xml @@ -46,6 +46,12 @@ 1.1.0-SNAPSHOT provided + + org.onap.policy.drools-applications + simulators + 1.1.0-SNAPSHOT + test + junit junit diff --git a/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java b/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java index 4ff1c1d2c..1c7ee9089 100644 --- a/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java +++ b/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java @@ -33,11 +33,13 @@ import java.util.UUID; import org.onap.policy.aai.AAINQInstanceFilters; import org.onap.policy.aai.AAINQInventoryResponseItem; +import org.onap.policy.aai.AAIGETVnfResponse; import org.onap.policy.aai.AAIManager; import org.onap.policy.aai.AAINQNamedQuery; import org.onap.policy.aai.AAINQQueryParameters; import org.onap.policy.aai.AAINQRequest; import org.onap.policy.aai.AAINQResponse; +import org.onap.policy.aai.util.AAIException; import org.onap.policy.appclcm.LCMCommonHeader; import org.onap.policy.appclcm.LCMRequest; import org.onap.policy.appclcm.LCMRequestWrapper; @@ -138,8 +140,9 @@ public class AppcLcmActorServiceProvider implements Actor { * the vnf id of the source entity reporting the alert * * @return the target entities vnf id to act upon + * @throws AAIException */ - public static String vnfNamedQuery(String resourceId, String sourceVnfId) { + public static String vnfNamedQuery(String resourceId, String sourceVnfId) throws AAIException { //TODO: This request id should not be hard coded in future releases UUID requestId = UUID.fromString("a93ac487-409c-4e8c-9e5f-334ae8f99087"); @@ -170,9 +173,15 @@ public class AppcLcmActorServiceProvider implements Actor { aaiUrl, aaiUsername, aaiPassword, aaiRequest, requestId); + + if (aaiResponse == null) { + throw new AAIException("The named query response was null"); + } - //TODO: What if the resourceId never matches? String targetVnfId = parseAAIResponse(aaiResponse.inventoryResponseItems, resourceId); + if (targetVnfId == null) { + throw new AAIException("Target vnf-id could not be found"); + } return targetVnfId; } @@ -192,9 +201,10 @@ public class AppcLcmActorServiceProvider implements Actor { * the policy the was specified from the yaml generated * by CLAMP or through the Policy GUI/API * @return an APPC request conforming to the lcm API using the DMAAP wrapper + * @throws AAIException */ - public static LCMRequestWrapper constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation, - Policy policy) { + public static LCMRequestWrapper constructRequest(VirtualControlLoopEvent onset, + ControlLoopOperation operation, Policy policy, AAIGETVnfResponse vnfResponse) throws AAIException { /* Construct an APPC request using LCM Model */ @@ -225,7 +235,15 @@ public class AppcLcmActorServiceProvider implements Actor { * a vnf-id. */ HashMap requestActionIdentifiers = new HashMap<>(); - requestActionIdentifiers.put("vnf-id", onset.AAI.get(DCAE_VNF_ID)); + String vnfId = onset.AAI.get(DCAE_VNF_ID); + if (vnfId == null) { + vnfId = vnfResponse.vnfID; + if (vnfId == null) { + throw new AAIException("No vnf-id found"); + } + } + requestActionIdentifiers.put("vnf-id", vnfId); + appcRequest.setActionIdentifiers(requestActionIdentifiers); /* diff --git a/controlloop/common/actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmServiceProviderTest.java b/controlloop/common/actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmServiceProviderTest.java index 63ecd2ec9..7c0f1882a 100644 --- a/controlloop/common/actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmServiceProviderTest.java +++ b/controlloop/common/actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmServiceProviderTest.java @@ -27,7 +27,11 @@ import java.util.AbstractMap; import java.util.HashMap; import java.util.UUID; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.Test; +import org.onap.policy.aai.AAIGETVnfResponse; +import org.onap.policy.aai.util.AAIException; import org.onap.policy.appclcm.LCMCommonHeader; import org.onap.policy.appclcm.LCMRequest; import org.onap.policy.appclcm.LCMRequestWrapper; @@ -41,6 +45,9 @@ import org.onap.policy.controlloop.policy.Policy; import org.onap.policy.controlloop.policy.PolicyResult; import org.onap.policy.controlloop.policy.Target; import org.onap.policy.controlloop.policy.TargetType; +import org.onap.policy.drools.http.server.HttpServletServer; +import org.onap.policy.drools.system.PolicyEngine; +import org.onap.policy.simulators.Util; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -51,6 +58,7 @@ public class AppcLcmServiceProviderTest { private static VirtualControlLoopEvent onsetEvent; private static ControlLoopOperation operation; private static Policy policy; + private static AAIGETVnfResponse aaiResponse; private static LCMRequestWrapper dmaapRequest; private static LCMResponseWrapper dmaapResponse; @@ -64,11 +72,11 @@ public class AppcLcmServiceProviderTest { onsetEvent.requestID = UUID.randomUUID(); onsetEvent.closedLoopEventClient = "tca.instance00001"; onsetEvent.target_type = ControlLoopTargetType.VM; - onsetEvent.target = "generic-vnf.vnf-id"; + onsetEvent.target = "generic-vnf.vnf-name"; onsetEvent.from = "DCAE"; onsetEvent.closedLoopAlarmStart = Instant.now(); onsetEvent.AAI = new HashMap<>(); - onsetEvent.AAI.put("generic-vnf.vnf-id", "fw0001vm001fw001"); + onsetEvent.AAI.put("generic-vnf.vnf-name", "fw0001vm001fw001"); onsetEvent.closedLoopEventStatus = ControlLoopEventStatus.ONSET; /* Construct an operation with an APPC actor and restart operation. */ @@ -84,11 +92,15 @@ public class AppcLcmServiceProviderTest { policy.setName("Restart the VM"); policy.setDescription("Upon getting the trigger event, restart the VM"); policy.setActor("APPC"); - policy.setTarget(new Target(TargetType.VM)); + policy.setTarget(new Target(TargetType.VNF)); policy.setRecipe("Restart"); policy.setPayload(null); policy.setRetry(2); policy.setTimeout(300); + + /* Construct a mock A&AI response */ + aaiResponse = new AAIGETVnfResponse(); + aaiResponse.vnfID = "vnf01"; /* A sample DMAAP request wrapper. */ dmaapRequest = new LCMRequestWrapper(); @@ -101,7 +113,12 @@ public class AppcLcmServiceProviderTest { dmaapResponse.setCorrelationId(onsetEvent.requestID.toString() + "-" + "1"); dmaapResponse.setRpcName(policy.getRecipe().toLowerCase()); dmaapResponse.setType("response"); - + + /* Set environment properties */ + PolicyEngine.manager.setEnvironmentProperty("aai.url", "http://localhost:6666"); + PolicyEngine.manager.setEnvironmentProperty("aai.username", "AAI"); + PolicyEngine.manager.setEnvironmentProperty("aai.password", "AAI"); + /* A sample APPC LCM request. */ LCMRequest appcRequest = new LCMRequest(); @@ -132,13 +149,33 @@ public class AppcLcmServiceProviderTest { dmaapResponse.setBody(appcResponse); } + @BeforeClass + public static void setUpSimulator() { + try { + Util.buildAaiSim(); + } catch (Exception e) { + fail(e.getMessage()); + } + } + + @AfterClass + public static void tearDownSimulator() { + HttpServletServer.factory.destroy(); + } + /** * A test to construct an APPC LCM restart request. */ @Test public void constructRestartRequestTest() { - LCMRequestWrapper dmaapRequest = AppcLcmActorServiceProvider.constructRequest(onsetEvent, operation, policy); + LCMRequestWrapper dmaapRequest = null; + try { + dmaapRequest = AppcLcmActorServiceProvider.constructRequest(onsetEvent, operation, policy, aaiResponse); + } catch (AAIException e) { + logger.warn(e.toString()); + fail("no vnfid found"); + } /* The service provider must return a non null DMAAP request wrapper */ assertNotNull(dmaapRequest); @@ -162,6 +199,7 @@ public class AppcLcmServiceProviderTest { /* Action Identifiers are required and cannot be null */ assertNotNull(appcRequest.getActionIdentifiers()); assertNotNull(appcRequest.getActionIdentifiers().get("vnf-id")); + assertEquals(appcRequest.getActionIdentifiers().get("vnf-id"), "vnf01"); logger.debug("APPC Request: \n" + appcRequest.toString()); } @@ -267,5 +305,22 @@ public class AppcLcmServiceProviderTest { assertEquals(result.getKey(), PolicyResult.FAILURE_EXCEPTION); } - + /** + * This test ensures that that if the the source entity + * is also the target entity, the source will be used for + * the APPC request + */ + @Test + public void sourceIsTargetTest() { + String resourceId = "82194af1-3c2c-485a-8f44-420e22a9eaa4"; + String targetVnfId = null; + try { + targetVnfId = AppcLcmActorServiceProvider.vnfNamedQuery(resourceId, aaiResponse.vnfID); + } catch (AAIException e) { + logger.warn(e.toString()); + fail("no vnf-id found"); + } + assertNotNull(targetVnfId); + assertEquals(targetVnfId, aaiResponse.vnfID); + } } diff --git a/controlloop/common/eventmanager/pom.xml b/controlloop/common/eventmanager/pom.xml index 57de25576..7479f65ee 100644 --- a/controlloop/common/eventmanager/pom.xml +++ b/controlloop/common/eventmanager/pom.xml @@ -167,5 +167,11 @@ ${project.version} test + + org.onap.policy.drools-applications + simulators + 1.1.0-SNAPSHOT + test + 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 1127bce3b..eeb724ad2 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 @@ -209,10 +209,12 @@ public class ControlLoopOperationManager implements Serializable { this.currentOperation = operation; if ("ModifyConfig".equalsIgnoreCase(policy.getRecipe())) { - this.operationRequest = APPCActorServiceProvider.constructRequest((VirtualControlLoopEvent)onset, operation.operation, this.policy); + this.operationRequest = APPCActorServiceProvider.constructRequest((VirtualControlLoopEvent) onset, + operation.operation, this.policy, eventManager.getVnfResponse()); } else { - this.operationRequest = AppcLcmActorServiceProvider.constructRequest((VirtualControlLoopEvent) onset, operation.operation, this.policy); + this.operationRequest = AppcLcmActorServiceProvider.constructRequest((VirtualControlLoopEvent) onset, + operation.operation, this.policy, eventManager.getVnfResponse()); } // // Save the operation 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 c5c0bc967..caa17ff38 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 @@ -29,6 +29,8 @@ import java.time.Instant; import java.util.HashMap; import java.util.UUID; +import org.junit.AfterClass; +import org.junit.BeforeClass; import org.junit.Test; import org.onap.policy.aai.util.AAIException; import org.onap.policy.appclcm.LCMRequest; @@ -42,6 +44,8 @@ import org.onap.policy.controlloop.Util; import org.onap.policy.controlloop.policy.ControlLoopPolicy; import org.onap.policy.controlloop.policy.PolicyResult; import org.onap.policy.controlloop.processor.ControlLoopProcessor; +import org.onap.policy.drools.http.server.HttpServletServer; +import org.onap.policy.drools.system.PolicyEngine; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -51,16 +55,32 @@ public class ControlLoopOperationManagerTest { static { onset = new VirtualControlLoopEvent(); onset.requestID = UUID.randomUUID(); - onset.target = "vserver.selflink"; + onset.target = "generic-vnf.vnf-name"; onset.closedLoopAlarmStart = Instant.now(); onset.AAI = new HashMap<>(); - onset.AAI.put("cloud-region.identity-url", "foo"); - onset.AAI.put("vserver.selflink", "bar"); - onset.AAI.put("vserver.is-closed-loop-disabled", "false"); onset.AAI.put("generic-vnf.vnf-name", "testTriggerSource"); onset.closedLoopEventStatus = ControlLoopEventStatus.ONSET; + + /* Set environment properties */ + PolicyEngine.manager.setEnvironmentProperty("aai.url", "http://localhost:6666"); + PolicyEngine.manager.setEnvironmentProperty("aai.username", "AAI"); + PolicyEngine.manager.setEnvironmentProperty("aai.password", "AAI"); } + @BeforeClass + public static void setUpSimulator() { + try { + org.onap.policy.simulators.Util.buildAaiSim(); + } catch (Exception e) { + fail(e.getMessage()); + } + } + + @AfterClass + public static void tearDownSimulator() { + HttpServletServer.factory.destroy(); + } + @Test public void testRetriesFail() { // @@ -77,7 +97,14 @@ public class ControlLoopOperationManagerTest { // create the manager // ControlLoopEventManager eventManager = new ControlLoopEventManager(onset.closedLoopControlName, onset.requestID); - + try { + eventManager.checkEventSyntax(onset); + } + catch (ControlLoopException e) { + logger.warn(e.toString()); + fail("The onset failed the syntax check"); + } + ControlLoopOperationManager manager = new ControlLoopOperationManager(onset, processor.getCurrentPolicy(), eventManager); logger.debug("{}",manager); // @@ -192,6 +219,13 @@ public class ControlLoopOperationManagerTest { // create the manager // ControlLoopEventManager eventManager = new ControlLoopEventManager(onset.closedLoopControlName, onset.requestID); + try { + eventManager.checkEventSyntax(onset); + } + catch (ControlLoopException e) { + logger.warn(e.toString()); + fail("The onset failed the syntax check"); + } ControlLoopOperationManager manager = new ControlLoopOperationManager(onset, processor.getCurrentPolicy(), eventManager); // diff --git a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java index 03686a860..1a0eb311f 100644 --- a/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java +++ b/controlloop/common/simulators/src/main/java/org/onap/policy/simulators/AaiSimulatorJaxRs.java @@ -79,12 +79,16 @@ public class AaiSimulatorJaxRs { @Path("/v11/network/generic-vnfs/generic-vnf") @Consumes(MediaType.APPLICATION_JSON) @Produces("application/json") - public String getByVnfName (@QueryParam("vnfName") String vnfName) + public String getByVnfName (@QueryParam("vnf-name") String vnfName) { if ("getFail".equals(vnfName)) { return "{\"requestError\":{\"serviceException\":{\"messageId\":\"SVC3001\",\"text\":\"Resource not found for %1 using id %2 (msg=%3) (ec=%4)\",\"variables\":[\"GET\",\"network/generic-vnfs/generic-vnf\",\"Node Not Found:No Node of type generic-vnf found at network/generic-vnfs/generic-vnf\",\"ERR.5.4.6114\"]}}}"; } boolean isDisabled = "disableClosedLoop".equals(vnfName); + if ("error".equals(vnfName)) { + return "{ \"vnf-id\": \"error\", \"vnf-name\": \"" + vnfName + "\", \"vnf-type\": \"RT\", \"service-id\": \"d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4\", \"equipment-role\": \"UCPE\", \"orchestration-status\": \"created\", \"management-option\": \"ATT\", \"ipv4-oam-address\": \"32.40.68.35\", \"ipv4-loopback0-address\": \"32.40.64.57\", \"nm-lan-v6-address\": \"2001:1890:e00e:fffe::1345\", \"management-v6-address\": \"2001:1890:e00e:fffd::36\", \"in-maint\": false, \"is-closed-loop-disabled\": " + isDisabled + ", \"resource-version\": \"1493389458092\", \"relationship-list\": {\"relationship\":[{ \"related-to\": \"service-instance\", \"related-link\": \"/aai/v11/business/customers/customer/1610_Func_Global_20160817084727/service-subscriptions/service-subscription/uCPE-VMS/service-instances/service-instance/USUCP0PCOIL0110UJZZ01\", \"relationship-data\":[{ \"relationship-key\": \"customer.global-customer-id\", \"relationship-value\": \"1610_Func_Global_20160817084727\"},{ \"relationship-key\": \"service-subscription.service-type\", \"relationship-value\": \"uCPE-VMS\"},{ \"relationship-key\": \"service-instance.service-instance-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01\"} ], \"related-to-property\": [{\"property-key\": \"service-instance.service-instance-name\"}]},{ \"related-to\": \"vserver\", \"related-link\": \"/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/USUCP0PCOIL0110UJZZ01%3A%3AuCPE-VMS/vservers/vserver/3b2558f4-39d8-40e7-bfc7-30660fb52c45\", \"relationship-data\":[{ \"relationship-key\": \"cloud-region.cloud-owner\", \"relationship-value\": \"att-aic\"},{ \"relationship-key\": \"cloud-region.cloud-region-id\", \"relationship-value\": \"AAIAIC25\"},{ \"relationship-key\": \"tenant.tenant-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01::uCPE-VMS\"},{ \"relationship-key\": \"vserver.vserver-id\", \"relationship-value\": \"3b2558f4-39d8-40e7-bfc7-30660fb52c45\"} ], \"related-to-property\": [ {\"property-key\": \"vserver.vserver-name\",\"property-value\": \"USUCP0PCOIL0110UJZZ01-vsrx\" }]} ]}}"; + + } return "{ \"vnf-id\": \"5e49ca06-2972-4532-9ed4-6d071588d792\", \"vnf-name\": \"" + vnfName + "\", \"vnf-type\": \"RT\", \"service-id\": \"d7bb0a21-66f2-4e6d-87d9-9ef3ced63ae4\", \"equipment-role\": \"UCPE\", \"orchestration-status\": \"created\", \"management-option\": \"ATT\", \"ipv4-oam-address\": \"32.40.68.35\", \"ipv4-loopback0-address\": \"32.40.64.57\", \"nm-lan-v6-address\": \"2001:1890:e00e:fffe::1345\", \"management-v6-address\": \"2001:1890:e00e:fffd::36\", \"in-maint\": false, \"is-closed-loop-disabled\": " + isDisabled + ", \"resource-version\": \"1493389458092\", \"relationship-list\": {\"relationship\":[{ \"related-to\": \"service-instance\", \"related-link\": \"/aai/v11/business/customers/customer/1610_Func_Global_20160817084727/service-subscriptions/service-subscription/uCPE-VMS/service-instances/service-instance/USUCP0PCOIL0110UJZZ01\", \"relationship-data\":[{ \"relationship-key\": \"customer.global-customer-id\", \"relationship-value\": \"1610_Func_Global_20160817084727\"},{ \"relationship-key\": \"service-subscription.service-type\", \"relationship-value\": \"uCPE-VMS\"},{ \"relationship-key\": \"service-instance.service-instance-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01\"} ], \"related-to-property\": [{\"property-key\": \"service-instance.service-instance-name\"}]},{ \"related-to\": \"vserver\", \"related-link\": \"/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/att-aic/AAIAIC25/tenants/tenant/USUCP0PCOIL0110UJZZ01%3A%3AuCPE-VMS/vservers/vserver/3b2558f4-39d8-40e7-bfc7-30660fb52c45\", \"relationship-data\":[{ \"relationship-key\": \"cloud-region.cloud-owner\", \"relationship-value\": \"att-aic\"},{ \"relationship-key\": \"cloud-region.cloud-region-id\", \"relationship-value\": \"AAIAIC25\"},{ \"relationship-key\": \"tenant.tenant-id\", \"relationship-value\": \"USUCP0PCOIL0110UJZZ01::uCPE-VMS\"},{ \"relationship-key\": \"vserver.vserver-id\", \"relationship-value\": \"3b2558f4-39d8-40e7-bfc7-30660fb52c45\"} ], \"related-to-property\": [ {\"property-key\": \"vserver.vserver-name\",\"property-value\": \"USUCP0PCOIL0110UJZZ01-vsrx\" }]} ]}}"; } diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java index bae7a5155..f18b440d7 100644 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java +++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java @@ -276,7 +276,7 @@ public class VCPEControlLoopTest implements TopicListener { String policyName = notification.policyName; if (policyName.endsWith("EVENT")) { logger.debug("Rule Fired: " + notification.policyName); - if ("getFail".equals(notification.AAI.get("generic-vnf.vnf-id"))) { + if ("getFail".equals(notification.AAI.get("generic-vnf.vnf-name"))) { assertEquals(ControlLoopNotificationType.REJECTED, notification.notification); kieSession.halt(); } @@ -364,22 +364,22 @@ public class VCPEControlLoopTest implements TopicListener { VirtualControlLoopEvent event = new VirtualControlLoopEvent(); event.closedLoopControlName = policy.getControlLoop().getControlLoopName(); event.requestID = requestID; - event.target = "generic-vnf.vnf-id"; + event.target = "generic-vnf.vnf-name"; event.closedLoopAlarmStart = Instant.now(); event.AAI = new HashMap<>(); - event.AAI.put("generic-vnf.vnf-id", "testGenericVnfID"); + event.AAI.put("generic-vnf.vnf-name", "testGenericVnfName"); event.closedLoopEventStatus = status; kieSession.insert(event); } - protected void sendEvent(ControlLoopPolicy policy, UUID requestID, ControlLoopEventStatus status, String vnfId) { + protected void sendEvent(ControlLoopPolicy policy, UUID requestID, ControlLoopEventStatus status, String vnfName) { VirtualControlLoopEvent event = new VirtualControlLoopEvent(); event.closedLoopControlName = policy.getControlLoop().getControlLoopName(); event.requestID = requestID; - event.target = "generic-vnf.vnf-id"; + event.target = "generic-vnf.vnf-name"; event.closedLoopAlarmStart = Instant.now(); event.AAI = new HashMap<>(); - event.AAI.put("generic-vnf.vnf-id", vnfId); + event.AAI.put("generic-vnf.vnf-name", vnfName); event.closedLoopEventStatus = status; kieSession.insert(event); } diff --git a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java index 54591cad0..f73e3b39e 100644 --- a/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java +++ b/controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VFWControlLoopTest.java @@ -322,7 +322,7 @@ public class VFWControlLoopTest implements TopicListener { String policyName = notification.policyName; if (policyName.endsWith("EVENT")) { logger.debug("Rule Fired: " + notification.policyName); - if ("getFail".equals(notification.AAI.get("generic-vnf.vnf-id"))) { + if ("getFail".equals(notification.AAI.get("generic-vnf.vnf-name"))) { assertEquals(ControlLoopNotificationType.REJECTED, notification.notification); kieSession.halt(); } @@ -363,8 +363,8 @@ public class VFWControlLoopTest implements TopicListener { } else if (policyName.endsWith("EVENT.MANAGER")) { logger.debug("Rule Fired: " + notification.policyName); - if ("error".equals(notification.AAI.get("generic-vnf.vnf-id"))) { - assertTrue(ControlLoopNotificationType.FINAL_FAILURE.equals(notification.notification)); + if ("error".equals(notification.AAI.get("generic-vnf.vnf-name"))) { + assertEquals(ControlLoopNotificationType.FINAL_FAILURE, notification.notification); assertEquals("Exception in processing closed loop", notification.message); } else { @@ -408,10 +408,10 @@ public class VFWControlLoopTest implements TopicListener { VirtualControlLoopEvent event = new VirtualControlLoopEvent(); event.closedLoopControlName = policy.getControlLoop().getControlLoopName(); event.requestID = requestID; - event.target = "generic-vnf.vnf-id"; + event.target = "generic-vnf.vnf-name"; event.closedLoopAlarmStart = Instant.now(); event.AAI = new HashMap<>(); - event.AAI.put("generic-vnf.vnf-id", "testGenericVnfID"); + event.AAI.put("generic-vnf.vnf-name", "testGenericVnfID"); event.closedLoopEventStatus = status; kieSession.insert(event); } @@ -429,10 +429,10 @@ public class VFWControlLoopTest implements TopicListener { VirtualControlLoopEvent event = new VirtualControlLoopEvent(); event.closedLoopControlName = policy.getControlLoop().getControlLoopName(); event.requestID = requestID; - event.target = "generic-vnf.vnf-id"; + event.target = "generic-vnf.vnf-name"; event.closedLoopAlarmStart = Instant.now(); event.AAI = new HashMap<>(); - event.AAI.put("generic-vnf.vnf-id", vnfId); + event.AAI.put("generic-vnf.vnf-name", vnfId); event.closedLoopEventStatus = status; kieSession.insert(event); } -- cgit 1.2.3-korg