diff options
Diffstat (limited to 'controlloop/common/actors')
3 files changed, 38 insertions, 35 deletions
diff --git a/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java b/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java index a014c7a80..8c1b23af9 100644 --- a/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java +++ b/controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java @@ -136,10 +136,10 @@ public class SOActorServiceProvider implements Actor { } - /** + /** * Constructs and sends an AAI vserver Named Query * - * @param eventRequestID + * @param onset * @returns the response to the AAI Named Query */ private AAINQResponseWrapper AaiNamedQueryRequest(VirtualControlLoopEvent onset) { @@ -239,9 +239,9 @@ public class SOActorServiceProvider implements Actor { int nonBaseIndex = -1; List<AAINQInventoryResponseItem> inventoryItems = namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems; for (AAINQInventoryResponseItem m : inventoryItems) { - if (m.vfModule != null && m.vfModule.isBaseVfModule == true) { + if (m.vfModule != null && m.vfModule.isBaseVfModule) { baseIndex = inventoryItems.indexOf(m); - } else if (m.vfModule != null && m.vfModule.isBaseVfModule == false && m.vfModule.orchestrationStatus == null) { + } else if (m.vfModule != null && m.vfModule.orchestrationStatus == null) { nonBaseIndex = inventoryItems.indexOf(m); } // @@ -302,7 +302,7 @@ public class SOActorServiceProvider implements Actor { } // Extracted fields should not be null - if (checkExtractedFields() == false) { + if (!checkExtractedFields()) { System.err.println("some fields are missing from AAI response."); return; } @@ -338,7 +338,7 @@ public class SOActorServiceProvider implements Actor { */ public SORequest constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation, Policy policy) { - if (policy.getActor().equals("SO") && policy.getRecipe().equals("VF Module Create")) { + if ("SO".equals(policy.getActor()) && "VF Module Create".equals(policy.getRecipe())) { // perform named query request and handle response AaiNamedQueryRequest(onset); } else { @@ -348,7 +348,7 @@ public class SOActorServiceProvider implements Actor { // check if the fields extracted from named query response are // not null so we can proceed with SO request - if (checkExtractedFields() == false) { + if (!checkExtractedFields()) { System.err.println("AAI response is missing some required fields. Cannot proceed with SO Request construction."); return null; @@ -553,7 +553,7 @@ public class SOActorServiceProvider implements Actor { } /** - * @param serviceItemModeInvariantlId the serviceItemModelInvariantId to set + * @param serviceItemModelInvariantId the serviceItemModelInvariantId to set */ private void setServiceItemModelInvariantId(String serviceItemModelInvariantId) { this.serviceItemModelInvariantId = serviceItemModelInvariantId; 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"); |