summaryrefslogtreecommitdiffstats
path: root/controlloop/common/actors/actor.so
diff options
context:
space:
mode:
authorHockla, Ali (ah999m) <ah999m@att.com>2017-10-16 12:15:03 -0500
committerHockla, Ali (ah999m) <ah999m@att.com>2017-10-17 15:20:07 -0500
commit3cf3293477bc482ec842d6069d7d0995be6b1002 (patch)
tree58c27bcd00feeaf524688cbdc1be059059d488ac /controlloop/common/actors/actor.so
parent777302bddf16316fb555ebc0d9f32dd2ecc0ebf4 (diff)
Update SO Interface AAI NQ response from v8 to v11
- Removed nonBaseIndex since there is only base vf Module in v11 response - Reverted to checkExtractedFields() - Modified the AAI Simulator to return the v11 response - If AAI NQ fails then the SO Request will not be constructed. In this case, we are retracting objects from the transaction and inserting policyResult.FAILURE into current operation to prevent null values in finishOperation Issue-ID: POLICY-339 Change-Id: I1c48fac4f9a51467ad54b0706543f5d1baa70389 Signed-off-by: Hockla, Ali (ah999m) <ah999m@att.com>
Diffstat (limited to 'controlloop/common/actors/actor.so')
-rw-r--r--controlloop/common/actors/actor.so/src/main/java/org/onap/policy/controlloop/actor/so/SOActorServiceProvider.java66
1 files changed, 19 insertions, 47 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 8c1b23af9..b31906334 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
@@ -27,9 +27,9 @@ import java.util.Map;
import java.util.UUID;
import org.drools.core.WorkingMemory;
+import org.onap.policy.aai.AAIManager;
import org.onap.policy.aai.AAINQInstanceFilters;
import org.onap.policy.aai.AAINQInventoryResponseItem;
-import org.onap.policy.aai.AAIManager;
import org.onap.policy.aai.AAINQNamedQuery;
import org.onap.policy.aai.AAINQQueryParameters;
import org.onap.policy.aai.AAINQRequest;
@@ -202,12 +202,17 @@ public class SOActorServiceProvider implements Actor {
// insert aainqResponseWrapper to memory -- Is this needed?
// insert(aainqResponseWrapper);
- //
+ if (logger.isDebugEnabled()) {
+ logger.debug("AAI Named Query Response: ");
+ logger.debug(Serialization.gsonPretty.toJson(aainqResponseWrapper.aainqresponse));
+ }
+
extractSOFieldsFromNamedQuery(aainqResponseWrapper, onset);
return aainqResponseWrapper;
}
}
+
/**
* Extract the required fields from the named query response
* @param namedQueryResponseWrapper
@@ -236,22 +241,19 @@ public class SOActorServiceProvider implements Actor {
// Find the index for base vf module and non-base vf module
int baseIndex = -1;
- 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) {
baseIndex = inventoryItems.indexOf(m);
- } else if (m.vfModule != null && m.vfModule.orchestrationStatus == null) {
- nonBaseIndex = inventoryItems.indexOf(m);
- }
+ }
//
- if (baseIndex != -1 && nonBaseIndex != -1) {
+ if (baseIndex != -1) {
break;
}
}
// Report the error if either base vf module or non-base vf module is not found
- if (baseIndex == -1 || nonBaseIndex == -1) {
+ if (baseIndex == -1) {
logger.error("Either base or non-base vf module is not found from AAI response.");
return;
}
@@ -261,49 +263,19 @@ public class SOActorServiceProvider implements Actor {
setVfModuleItemVfModuleName(vfModuleItemVfModuleName.replace("Vfmodule", "vDNS"));
// vfModuleItem - NOT the base module
- setVfModuleItemModelInvariantId(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).vfModule.modelInvariantId);
- setVfModuleItemModelVersionId(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).vfModule.modelVersionId);
- setVfModuleItemModelName(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).extraProperties.extraProperty.get(0).propertyValue);
- setVfModuleItemModelNameVersionId(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(nonBaseIndex).extraProperties.extraProperty.get(4).propertyValue);
+ setVfModuleItemModelInvariantId(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(baseIndex).vfModule.modelInvariantId);
+ setVfModuleItemModelVersionId(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(baseIndex).vfModule.modelVersionId);
+ setVfModuleItemModelName(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(baseIndex).extraProperties.extraProperty.get(0).propertyValue);
+ setVfModuleItemModelNameVersionId(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(0).items.inventoryResponseItems.get(baseIndex).extraProperties.extraProperty.get(4).propertyValue);
// tenantItem
setTenantItemTenantId(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).tenant.tenantId);
// cloudRegionItem
setCloudRegionItemCloudRegionId(namedQueryResponseWrapper.aainqresponse.inventoryResponseItems.get(0).items.inventoryResponseItems.get(1).items.inventoryResponseItems.get(0).cloudRegion.cloudRegionId);
-
+
} catch (Exception e) {
- logger.error(e.getMessage(), e);
- VirtualControlLoopNotification notification = new VirtualControlLoopNotification(onset);
- notification.notification = ControlLoopNotificationType.REJECTED;
- notification.message = "Exception occurred " + e.getMessage();
- notification.policyName = onset.policyName;
- notification.policyScope = onset.policyScope;
- notification.policyVersion = onset.policyVersion;
- //
- try {
- logger.debug(Serialization.gsonPretty.toJson(notification));
- } catch (Exception e1) {
- logger.error("Can't deliver notification: " + notification);
- logger.error(e1.getMessage(), e1);
- }
- //
- notification.notification = ControlLoopNotificationType.FINAL_FAILURE;
- notification.message = "Invalid named-query response from AAI";
- //
- try {
- logger.debug(Serialization.gsonPretty.toJson(notification));
- } catch (Exception e1) {
- logger.error("Can't deliver notification: " + notification);
- logger.error(e1.getMessage(), e1);
- }
- // Retract everything
- return;
- }
-
- // Extracted fields should not be null
- if (!checkExtractedFields()) {
- System.err.println("some fields are missing from AAI response.");
+ logger.warn("Problem extracting SO data from AAI query response because of {}", e.getMessage(), e);
return;
}
}
@@ -327,7 +299,7 @@ public class SOActorServiceProvider implements Actor {
}
return true;
}
-
+
/**
* Construct SO Request
*
@@ -335,6 +307,7 @@ public class SOActorServiceProvider implements Actor {
* @param operation
* @param policy
* @return SORequest
+ * @throws IllegalAccessException
*/
public SORequest constructRequest(VirtualControlLoopEvent onset, ControlLoopOperation operation, Policy policy) {
@@ -349,8 +322,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()) {
-
- System.err.println("AAI response is missing some required fields. Cannot proceed with SO Request construction.");
+ logger.warn("AAI response is missing some required fields. Cannot proceed with SO Request construction.");
return null;
} else {