Fix Generic VNF isClosedLoopDisabled 43/22043/1
authordaniel <dc443y@att.com>
Fri, 3 Nov 2017 15:39:23 +0000 (10:39 -0500)
committerdaniel <dc443y@att.com>
Fri, 3 Nov 2017 15:45:07 +0000 (10:45 -0500)
No A&AI queries will be done for enriched events.
The event manager now understands prepended "generic-vnf."
in front of is-closed-loop-disabled from DCAE onsets.
A test case was revised to include sample data from an
enriched onset with vnf data based on the VES documentation.

Issue-Id: POLICY-350
Change-Id: Id7f59f8b860b9f147087067a2a9a7766f167f7e4
Signed-off-by: Daniel Cruz <dc443y@att.com>
controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java
controlloop/templates/template.demo/src/test/java/org/onap/policy/template/demo/VCPEControlLoopTest.java

index b167420..4adcff0 100644 (file)
@@ -560,7 +560,8 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
        }
        
        public void queryAai(VirtualControlLoopEvent event) throws AAIException {
-               if (event.AAI.get("vserver.is-closed-loop-disabled") == null) {
+               if (event.AAI.get("vserver.is-closed-loop-disabled") == null && 
+                       event.AAI.get("generic-vnf.is-closed-loop-disabled") == null) {
                        try {
                                if (event.AAI.get("generic-vnf.vnf-id") != null) {
                                        vnfResponse = getAAIVnfInfo(event); 
@@ -635,7 +636,13 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
                    "yes".equalsIgnoreCase(event.AAI.get("vserver.is-closed-loop-disabled")) || 
                    "Y".equalsIgnoreCase(event.AAI.get("vserver.is-closed-loop-disabled"))) { 
                        return true; 
-               }               
+               }
+               else if ("true".equalsIgnoreCase(event.AAI.get("generic-vnf.is-closed-loop-disabled")) || 
+                   "T".equalsIgnoreCase(event.AAI.get("generic-vnf.is-closed-loop-disabled")) || 
+                   "yes".equalsIgnoreCase(event.AAI.get("generic-vnf.is-closed-loop-disabled")) || 
+                   "Y".equalsIgnoreCase(event.AAI.get("generic-vnf.is-closed-loop-disabled"))) { 
+                   return true; 
+           }
                return false;
        }
        
index cebdc1e..26a82fe 100644 (file)
@@ -144,6 +144,14 @@ public class ControlLoopOperationManager implements Serializable {
                         return virtualOnset.AAI.get("generic-vnf.vnf-id");
                     }
                     else if (this.onset.target.equalsIgnoreCase("generic-vnf.vnf-name")) {
+                        /*
+                         * If the onset is enriched with the vnf-id,
+                         * we don't need an A&AI response
+                         */
+                        if (virtualOnset.AAI.containsKey("generic-vnf.vnf-id")) {
+                            return virtualOnset.AAI.get("generic-vnf.vnf-id");
+                        }
+                        
                         /*
                          * If the vnf-name was retrieved from the onset then the vnf-id
                          * must be obtained from the event manager's A&AI GET query
index 55812f1..377cff4 100644 (file)
@@ -41,9 +41,11 @@ import org.onap.policy.appclcm.LCMResponse;
 import org.onap.policy.appclcm.LCMResponseWrapper;
 import org.onap.policy.controlloop.ControlLoopEventStatus;
 import org.onap.policy.controlloop.ControlLoopNotificationType;
+import org.onap.policy.controlloop.ControlLoopTargetType;
 import org.onap.policy.controlloop.VirtualControlLoopEvent;
 import org.onap.policy.controlloop.VirtualControlLoopNotification;
 import org.onap.policy.controlloop.policy.ControlLoopPolicy;
+import org.onap.policy.controlloop.policy.TargetType;
 import org.onap.policy.drools.event.comm.Topic.CommInfrastructure;
 import org.onap.policy.drools.event.comm.TopicEndpoint;
 import org.onap.policy.drools.event.comm.TopicListener;
@@ -148,8 +150,7 @@ public class VCPEControlLoopTest implements TopicListener {
          * receive from DCAE to kick off processing through
          * the rules
          */
-        sendEvent(pair.a, requestID, ControlLoopEventStatus.ONSET);
-
+        sendEvent(pair.a, requestID, ControlLoopEventStatus.ONSET, "vCPEInfraVNF13", true);
         
         kieSession.fireUntilHalt();
         
@@ -187,7 +188,7 @@ public class VCPEControlLoopTest implements TopicListener {
          * receive from DCAE to kick off processing through
          * the rules
          */
-        sendEvent(pair.a, requestID, ControlLoopEventStatus.ONSET, "getFail");
+        sendEvent(pair.a, requestID, ControlLoopEventStatus.ONSET, "getFail", false);
 
         
         kieSession.fireUntilHalt();
@@ -319,7 +320,7 @@ public class VCPEControlLoopTest implements TopicListener {
                     kieSession.halt();
                 }
                 else {
-                    assertTrue(ControlLoopNotificationType.FINAL_SUCCESS.equals(notification.notification));
+                    assertEquals(ControlLoopNotificationType.FINAL_SUCCESS, notification.notification);
                     kieSession.halt();
                 }
             }
@@ -376,14 +377,26 @@ public class VCPEControlLoopTest implements TopicListener {
         kieSession.insert(event);
     }
     
-    protected void sendEvent(ControlLoopPolicy policy, UUID requestID, ControlLoopEventStatus status, String vnfName) {
+    protected void sendEvent(ControlLoopPolicy policy, UUID requestID, 
+            ControlLoopEventStatus status, String vnfName, boolean isEnriched) {
         VirtualControlLoopEvent event = new VirtualControlLoopEvent();
         event.closedLoopControlName = policy.getControlLoop().getControlLoopName();
         event.requestID = requestID;
         event.target = "generic-vnf.vnf-name";
+        event.target_type = ControlLoopTargetType.VNF;
         event.closedLoopAlarmStart = Instant.now();
         event.AAI = new HashMap<>();
         event.AAI.put("generic-vnf.vnf-name", vnfName);
+        if (isEnriched) {
+            event.AAI.put("generic-vnf.in-maint", "false");
+            event.AAI.put("generic-vnf.is-closed-loop-disabled", "false");
+            event.AAI.put("generic-vnf.orchestration-status", "Created");
+            event.AAI.put("generic-vnf.prov-status", "PREPROV");
+            event.AAI.put("generic-vnf.resource-version", "1");
+            event.AAI.put("generic-vnf.service-id", "e8cb8968-5411-478b-906a-f28747de72cd");
+            event.AAI.put("generic-vnf.vnf-id", "63b31229-9a3a-444f-9159-04ce2dca3be9");
+            event.AAI.put("generic-vnf.vnf-type", "vCPEInfraService10/vCPEInfraService10 0");
+        }
         event.closedLoopEventStatus = status;
         kieSession.insert(event);
     }