summaryrefslogtreecommitdiffstats
path: root/controlloop/common/actors/actor.appclcm/src
diff options
context:
space:
mode:
authordaniel <dc443y@att.com>2017-10-24 22:00:08 -0500
committerdaniel <dc443y@att.com>2017-10-25 09:29:41 -0500
commit85b1ada7cc0883aa8b86ea6e11bf86719e1cc10e (patch)
tree86f4712aa717e1fa5e510c345f887b3e0c11f6c8 /controlloop/common/actors/actor.appclcm/src
parent7e3ace91847ec5aaccfeeff638a8d2d9b17e45fc (diff)
Fix Source/Target Lock
The locking of the target is now taken care of when the operation manager is initialized. This allows us to keep the template flow the same and to ensure that for vFW we will not lock the source if it is not intended to be the target. NOTE: This will have to be revised in the future if policy chaining will support having different targets specified for each policy in the chain. Additional work was done for hardening the APPC model code to make sure exceptions are caught and we gracefully end processing the event with memory clean up and a final failure notification sent. Issue-Id: POLICY-367 Change-Id: Ic796d95eb5400067744492f810dd8069ba6241b3 Signed-off-by: Daniel Cruz <dc443y@att.com> Signed-off-by: daniel <dc443y@att.com>
Diffstat (limited to 'controlloop/common/actors/actor.appclcm/src')
-rw-r--r--controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java15
-rw-r--r--controlloop/common/actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmServiceProviderTest.java12
2 files changed, 5 insertions, 22 deletions
diff --git a/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java b/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java
index 1c7ee9089..ed59aafc5 100644
--- a/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java
+++ b/controlloop/common/actors/actor.appclcm/src/main/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmActorServiceProvider.java
@@ -33,7 +33,6 @@ import java.util.UUID;
import org.onap.policy.aai.AAINQInstanceFilters;
import org.onap.policy.aai.AAINQInventoryResponseItem;
-import org.onap.policy.aai.AAIGETVnfResponse;
import org.onap.policy.aai.AAIManager;
import org.onap.policy.aai.AAINQNamedQuery;
import org.onap.policy.aai.AAINQQueryParameters;
@@ -58,9 +57,6 @@ import org.slf4j.LoggerFactory;
public class AppcLcmActorServiceProvider implements Actor {
private static final Logger logger = LoggerFactory.getLogger(AppcLcmActorServiceProvider.class);
-
- /* The source vnf-id provided from the DCAE onset */
- private static final String DCAE_VNF_ID = "generic-vnf.vnf-id";
/* To be used in future releases to restart a single vm */
private static final String APPC_VM_ID = "vm-id";
@@ -204,7 +200,7 @@ public class AppcLcmActorServiceProvider implements Actor {
* @throws AAIException
*/
public static LCMRequestWrapper constructRequest(VirtualControlLoopEvent onset,
- ControlLoopOperation operation, Policy policy, AAIGETVnfResponse vnfResponse) throws AAIException {
+ ControlLoopOperation operation, Policy policy, String targetVnf) throws AAIException {
/* Construct an APPC request using LCM Model */
@@ -235,14 +231,7 @@ public class AppcLcmActorServiceProvider implements Actor {
* a vnf-id.
*/
HashMap<String, String> requestActionIdentifiers = new HashMap<>();
- String vnfId = onset.AAI.get(DCAE_VNF_ID);
- if (vnfId == null) {
- vnfId = vnfResponse.vnfID;
- if (vnfId == null) {
- throw new AAIException("No vnf-id found");
- }
- }
- requestActionIdentifiers.put("vnf-id", vnfId);
+ requestActionIdentifiers.put("vnf-id", targetVnf);
appcRequest.setActionIdentifiers(requestActionIdentifiers);
diff --git a/controlloop/common/actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmServiceProviderTest.java b/controlloop/common/actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmServiceProviderTest.java
index 7c0f1882a..d446968ef 100644
--- a/controlloop/common/actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmServiceProviderTest.java
+++ b/controlloop/common/actors/actor.appclcm/src/test/java/org/onap/policy/controlloop/actor/appclcm/AppcLcmServiceProviderTest.java
@@ -30,7 +30,6 @@ import java.util.UUID;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.onap.policy.aai.AAIGETVnfResponse;
import org.onap.policy.aai.util.AAIException;
import org.onap.policy.appclcm.LCMCommonHeader;
import org.onap.policy.appclcm.LCMRequest;
@@ -58,7 +57,6 @@ public class AppcLcmServiceProviderTest {
private static VirtualControlLoopEvent onsetEvent;
private static ControlLoopOperation operation;
private static Policy policy;
- private static AAIGETVnfResponse aaiResponse;
private static LCMRequestWrapper dmaapRequest;
private static LCMResponseWrapper dmaapResponse;
@@ -97,10 +95,6 @@ public class AppcLcmServiceProviderTest {
policy.setPayload(null);
policy.setRetry(2);
policy.setTimeout(300);
-
- /* Construct a mock A&AI response */
- aaiResponse = new AAIGETVnfResponse();
- aaiResponse.vnfID = "vnf01";
/* A sample DMAAP request wrapper. */
dmaapRequest = new LCMRequestWrapper();
@@ -171,7 +165,7 @@ public class AppcLcmServiceProviderTest {
LCMRequestWrapper dmaapRequest = null;
try {
- dmaapRequest = AppcLcmActorServiceProvider.constructRequest(onsetEvent, operation, policy, aaiResponse);
+ dmaapRequest = AppcLcmActorServiceProvider.constructRequest(onsetEvent, operation, policy, "vnf01");
} catch (AAIException e) {
logger.warn(e.toString());
fail("no vnfid found");
@@ -315,12 +309,12 @@ public class AppcLcmServiceProviderTest {
String resourceId = "82194af1-3c2c-485a-8f44-420e22a9eaa4";
String targetVnfId = null;
try {
- targetVnfId = AppcLcmActorServiceProvider.vnfNamedQuery(resourceId, aaiResponse.vnfID);
+ targetVnfId = AppcLcmActorServiceProvider.vnfNamedQuery(resourceId, "vnf01");
} catch (AAIException e) {
logger.warn(e.toString());
fail("no vnf-id found");
}
assertNotNull(targetVnfId);
- assertEquals(targetVnfId, aaiResponse.vnfID);
+ assertEquals(targetVnfId, "vnf01");
}
}