diff options
author | Pamela Dragosh <pdragosh@research.att.com> | 2017-09-22 15:08:34 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2017-09-22 15:08:34 +0000 |
commit | 7d39eea7a0537b4a1dd6f0d1ac9d30b268e1d91d (patch) | |
tree | bd84bd4e32f6f3ff3ec48d56bc01a86adbfd2530 /controlloop/common | |
parent | b2b8f46ab3a524eae487fa932d9ceb2b884a68f5 (diff) | |
parent | 1aa30b7d83f97103097c7f5d3e4cbd2fad92f659 (diff) |
Merge "Add VFC Response in Working Memory & JUNIT"
Diffstat (limited to 'controlloop/common')
8 files changed, 58 insertions, 16 deletions
diff --git a/controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VFCActorServiceProvider.java b/controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VFCActorServiceProvider.java index 49b93e8aa..1ea65faa5 100644 --- a/controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VFCActorServiceProvider.java +++ b/controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VFCActorServiceProvider.java @@ -19,10 +19,8 @@ package org.onap.policy.controlloop.actor.vfc; import java.util.Collections; -import java.util.HashMap; import java.util.List; -import java.util.Map; - +import java.util.UUID; import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.vfc.VFCRequest; import org.onap.policy.vfc.VFCHealRequest; @@ -30,15 +28,12 @@ import org.onap.policy.vfc.VFCHealAdditionalParams; import org.onap.policy.vfc.VFCHealActionVmInfo; import org.onap.policy.controlloop.ControlLoopOperation; import org.onap.policy.controlloop.policy.Policy; - import org.onap.policy.controlloop.actorServiceProvider.spi.Actor; + import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; import org.onap.policy.aai.AAIManager; import org.onap.policy.aai.AAIGETVnfResponse; - -import java.util.UUID; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -76,7 +71,7 @@ public class VFCActorServiceProvider implements Actor { VFCRequest request = new VFCRequest(); // TODO: Verify service-instance-id is part of onset event request.nsInstanceId = getAAIServiceInstance(onset); // onset.AAI.get("service-instance.service-instance-id"); - + request.requestId = onset.requestID; request.healRequest = new VFCHealRequest(); request.healRequest.vnfInstanceId = onset.AAI.get("generic-vnf.vnf-id"); request.healRequest.cause = operation.message; @@ -110,14 +105,13 @@ public class VFCActorServiceProvider implements Actor { String password = "testPass"; if (serviceInstance == null) { try { - AAIManager manager = new AAIManager(); if (vnfName != null) { String url = urlBase + "/aai/v11/network/generic-vnfs/generic-vnf?vnf-name="; - response = manager.getQueryByVnfName(url, username, password, requestID, vnfName); + response = AAIManager.getQueryByVnfName(url, username, password, requestID, vnfName); serviceInstance = response.serviceId; } else if (vnfID != null) { String url = urlBase + "/aai/v11/network/generic-vnfs/generic-vnf/"; - response = manager.getQueryByVnfID(url, username, password, requestID, vnfID); + response = AAIManager.getQueryByVnfID(url, username, password, requestID, vnfID); serviceInstance = response.serviceId; } else { logger.error("getAAIServiceInstance failed"); diff --git a/controlloop/common/eventmanager/pom.xml b/controlloop/common/eventmanager/pom.xml index e41c24bd7..57de25576 100644 --- a/controlloop/common/eventmanager/pom.xml +++ b/controlloop/common/eventmanager/pom.xml @@ -142,6 +142,13 @@ <version>1.1.0-SNAPSHOT</version> <scope>provided</scope> </dependency> + <dependency> + <groupId>org.onap.policy.drools-applications</groupId> + <artifactId>vfc</artifactId> + <version>1.1.0-SNAPSHOT</version> + <scope>provided</scope> + </dependency> + <dependency> <groupId>org.apache.httpcomponents</groupId> <artifactId>httpclient</artifactId> 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 8849a2351..ec99c1a5c 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 @@ -45,6 +45,7 @@ import org.onap.policy.controlloop.policy.Policy; import org.onap.policy.controlloop.policy.PolicyResult; import org.onap.policy.controlloop.actor.so.SOActorServiceProvider; import org.onap.policy.so.SOResponse; +import org.onap.policy.vfc.VFCResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -367,8 +368,28 @@ public class ControlLoopOperationManager implements Serializable { return PolicyResult.FAILURE; } + } else if (response instanceof VFCResponse) { + VFCResponse vfcResponse = (VFCResponse) response; + if (vfcResponse.responseDescriptor.getStatus().equalsIgnoreCase("finished")) { + // + // Consider it as success + // + this.completeOperation(new Integer(1), " Success", PolicyResult.SUCCESS); + if (this.policyResult != null && this.policyResult.equals(PolicyResult.FAILURE_TIMEOUT)) { + return null; + } + return PolicyResult.SUCCESS; + } else { + // + // Consider it as failure + // + this.completeOperation(new Integer(1), " Failed", PolicyResult.FAILURE); + if (this.policyResult != null && this.policyResult.equals(PolicyResult.FAILURE_TIMEOUT)) { + return null; + } + return PolicyResult.FAILURE; + } } - return null; } diff --git a/controlloop/common/model-impl/vfc/pom.xml b/controlloop/common/model-impl/vfc/pom.xml index db86345e8..7672b1bc9 100644 --- a/controlloop/common/model-impl/vfc/pom.xml +++ b/controlloop/common/model-impl/vfc/pom.xml @@ -45,5 +45,11 @@ <artifactId>rest</artifactId> <version>${project.version}</version> </dependency> + <dependency> + <groupId>org.drools</groupId> + <artifactId>drools-core</artifactId> + <version>6.5.0.Final</version> + <scope>provided</scope> + </dependency> </dependencies> </project> diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java index 4797ab906..5cb6d6624 100644 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java +++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCManager.java @@ -21,6 +21,7 @@ package org.onap.policy.vfc; import java.util.HashMap; import java.util.Map; +import org.drools.core.WorkingMemory; import org.onap.policy.vfc.util.Serialization; import org.onap.policy.rest.RESTManager; import org.onap.policy.rest.RESTManager.Pair; @@ -35,9 +36,11 @@ public final class VFCManager implements Runnable { private String username; private String password; private VFCRequest vfcRequest; + WorkingMemory workingMem; private static final Logger logger = LoggerFactory.getLogger(VFCManager.class); - public VFCManager(VFCRequest request) { + public VFCManager(WorkingMemory wm, VFCRequest request) { + workingMem = wm; vfcRequest = request; // TODO: Get base URL, username and password from MSB? // TODO: Following code is a placeholder, needs to be updated @@ -83,6 +86,7 @@ public final class VFCManager implements Runnable { Pair<Integer, String> httpDetailsGet = RESTManager.get(urlGet, username, password, headers); responseGet = Serialization.gsonPretty.fromJson(httpDetailsGet.b, VFCResponse.class); + responseGet.requestId = vfcRequest.requestId.toString(); body = Serialization.gsonPretty.toJson(responseGet); logger.debug("Response to VFC Heal get:"); logger.debug(body); @@ -91,6 +95,7 @@ public final class VFCManager implements Runnable { if (responseGet.responseDescriptor.status.equalsIgnoreCase("finished") || responseGet.responseDescriptor.status.equalsIgnoreCase("error")) { logger.debug("VFC Heal Status {}", responseGet.responseDescriptor.status); + workingMem.insert(responseGet); break; } } @@ -102,6 +107,7 @@ public final class VFCManager implements Runnable { && (responseGet.responseDescriptor.status != null) && (!responseGet.responseDescriptor.status.isEmpty())) { logger.debug("VFC timeout. Status: ({})", responseGet.responseDescriptor.status); + workingMem.insert(responseGet); } } catch (JsonSyntaxException e) { logger.error("Failed to deserialize into VFCResponse {}",e.getLocalizedMessage(),e); diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCRequest.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCRequest.java index 9e3a77a2b..89c9b08ff 100644 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCRequest.java +++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCRequest.java @@ -19,14 +19,16 @@ package org.onap.policy.vfc; import java.io.Serializable; +import java.util.UUID; import com.google.gson.annotations.SerializedName; public class VFCRequest implements Serializable { private static final long serialVersionUID = 3736300970326332512L; - // This field is not serialized and not part of JSON + // These fields are not serialized and not part of JSON public transient String nsInstanceId; + public transient UUID requestId; @SerializedName("healVnfData") public VFCHealRequest healRequest; diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponse.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponse.java index 775d78f1d..5d6efa0ce 100644 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponse.java +++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponse.java @@ -30,7 +30,9 @@ public class VFCResponse implements Serializable { public String jobId; @SerializedName("responseDescriptor") - VFCResponseDescriptor responseDescriptor; + public VFCResponseDescriptor responseDescriptor; + + public transient String requestId; public VFCResponse() { } diff --git a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseDescriptor.java b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseDescriptor.java index 9bf77c57c..62c61a7f6 100644 --- a/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseDescriptor.java +++ b/controlloop/common/model-impl/vfc/src/main/java/org/onap/policy/vfc/VFCResponseDescriptor.java @@ -27,7 +27,7 @@ public class VFCResponseDescriptor implements Serializable { private static final long serialVersionUID = 6827782899144150158L; @SerializedName("progress") - public String progress; + String progress; @SerializedName("status") String status; @@ -47,4 +47,8 @@ public class VFCResponseDescriptor implements Serializable { public VFCResponseDescriptor() { } + public String getStatus() { + return status; + } + } |