Parse new model ids from operation policy 35/84235/5
authorvamshi.nemalikonda <vn00480215@techmahindra.com>
Wed, 10 Apr 2019 11:07:08 +0000 (16:37 +0530)
committerVamshi Krishna Namilikonda <vn00480215@techmahindra.com>
Wed, 10 Apr 2019 13:43:26 +0000 (13:43 +0000)
Takes VFModule info from policy yaml,instead AAI.

Change-Id: If745b3ba32562cbc37571cea29ec7797ee697e88
Issue-ID: POLICY-1545
Signed-off-by: vamshi.nemalikonda <vn00480215@techmahindra.com>
controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java
controlloop/common/guard/src/main/java/org/onap/policy/guard/PolicyGuard.java
controlloop/templates/template.demo/src/test/resources/yaml/policy_ControlLoop_SO-test.yaml

index 8b7b159..7bd0a0e 100644 (file)
@@ -4,6 +4,7 @@
  * ================================================================================
  * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
  * Modifications Copyright (C) 2019 Huawei Technologies Co., Ltd. All rights reserved.
+ * Modifications Copyright (C) 2019 Tech Mahindra
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -227,6 +228,31 @@ public class ControlLoopOperationManager implements Serializable {
                     return vnfId;
                 }
                 throw new ControlLoopException("Target does not match target type");
+            case VFMODULE:
+                VirtualControlLoopEvent virtualOnsetEvent = (VirtualControlLoopEvent) this.onset;
+                if (this.onset.getTarget().equalsIgnoreCase(VSERVER_VSERVER_NAME)) {
+                    return virtualOnsetEvent.getAai().get(VSERVER_VSERVER_NAME);
+                } else if (this.onset.getTarget().equalsIgnoreCase(GENERIC_VNF_VNF_ID)) {
+                    return virtualOnsetEvent.getAai().get(GENERIC_VNF_VNF_ID);
+                } else if (this.onset.getTarget().equalsIgnoreCase(GENERIC_VNF_VNF_NAME)) {
+                    /*
+                     * If the onset is enriched with the vnf-id, we don't need an A&AI response
+                     */
+                    if (virtualOnsetEvent.getAai().containsKey(GENERIC_VNF_VNF_ID)) {
+                        return virtualOnsetEvent.getAai().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
+                     */
+                    String vnfId = this.eventManager.getVnfResponse().getVnfId();
+                    if (vnfId == null) {
+                        throw new AaiException("No vnf-id found");
+                    }
+                    return vnfId;
+                }
+                throw new ControlLoopException("Target does not match target type");
             default:
                 throw new ControlLoopException("The target type is not supported");
         }
@@ -989,7 +1015,7 @@ public class ControlLoopOperationManager implements Serializable {
 
     /**
      * Construct a ControlLoopResponse object from actor response and input event.
-     * 
+     *
      * @param response the response from actor
      * @param event the input event
      *
index 7ae0e7e..90e6e87 100644 (file)
@@ -3,6 +3,7 @@
  * guard
  * ================================================================================
  * Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ * Modifications Copyright (C) 2019 Tech Mahindra
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -108,6 +109,12 @@ public class PolicyGuard {
                 // Create the Lock object
                 //
                 return new VnfTargetLock(targetType, targetInstance, requestId, callback);
+                
+            case VFMODULE:
+                //
+                // Create the Lock object
+                //
+                return new VnfTargetLock(targetType, targetInstance, requestId, callback);
             default:
                 logger.error("invalid target type {} for lock on {}", targetType, targetInstance);
                 return null;
index f57a6d6..c6125d0 100644 (file)
@@ -28,7 +28,12 @@ policies:
     actor: SO
     recipe: VF Module Create
     target:
-      type: VNF
+      type: VFMODULE
+      modelInvariantId: 90b793b5-b8ae-4c36-b10b-4b6372859d3a
+      modelVersionId: 2210154d-e61a-4d7f-8fb9-0face1aee3f8
+      modelName: SproutScalingVf..scaling_sprout..module-1
+      modelVersion: 1
+      modelCustomizationId: 3e2d67ad-3495-4732-82f6-b0b872791fff
     payload:
       requestParameters: '{"usePreload":true,"userParams":[]}'
       configurationParameters: '[{"ip-addr":"$.vf-module-topology.vf-module-parameters.param[9]","oam-ip-addr":"$.vf-module-topology.vf-module-parameters.param[16]","enabled":"$.vf-module-topology.vf-module-parameters.param[23]"}]'