aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common
diff options
context:
space:
mode:
authorJorge Hernandez <jh1730@att.com>2017-09-28 02:49:17 +0000
committerGerrit Code Review <gerrit@onap.org>2017-09-28 02:49:17 +0000
commit74f8161fbdec7c60a1df7103d39a500953cc7f64 (patch)
treeb00021beba38f99542cf4c63efaab5dba812610f /controlloop/common
parent060a99c988e622e7c8010bf8519aafbc0cdd6c81 (diff)
parent49609bb26fe27810b24af57b3add15cfd19bdfa2 (diff)
Merge "Cleanup for VFC Actor code"
Diffstat (limited to 'controlloop/common')
-rw-r--r--controlloop/common/actors/actor.vfc/pom.xml7
-rw-r--r--controlloop/common/actors/actor.vfc/src/main/java/org/onap/policy/controlloop/actor/vfc/VFCActorServiceProvider.java50
2 files changed, 30 insertions, 27 deletions
diff --git a/controlloop/common/actors/actor.vfc/pom.xml b/controlloop/common/actors/actor.vfc/pom.xml
index c52b6aed7..223be4bda 100644
--- a/controlloop/common/actors/actor.vfc/pom.xml
+++ b/controlloop/common/actors/actor.vfc/pom.xml
@@ -34,6 +34,11 @@
<version>1.1.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
-
+ <dependency>
+ <groupId>org.onap.policy.drools-pdp</groupId>
+ <artifactId>policy-management</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
</dependencies>
</project>
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 1ea65faa5..469faa46c 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
@@ -28,6 +28,7 @@ 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.drools.system.PolicyEngine;
import org.onap.policy.controlloop.actorServiceProvider.spi.Actor;
import com.google.common.collect.ImmutableList;
@@ -66,53 +67,50 @@ public class VFCActorServiceProvider implements Actor {
public static VFCRequest constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation,
Policy policy) {
-
// Construct an VFC request
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.nsInstanceId = getAAIServiceInstance(onset);
+ request.requestId = onset.requestID;
request.healRequest = new VFCHealRequest();
request.healRequest.vnfInstanceId = onset.AAI.get("generic-vnf.vnf-id");
request.healRequest.cause = operation.message;
request.healRequest.additionalParams = new VFCHealAdditionalParams();
- switch (policy.getRecipe()) {
- case "Restart":
- // TODO: check target??
- request.healRequest.additionalParams.action = "restartvm";
- request.healRequest.additionalParams.actionInfo = new VFCHealActionVmInfo();
- // TODO: Verify vserver-id and vserver-name is part of onset event
- request.healRequest.additionalParams.actionInfo.vmid = onset.AAI.get("vserver.vserver-id");
- request.healRequest.additionalParams.actionInfo.vmname = onset.AAI.get("vserver.vserver-name");
- break;
- default:
- // TODO: default
- break;
+ if ("Restart".equalsIgnoreCase(policy.getRecipe())) {
+ request.healRequest.additionalParams.action = "restartvm";
+ request.healRequest.additionalParams.actionInfo = new VFCHealActionVmInfo();
+ request.healRequest.additionalParams.actionInfo.vmid = onset.AAI.get("vserver.vserver-id");
+ request.healRequest.additionalParams.actionInfo.vmname = onset.AAI.get("vserver.vserver-name");
+ } else {
+ request = null;
}
return request;
}
private static String getAAIServiceInstance(VirtualControlLoopEvent event) {
- AAIGETVnfResponse response = null;
+ AAIGETVnfResponse response;
UUID requestID = event.requestID;
String serviceInstance = event.AAI.get("service-instance.service-instance-id");
String vnfName = event.AAI.get("generic-vnf.vnf-name");
String vnfID = event.AAI.get("generic-vnf.vnf-id");
- String urlBase = "http://localhost:6666";
- String username = "testUser";
- String password = "testPass";
if (serviceInstance == null) {
+ String aaiUrl = PolicyEngine.manager.getEnvironmentProperty("aai.url");
+ String aaiUsername = PolicyEngine.manager.getEnvironmentProperty("aai.username");
+ String aaiPassword = PolicyEngine.manager.getEnvironmentProperty("aai.password");
try {
if (vnfName != null) {
- String url = urlBase + "/aai/v11/network/generic-vnfs/generic-vnf?vnf-name=";
- response = AAIManager.getQueryByVnfName(url, username, password, requestID, vnfName);
- serviceInstance = response.serviceId;
+ String url = aaiUrl + "/aai/v11/network/generic-vnfs/generic-vnf?vnf-name=";
+ response = AAIManager.getQueryByVnfName(url, aaiUsername, aaiPassword, requestID, vnfName);
+ if (response != null) {
+ serviceInstance = response.serviceId;
+ }
} else if (vnfID != null) {
- String url = urlBase + "/aai/v11/network/generic-vnfs/generic-vnf/";
- response = AAIManager.getQueryByVnfID(url, username, password, requestID, vnfID);
- serviceInstance = response.serviceId;
+ String url = aaiUrl + "/aai/v11/network/generic-vnfs/generic-vnf/";
+ response = AAIManager.getQueryByVnfID(url, aaiUsername, aaiPassword, requestID, vnfID);
+ if (response != null) {
+ serviceInstance = response.serviceId;
+ }
} else {
logger.error("getAAIServiceInstance failed");