summaryrefslogtreecommitdiffstats
path: root/models-interactions/model-actors/actor.vfc/src/main
diff options
context:
space:
mode:
authorpramod.jamkhedkar <pramod@research.att.com>2019-04-09 14:40:16 -0400
committerpramod.jamkhedkar <pramod@research.att.com>2019-04-10 17:02:16 -0400
commit38c89e3a57f168603faaf2ad4220105b2d54a9c8 (patch)
tree1f9568e77e9999663c89b7ee88655d0eb386a755 /models-interactions/model-actors/actor.vfc/src/main
parente678e5af567040022f23ed7a1ba1723b82434418 (diff)
Custom Query Code
Changes to aai, so, vfc and restmanager to support aai custom queries. updated to latest version of aai schema. Made changes according to latest updates. Issue-ID: POLICY-1278 Change-Id: I255cef17fff4fe7d4ea21344c0e5ccaac52cbe9a Signed-off-by: pramod.jamkhedkar <pramod@research.att.com>
Diffstat (limited to 'models-interactions/model-actors/actor.vfc/src/main')
-rw-r--r--models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java50
1 files changed, 48 insertions, 2 deletions
diff --git a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java b/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java
index 23eb71996..61cf81da9 100644
--- a/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java
+++ b/models-interactions/model-actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VfcActorServiceProvider.java
@@ -22,11 +22,10 @@ package org.onap.policy.controlloop.actor.vfc;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
-
import java.util.Collections;
import java.util.List;
import java.util.UUID;
-
+import org.onap.policy.aai.AaiCqResponse;
import org.onap.policy.aai.AaiGetVnfResponse;
import org.onap.policy.aai.AaiManager;
import org.onap.policy.controlloop.ControlLoopOperation;
@@ -146,4 +145,51 @@ public class VfcActorServiceProvider implements Actor {
}
return response;
}
+
+ /**
+ * This method constructs the VFC request.
+ *
+ * @param onset onset object
+ * @param operation operation object
+ * @param policy policy object
+ * @param aaiCqResponse response from aai custom query
+ * @return VfcRequest
+ */
+ public static VfcRequest constructRequestCq(VirtualControlLoopEvent onset, ControlLoopOperation operation,
+ Policy policy, AaiCqResponse aaiCqResponse) {
+
+ // Construct an VFC request
+ VfcRequest request = new VfcRequest();
+ String serviceInstance = onset.getAai().get("service-instance.service-instance-id");
+ if (serviceInstance == null || "".equals(serviceInstance)) {
+ // get service isntance from AaiCqResponse
+ if (aaiCqResponse == null) {
+ return null;
+ }
+ serviceInstance = aaiCqResponse.getServiceInstance().getServiceInstanceId();
+ // If the serviceInstanceId returned is null then return null
+ if (serviceInstance == null) {
+ return null;
+ }
+
+ }
+ request.setNsInstanceId(serviceInstance);
+ request.setRequestId(onset.getRequestId());
+ request.setHealRequest(new VfcHealRequest());
+ request.getHealRequest().setVnfInstanceId(onset.getAai().get("generic-vnf.vnf-id"));
+ request.getHealRequest().setCause(operation.getMessage());
+ request.getHealRequest().setAdditionalParams(new VfcHealAdditionalParams());
+
+ if (policy.getRecipe().toLowerCase().equalsIgnoreCase(RECIPE_RESTART)) {
+ request.getHealRequest().getAdditionalParams().setAction("restartvm");
+ request.getHealRequest().getAdditionalParams().setActionInfo(new VfcHealActionVmInfo());
+ request.getHealRequest().getAdditionalParams().getActionInfo()
+ .setVmid(onset.getAai().get("vserver.vserver-id"));
+ request.getHealRequest().getAdditionalParams().getActionInfo()
+ .setVmname(onset.getAai().get("vserver.vserver-name"));
+ } else {
+ return null;
+ }
+ return request;
+ }
}