summaryrefslogtreecommitdiffstats
path: root/controlloop/common/eventmanager/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop/common/eventmanager/src/main')
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java44
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java23
2 files changed, 53 insertions, 14 deletions
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
index f891a2c6a..0d4aa938c 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
@@ -45,6 +45,7 @@ import org.onap.policy.guard.LockCallback;
import org.onap.policy.guard.PolicyGuard;
import org.onap.policy.guard.PolicyGuard.LockResult;
import org.onap.policy.guard.TargetLock;
+import org.onap.policy.drools.system.PolicyEngine;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -73,6 +74,12 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
private transient TargetLock targetLock = null;
private static AAIGETVnfResponse vnfResponse = null;
private static AAIGETVserverResponse vserverResponse = null;
+ private static String aaiHostURL;
+ private static String aaiUser;
+ private static String aaiPassword;
+ private static String aaiGetQueryByVserver;
+ private static String aaiGetQueryByVnfID;
+ private static String aaiGetQueryByVnfName;
private static Collection<String> requiredAAIKeys = new ArrayList<>();
static {
@@ -540,7 +547,7 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
if (vnfResponse == null) {
throw new ControlLoopException("AAI Response is null (query by vnf-id)");
}
- if (vnfResponse != null && isClosedLoopDisabled(vnfResponse) == true) {
+ if (isClosedLoopDisabled(vnfResponse) == true) {
throw new ControlLoopException("is-closed-loop-disabled is set to true");
}
} else if (event.AAI.get("generic-vnf.vnf-name") != null) {
@@ -548,7 +555,7 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
if (vnfResponse == null) {
throw new ControlLoopException("AAI Response is null (query by vnf-name)");
}
- if (vnfResponse != null && isClosedLoopDisabled(vnfResponse) == true) {
+ if (isClosedLoopDisabled(vnfResponse) == true) {
throw new ControlLoopException("is-closed-loop-disabled is set to true");
}
} else if (event.AAI.get("vserver.vserver-name") != null) {
@@ -556,7 +563,7 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
if (vserverResponse == null) {
throw new ControlLoopException("AAI Response is null (query by vserver-name)");
}
- if (vserverResponse != null && isClosedLoopDisabled(vserverResponse) == true) {
+ if (isClosedLoopDisabled(vserverResponse) == true) {
throw new ControlLoopException("is-closed-loop-disabled is set to true");
}
}
@@ -615,16 +622,19 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
}
public static AAIGETVserverResponse getAAIVserverInfo(VirtualControlLoopEvent event) throws ControlLoopException {
- String user = "POLICY";
- String password = "POLICY";
UUID requestID = event.requestID;
AAIGETVserverResponse response = null;
String vserverName = event.AAI.get("vserver.vserver-name");
try {
if (vserverName != null) {
- String url = "https://aai-ext1.test.att.com:8443/aai/v11/nodes/vservers?vserver-name=";
- response = AAIManager.getQueryByVserverName(url, user, password, requestID, vserverName);
+ aaiHostURL = PolicyEngine.manager.getEnvironmentProperty("aai.url");
+ aaiUser = PolicyEngine.manager.getEnvironmentProperty("aai.user");
+ aaiPassword = PolicyEngine.manager.getEnvironmentProperty("aai.password");
+ String aaiGetQueryByVserver = "/aai/v11/nodes/vservers?vserver-name=";
+ String url = aaiHostURL + aaiGetQueryByVserver;
+ logger.info("url: " + url);
+ response = AAIManager.getQueryByVserverName(url, aaiUser, aaiPassword, requestID, vserverName);
}
} catch (Exception e) {
logger.error("getAAIVserverInfo exception: ", e);
@@ -635,8 +645,6 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
}
public static AAIGETVnfResponse getAAIVnfInfo(VirtualControlLoopEvent event) throws ControlLoopException {
- String user = "POLICY";
- String password = "POLICY";
UUID requestID = event.requestID;
AAIGETVnfResponse response = null;
String vnfName = event.AAI.get("generic-vnf.vnf-name");
@@ -644,11 +652,21 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
try {
if (vnfName != null) {
- String url = "https://aai-ext1.test.att.com:8443/aai/v11/network/generic-vnfs/generic-vnf?vnf-name=";
- response = AAIManager.getQueryByVnfName(url, user, password, requestID, vnfName);
+ aaiHostURL = PolicyEngine.manager.getEnvironmentProperty("aai.url");
+ aaiUser = PolicyEngine.manager.getEnvironmentProperty("aai.user");
+ aaiPassword = PolicyEngine.manager.getEnvironmentProperty("aai.password");
+ String aaiGetQueryByVnfName = "/aai/v11/network/generic-vnfs/generic-vnf?vnf-name=";
+ String url = aaiHostURL + aaiGetQueryByVnfName;
+ logger.info("url: " + url);
+ response = AAIManager.getQueryByVnfName(url, aaiUser, aaiPassword, requestID, vnfName);
} else if (vnfID != null) {
- String url = "https://aai-ext1.test.att.com:8443/aai/v11/network/generic-vnfs/generic-vnf/";
- response = AAIManager.getQueryByVnfID(url, user, password, requestID, vnfID);
+ aaiHostURL = PolicyEngine.manager.getEnvironmentProperty("aai.url");
+ aaiUser = PolicyEngine.manager.getEnvironmentProperty("aai.user");
+ aaiPassword = PolicyEngine.manager.getEnvironmentProperty("aai.password");
+ String aaiGetQueryByVnfID = "/aai/v11/network/generic-vnfs/generic-vnf/";
+ String url = aaiHostURL + aaiGetQueryByVnfID;
+ logger.info("url: " + url);
+ response = AAIManager.getQueryByVnfID(url, aaiUser, aaiPassword, requestID, vnfID);
}
} catch (Exception e) {
logger.error("getAAIVnfInfo exception: ", e);
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 a772efce3..10cf173fc 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;
}