aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--appc-dg-util/appc-dg-util-bundle/src/main/java/org/onap/appc/dg/util/impl/ExecuteNodeActionImpl.java226
1 files changed, 103 insertions, 123 deletions
diff --git a/appc-dg-util/appc-dg-util-bundle/src/main/java/org/onap/appc/dg/util/impl/ExecuteNodeActionImpl.java b/appc-dg-util/appc-dg-util-bundle/src/main/java/org/onap/appc/dg/util/impl/ExecuteNodeActionImpl.java
index 4f517d211..abe24554d 100644
--- a/appc-dg-util/appc-dg-util-bundle/src/main/java/org/onap/appc/dg/util/impl/ExecuteNodeActionImpl.java
+++ b/appc-dg-util/appc-dg-util-bundle/src/main/java/org/onap/appc/dg/util/impl/ExecuteNodeActionImpl.java
@@ -15,15 +15,15 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* ============LICENSE_END=========================================================
*/
@@ -35,14 +35,12 @@ import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
-
import org.onap.appc.dg.util.ExecuteNodeAction;
import org.onap.appc.exceptions.APPCException;
import org.onap.appc.i18n.Msg;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
-
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import com.att.eelf.i18n.EELFResourceManager;
@@ -64,12 +62,8 @@ public class ExecuteNodeActionImpl implements ExecuteNodeAction {
private static final String RELATED_TO_PROPERTY_LEN_PARAM = "related-to-property_length";
public static final String DG_OUTPUT_STATUS_MESSAGE = "output.status.message";
private static EELFLogger logger = EELFManager.getInstance().getLogger(ExecuteNodeActionImpl.class);
- private static Map<String, String> vnfHierarchyMap = new ConcurrentHashMap<>();
- private static Map<String, Set<String>> vnfcHierarchyMap = new HashMap<>();
- private static int vmCount = 0;
- private static Set<String> vmSet;
- private static String vmURL;
+
private AAIServiceFactory aaiServiceFactory;
public ExecuteNodeActionImpl(AAIServiceFactory aaiServiceFactory) {
@@ -174,120 +168,10 @@ public class ExecuteNodeActionImpl implements ExecuteNodeAction {
}
}
- private void getVserverRelations(SvcLogicContext vnfCtx, SvcLogicContext ctx) throws APPCException {
-
- 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++;
- }
- }
- }
-
@Override
public void getVnfHierarchy(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
- if (logger.isDebugEnabled()) {
+
+ if (logger.isDebugEnabled()) {
logger.debug("Inside getVnfHierarchy======");
}
String resourceKey = params.get(RESOURCE_KEY_PARAM);
@@ -303,9 +187,105 @@ public class ExecuteNodeActionImpl implements ExecuteNodeAction {
if (vnfCtx.getAttribute(GET_RESOURCE_RESULT).equals(SUCCESS_PARAM)) {
trySetHeatStackIDAttribute(ctx, vnfCtx);
ctx.setAttribute("vnf.type", vnfCtx.getAttribute("vnfRetrived.vnf-type"));
+ Map<String, String> vnfHierarchyMap = new ConcurrentHashMap<>();
+ Map<String, Set<String>> vnfcHierarchyMap = new HashMap<>();
+ int vmCount = 0;
+ Set<String> vmSet;
+ String vmURL;
// loop through relationship-list data, to get vserver relations
- getVserverRelations(vnfCtx, ctx);
+ 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++;
+ }
+ }
vnfHierarchyMap.put("VNF.VMCount", Integer.toString(vmCount));
if (vmCount == 0) {
ctx.setAttribute(DG_OUTPUT_STATUS_MESSAGE, "VM count is 0");