+ logger.debug("Parsing Vserver details from VNF relations");
+ for (String ctxKeySet : vnfCtx.getAttributeKeySet()) {
+ if (ctxKeySet.startsWith("vnfRetrived.") && "vserver".equalsIgnoreCase(vnfCtx.getAttribute(ctxKeySet))) {
+ String vmKey = ctxKeySet.substring(0, ctxKeySet.length() - "related-to".length());
+ String vserverID = null;
+ String tenantID = null;
+ String cloudOwner = null;
+ String cloudRegionId = null;
+ int relationshipLength = getAttribute(vnfCtx, vmKey, RELATIONSHIP_DATA_LEN_PARAM);
+
+ for (int j = 0; j < relationshipLength; j++) {
+ // loop inside relationship data, to get vserver-id and tenant-id
+ String key = vnfCtx.getAttribute(vmKey + RELATIONSHIP_DATA_STR + j + "].relationship-key");
+ String value = vnfCtx.getAttribute(vmKey + RELATIONSHIP_DATA_STR + j + "].relationship-value");
+
+ vnfHierarchyMap.put(VNFF_VM_STR + vmCount + "]." + key, value);
+ if ("vserver.vserver-id".equals(key)) {
+ vserverID = value;
+ }
+ if ("tenant.tenant-id".equals(key)) {
+ tenantID = value;
+ }
+ if ("cloud-region.cloud-owner".equals(key)) {
+ cloudOwner = value;
+ }
+ if ("cloud-region.cloud-region-id".equals(key)) {
+ cloudRegionId = value;
+ }
+ }
+ int relatedPropertyLength = getAttribute(vnfCtx, vmKey, RELATED_TO_PROPERTY_LEN_PARAM);
+ for (int j = 0; j < relatedPropertyLength; j++) {
+ // loop inside related-to-property data, to get vserver-name
+ String key = vnfCtx.getAttribute(vmKey + "related-to-property[" + j + "].property-key");
+ String value = vnfCtx.getAttribute(vmKey + "related-to-property[" + j + "].property-value");
+ vnfHierarchyMap.put(VNFF_VM_STR + vmCount + "]." + key, value);
+ }
+ // Retrive VM relations to find vnfc's VM to VNFC is 1 to 1 relation
+ String vmRetrivalKey = "vserver.vserver-id = '" + vserverID + "' AND tenant.tenant_id = '" + tenantID
+ + "'" + "' AND cloud-region.cloud-owner = '" + cloudOwner
+ + "' AND cloud-region.cloud-region-id = '" + cloudRegionId + "'";
+ Map<String, String> paramsVm = new HashMap<>();
+ paramsVm.put(RESOURCE_TYPE_PARAM, "vserver");
+ paramsVm.put(PREFIX_PARAM, "vmRetrived");
+ paramsVm.put(RESOURCE_KEY_PARAM, vmRetrivalKey);
+ SvcLogicContext vmCtx = getSvcLogicContext();
+
+ logger.debug("Retrieving VM details from A&AI");
+ getResource(paramsVm, vmCtx);
+ if ((SUCCESS_PARAM).equals(vmCtx.getAttribute(GET_RESOURCE_RESULT))) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Parsing VNFC details from VM relations");
+ }
+ vmURL = vmCtx.getAttribute("vmRetrived.vserver-selflink");
+ vnfHierarchyMap.put(VNFF_VM_STR + vmCount + "].URL", vmURL);
+
+ // loop through relationship-list data, to get vnfc relations
+ for (String ctxVnfcKeySet : vmCtx.getAttributeKeySet()) {
+ if (ctxVnfcKeySet.startsWith("vmRetrived.")
+ && "vnfc".equalsIgnoreCase(vmCtx.getAttribute(ctxVnfcKeySet))) {
+
+ String vnfcKey = ctxVnfcKeySet.substring(0, ctxVnfcKeySet.length() - "related-to".length());
+
+ relationshipLength = getAttribute(vmCtx, vnfcKey, RELATIONSHIP_DATA_LEN_PARAM);
+
+ for (int j = 0; j < relationshipLength; j++) {
+ // loop through relationship data, to get vnfc name
+ String key = vmCtx
+ .getAttribute(vnfcKey + RELATIONSHIP_DATA_STR + j + "].relationship-key");
+ String value = vmCtx
+ .getAttribute(vnfcKey + RELATIONSHIP_DATA_STR + j + "].relationship-value");
+ if ("vnfc.vnfc-name".equalsIgnoreCase(key)) {
+ vnfHierarchyMap.put(VNFF_VM_STR + vmCount + "].VNFC", value);
+ vmSet = resolveVmSet(vnfcHierarchyMap, value);
+ vmSet.add(vmURL);
+ vnfcHierarchyMap.put(value, vmSet);
+ break;
+ // VM to VNFC is 1 to 1 relation, once we got the VNFC name we can break the loop
+ }
+ }
+ }
+ }
+ } else {
+ ctx.setAttribute(DG_OUTPUT_STATUS_MESSAGE, ERROR_RETRIEVING_VNFC_HIERARCHY_PARAM);
+ vnfHierarchyMap.put(GET_VNF_HIERARCHY_RESULT_PARAM, "FAILURE");
+ logger.error("Failed in getVnfHierarchy, Error retrieving Vserver details. Error message: "
+ + vmCtx.getAttribute(GET_RESOURCE_RESULT));
+ logger.warn("Incorrect or Incomplete VNF Hierarchy");
+ throw new APPCException(ERROR_RETRIEVING_VNFC_HIERARCHY_PARAM);
+ }
+ vmCount++;
+ }
+ }