aboutsummaryrefslogtreecommitdiffstats
path: root/appc-outbound/appc-aai-client/provider/src
diff options
context:
space:
mode:
Diffstat (limited to 'appc-outbound/appc-aai-client/provider/src')
-rw-r--r--appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/aai/AaiService.java510
-rw-r--r--appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/aai/AaiServiceInternalException.java32
-rw-r--r--appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/aai/MissingParameterException.java32
-rw-r--r--appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/aai/VServerInfo.java74
-rw-r--r--appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/aai/MockAaiService.java896
-rw-r--r--appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/node/MockAaiService.java75
6 files changed, 865 insertions, 754 deletions
diff --git a/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/aai/AaiService.java b/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/aai/AaiService.java
index a77aa9cb3..2e94e9294 100644
--- a/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/aai/AaiService.java
+++ b/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/aai/AaiService.java
@@ -24,6 +24,8 @@
package org.onap.appc.aai.client.aai;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@@ -34,16 +36,40 @@ import org.onap.appc.aai.client.AppcAaiClientConstant;
import org.onap.ccsdk.sli.adaptors.aai.AAIClient;
import org.onap.ccsdk.sli.adaptors.aai.AAIService;
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 org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.ServiceReference;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
public class AaiService {
private static final EELFLogger log = EELFManager.getInstance().getLogger(AaiService.class);
+ private static final String STR_VNF_ID = "generic-vnf.vnf-id = '";
+ private static final String STR_VNFC_REF = "vnfcReference[";
+ private static final String STR_VNFC_REF_KEY = "VNFCREFKEY ";
+ private static final String STR_AAI_REF_KEY = "AAIREFKEY ";
+ private static final String STR_RELATIONSHIP_LIST = ".relationship-list.relationship[";
+ private static final String STR_VNFC_NAME = "vnfc.vnfc-name = '";
+ private static final String QUERY_STR_VNFC_NAME = "VNFCNAME IN INSERTVNFCS ";
+
+ private static final String PARAM_GENERIC_VNF = "generic-vnf";
+ private static final String PARAM_VNF_INFO = "vnfInfo";
+ private static final String PARAM_VSERVER = "vserver";
+ private static final String PARAM_VM_INFO = "vmInfo";
+ private static final String PARAM_PROV_STATUS = "prov-status";
+ private static final String PARAM_VAL_NVTPROV = "NVTPROV";
+
+ private static final String ATTR_VSERVER_ID = "vserver-id";
+ private static final String ATTR_TENANT_ID = "tenant-id";
+ private static final String ATTR_CLOUD_OWNER = "cloud-owner";
+ private static final String ATTR_CLOUD_REGION_ID = "cloud-region-id";
+ private static final String ATTR_VNFC_COUNT = "vm.vnfc-count";
+ private static final String ATTR_VNFC_NAME = "vnfc-name";
+ private static final String ATTR_VNFC_FUNC_CODE = "VNFC-FUNCTION-CODE";
+ private static final String ATTR_VSERVER_NAME = "vserver-name";
+ private static final String ATTR_VNF_ID = "vnf-id";
+
private AAIClient aaiClient;
public AaiService(AAIClient aaiClient) {
@@ -56,18 +82,17 @@ public class AaiService {
aaiClient = (AAIClient) bctx.getService(sref);
}
- public void getGenericVnfInfo(Map<String, String> params, SvcLogicContext ctx) throws Exception {
+ public void getGenericVnfInfo(Map<String, String> params, SvcLogicContext ctx)
+ throws AaiServiceInternalException, SvcLogicException {
String vnfId = params.get("vnfId");
if (StringUtils.isBlank(vnfId)) {
- throw new Exception("VnfId is missing");
+ throw new AaiServiceInternalException("VnfId is missing");
}
String prefix = params.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
prefix = StringUtils.isNotBlank(prefix) ? (prefix + ".") : "";
- String resourceKey = "generic-vnf.vnf-id = '" + vnfId + "'";
- String resourceType = "generic-vnf";
- String queryPrefix = "vnfInfo";
- SvcLogicContext vnfCtx = readResource(resourceKey, queryPrefix, resourceType);
+ String resourceKey = STR_VNF_ID + vnfId + "'";
+ SvcLogicContext vnfCtx = readResource(resourceKey, PARAM_VNF_INFO, PARAM_GENERIC_VNF);
ctx.setAttribute(prefix + "vnf.vnf-name", vnfCtx.getAttribute("vnfInfo.vnf-name"));
ctx.setAttribute(prefix + "vnf.vnf-type", vnfCtx.getAttribute("vnfInfo.vnf-type"));
@@ -83,18 +108,19 @@ public class AaiService {
}
log.info("RELLEN " + relationshipLength);
for (int i = 0; i < relationshipLength; i++) {
- String vserverId = getRelationshipValue(i, vnfCtx, "vserver", "vserver.vserver-id", "vnfInfo");
- String tenantId = getRelationshipValue(i, vnfCtx, "vserver", "tenant.tenant-id", "vnfInfo");
- String cloudOwner = getRelationshipValue(i, vnfCtx, "vserver", "cloud-region.cloud-owner", "vnfInfo");
+ String vserverId = getRelationshipValue(i, vnfCtx, PARAM_VSERVER, "vserver.vserver-id", PARAM_VNF_INFO);
+ String tenantId = getRelationshipValue(i, vnfCtx, PARAM_VSERVER, "tenant.tenant-id", PARAM_VNF_INFO);
+ String cloudOwner = getRelationshipValue(i, vnfCtx, PARAM_VSERVER, "cloud-region.cloud-owner",
+ PARAM_VNF_INFO);
String cloudRegionId =
- getRelationshipValue(i, vnfCtx, "vserver", "cloud-region.cloud-region-id", "vnfInfo");
+ getRelationshipValue(i, vnfCtx, PARAM_VSERVER, "cloud-region.cloud-region-id", PARAM_VNF_INFO);
if (vserverId != null) {
log.info("VSERVER KEYS " + vserverId + " " + tenantId + " " + cloudOwner + " " + cloudRegionId);
String vnfPrefix = prefix + "vm[" + vmCount + "].";
- ctx.setAttribute(vnfPrefix + "vserver-id", vserverId);
- ctx.setAttribute(vnfPrefix + "tenant-id", tenantId);
- ctx.setAttribute(vnfPrefix + "cloud-owner", cloudOwner);
- ctx.setAttribute(vnfPrefix + "cloud-region-id", cloudRegionId);
+ ctx.setAttribute(vnfPrefix + ATTR_VSERVER_ID, vserverId);
+ ctx.setAttribute(vnfPrefix + ATTR_TENANT_ID, tenantId);
+ ctx.setAttribute(vnfPrefix + ATTR_CLOUD_OWNER, cloudOwner);
+ ctx.setAttribute(vnfPrefix + ATTR_CLOUD_REGION_ID, cloudRegionId);
vmCount++;
}
}
@@ -102,80 +128,77 @@ public class AaiService {
log.info("VMCOUNT FROM VNF INFO " + ctx.getAttribute(prefix + "vm-count"));
}
- public void getVMInfo(Map<String, String> params, SvcLogicContext ctx) throws Exception {
- log.info("Received getVmInfo call with params : " + params);
- String prefix = params.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
- prefix = StringUtils.isNotBlank(prefix) ? (prefix + ".") : "";
- int vnfcCount = 0;
- ctx.setAttribute(prefix + "vm.vnfc-count", String.valueOf(vnfcCount)); // Incase no vnfcs are found
- String vserverId = params.get("vserverId");
- if (StringUtils.isBlank(vserverId)) {
- throw new Exception("VServerId is missing");
- }
- String tenantId = params.get("tenantId");
- if (StringUtils.isBlank(tenantId)) {
- throw new Exception("TenantId is missing");
- }
- String cloudOwner = params.get("cloudOwner");
- if (StringUtils.isBlank(cloudOwner)) {
- throw new Exception("Cloud Owner is missing");
- }
- String cloudRegionId = params.get("cloudRegionId");
- if (StringUtils.isBlank(cloudRegionId)) {
- throw new Exception("Cloud region Id is missing");
- }
- String resourceKey = "vserver.vserver-id = '" + vserverId + "' AND tenant.tenant-id = '" + tenantId
- + "' AND cloud-region.cloud-owner = '" + cloudOwner + "' AND cloud-region.cloud-region-id = '"
- + cloudRegionId + "'";
- String queryPrefix = "vmInfo";
- String resourceType = "vserver";
- SvcLogicContext vmCtx = readResource(resourceKey, queryPrefix, resourceType);
+ public void getVMInfo(Map<String, String> params, SvcLogicContext ctx)
+ throws SvcLogicException {
+
+ try {
+ log.info("Received getVmInfo call with params : " + params);
+ String prefix = params.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
+ prefix = StringUtils.isNotBlank(prefix) ? (prefix + ".") : "";
+ int vnfcCount = 0;
+ ctx.setAttribute(prefix + ATTR_VNFC_COUNT, String.valueOf(vnfcCount)); // In case no vnfcs are found
+
+ VServerInfo vServerInfo = new VServerInfo(params);
+
+ String resourceKey =
+ "vserver.vserver-id = '" + vServerInfo.getVserverId() + "' AND tenant.tenant-id = '" + vServerInfo
+ .getTenantId()
+ + "' AND cloud-region.cloud-owner = '" + vServerInfo.getCloudOwner()
+ + "' AND cloud-region.cloud-region-id = '"
+ + vServerInfo.getCloudRegionId() + "'";
+
+ SvcLogicContext vmCtx = readResource(resourceKey, PARAM_VM_INFO, PARAM_VSERVER);
+ ctx.setAttribute(prefix + "vm.prov-status", vmCtx.getAttribute("vmInfo.prov-status"));
+ ctx.setAttribute(prefix + "vm.vserver-name", vmCtx.getAttribute("vmInfo.vserver-name"));
+
+ String relLen = vmCtx.getAttribute("vmInfo.relationship-list.relationship_length");
+ int relationshipLength = 0;
+ if (relLen != null) {
+ relationshipLength = Integer.parseInt(relLen);
+ }
+ log.info("RELLEN" + relationshipLength);
+ for (int i = 0; i < relationshipLength; i++) {
+ String vfModuleId = getRelationshipValue(i, vmCtx, "vf-module", "vf-module.vf-module-id",
+ PARAM_VM_INFO);
+ if (vfModuleId != null) {
+ ctx.setAttribute(prefix + "vm.vf-module-id", vfModuleId);
+ }
- ctx.setAttribute(prefix + "vm.prov-status", vmCtx.getAttribute("vmInfo.prov-status"));
- ctx.setAttribute(prefix + "vm.vserver-name", vmCtx.getAttribute("vmInfo.vserver-name"));
+ String vnfcName = getRelationshipValue(i, vmCtx, "vnfc", "vnfc.vnfc-name", PARAM_VM_INFO);
+ if (vnfcName != null) {
+ ctx.setAttribute(prefix + "vm.vnfc[" + vnfcCount + "].vnfc-name", vnfcName);
+ vnfcCount++;
+ }
- String relLen = vmCtx.getAttribute("vmInfo.relationship-list.relationship_length");
- int relationshipLength = 0;
- if (relLen != null) {
- relationshipLength = Integer.parseInt(relLen);
+ } // relationshipLength
+ ctx.setAttribute(prefix + ATTR_VNFC_COUNT, String.valueOf(vnfcCount));
+ log.info("VSERVERNAME " + ctx.getAttribute(prefix + "vm.vserver-name") + " HAS NUM VNFCS = "
+ + ctx.getAttribute(prefix + ATTR_VNFC_COUNT));
+ } catch (Exception e) {
+ log.error("An error occurred when fetching Vm info", e);
+ throw new SvcLogicException("Failed to fetch VM info", e);
}
- log.info("RELLEN" + relationshipLength);
- for (int i = 0; i < relationshipLength; i++) {
- String vfModuleId = getRelationshipValue(i, vmCtx, "vf-module", "vf-module.vf-module-id", "vmInfo");
- if (vfModuleId != null)
- ctx.setAttribute(prefix + "vm.vf-module-id", vfModuleId);
-
- String vnfcName = getRelationshipValue(i, vmCtx, "vnfc", "vnfc.vnfc-name", "vmInfo");
- if (vnfcName != null) {
- ctx.setAttribute(prefix + "vm.vnfc[" + vnfcCount + "].vnfc-name", vnfcName);
- vnfcCount++;
- }
-
- } // relationshipLength
- ctx.setAttribute(prefix + "vm.vnfc-count", String.valueOf(vnfcCount));
- log.info("VSERVERNAME " + ctx.getAttribute(prefix + "vm.vserver-name") + " HAS NUM VNFCS = "
- + ctx.getAttribute(prefix + "vm.vnfc-count"));
}
private String getRelationshipValue(int i, SvcLogicContext ctx, String relatedTo, String relationshipKey,
- String prefix) throws Exception {
+ String prefix) {
- if (relatedTo.equals(ctx.getAttribute(prefix + ".relationship-list.relationship[" + i + "].related-to"))) {
+ if (relatedTo.equals(ctx.getAttribute(prefix + STR_RELATIONSHIP_LIST + i + "].related-to"))) {
log.info("RELATEDTO " + relatedTo);
int relationshipDataLength = 0;
String relDataLen =
- ctx.getAttribute(prefix + ".relationship-list.relationship[" + i + "].relationship-data_length");
+ ctx.getAttribute(prefix + STR_RELATIONSHIP_LIST + i + "].relationship-data_length");
if (relDataLen != null) {
relationshipDataLength = Integer.parseInt(relDataLen);
}
for (int j = 0; j < relationshipDataLength; j++) {
- String key = ctx.getAttribute(prefix + ".relationship-list.relationship[" + i + "].relationship-data["
- + j + "].relationship-key");
+ String key = ctx.getAttribute(prefix + STR_RELATIONSHIP_LIST + i + "].relationship-data["
+ + j + "].relationship-key");
- String value = ctx.getAttribute(prefix + ".relationship-list.relationship[" + i + "].relationship-data["
- + j + "].relationship-value");
+ String value = ctx.getAttribute(prefix + STR_RELATIONSHIP_LIST + i + "].relationship-data["
+ + j + "].relationship-value");
log.info("GENERIC KEY " + key);
log.info("GENERIC VALUE " + value);
@@ -190,7 +213,8 @@ public class AaiService {
return null;
}
- public void getVnfcInfo(Map<String, String> params, SvcLogicContext ctx) throws Exception {
+ public void getVnfcInfo(Map<String, String> params, SvcLogicContext ctx)
+ throws AaiServiceInternalException, SvcLogicException {
log.info("Received getVnfc call with params : " + params);
String prefix = params.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
@@ -198,13 +222,11 @@ public class AaiService {
String vnfcName = params.get("vnfcName");
if (StringUtils.isBlank(vnfcName)) {
- throw new Exception("Vnfc Name is missing");
+ throw new AaiServiceInternalException("Vnfc Name is missing");
}
- String resourceKey = "vnfc.vnfc-name = '" + vnfcName + "'";
- String queryPrefix = "vnfcInfo";
- String resourceType = "vnfc";
- SvcLogicContext vnfcCtx = readResource(resourceKey, queryPrefix, resourceType);
+ String resourceKey = STR_VNFC_NAME + vnfcName + "'";
+ SvcLogicContext vnfcCtx = readResource(resourceKey, "vnfcInfo", "vnfc");
// Changes for US 315820 for 1710 vnfc-type renamed to nfc-function,vnfc-function-code renamed to
// nfc-naming-code
@@ -216,8 +238,9 @@ public class AaiService {
}
- public void insertVnfcs(Map<String, String> params, SvcLogicContext ctx, int vnfcRefLen, int vmCount, String vfModuleIdFromRequest)
- throws Exception {
+ public void insertVnfcs(Map<String, String> params, SvcLogicContext ctx, int vnfcRefLen, int vmCount,
+ String vfModuleIdFromRequest)
+ throws AaiServiceInternalException, SvcLogicException {
log.info("Received insertVnfcs call with params : " + params);
String prefix = params.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
@@ -229,41 +252,42 @@ public class AaiService {
String aaiRefKey = prefix + "vm[" + i + "].";
//ConfigScaleOut - Do not process vms that are not associated with vfmodule id if vfmodule id is present
- if (StringUtils.isNotBlank(vfModuleIdFromRequest)){
- String vmVfModuleId = ctx.getAttribute(aaiRefKey+"vf-module-id");
- log.info("insertVnfcs():::vfModule for vm is="+vmVfModuleId);
- if (StringUtils.isBlank(vmVfModuleId) || !StringUtils.equalsIgnoreCase(vmVfModuleId,vfModuleIdFromRequest)) {
+ if (StringUtils.isNotBlank(vfModuleIdFromRequest)) {
+ String vmVfModuleId = ctx.getAttribute(aaiRefKey + "vf-module-id");
+ log.info("insertVnfcs():::vfModule for vm is=" + vmVfModuleId);
+ if (StringUtils.isBlank(vmVfModuleId) || !StringUtils
+ .equalsIgnoreCase(vmVfModuleId, vfModuleIdFromRequest)) {
continue;
}
}
- log.info("VNFCNAME IN INSERTVNFCS " + ctx.getAttribute(aaiRefKey + "vnfc-name"));
- String vnfcNameAAI = ctx.getAttribute(aaiRefKey + "vnfc-name");
+ log.info(QUERY_STR_VNFC_NAME + ctx.getAttribute(aaiRefKey + ATTR_VNFC_NAME));
+ String vnfcNameAAI = ctx.getAttribute(aaiRefKey + ATTR_VNFC_NAME);
// Get Vnfc_reference data from the table
- String vnfcRefKey = "vnfcReference[" + vnfcRefIndx + "].";
+ String vnfcRefKey = STR_VNFC_REF + vnfcRefIndx + "].";
- log.info("VNFCREFKEY " + vnfcRefKey);
- log.info("AAIREFKEY " + aaiRefKey);
+ log.info(STR_VNFC_REF_KEY + vnfcRefKey);
+ log.info(STR_AAI_REF_KEY + aaiRefKey);
String groupNotationType = ctx.getAttribute(vnfcRefKey + "GROUP-NOTATION-TYPE");
String groupNotationValue = ctx.getAttribute(vnfcRefKey + "GROUP-NOTATION-VALUE");
String vnfcType = ctx.getAttribute(vnfcRefKey + "VNFC-TYPE");
- String vnfcFuncCode = ctx.getAttribute(vnfcRefKey + "VNFC-FUNCTION-CODE");
+ String vnfcFuncCode = ctx.getAttribute(vnfcRefKey + ATTR_VNFC_FUNC_CODE);
String populateIpAddressV4OamVip = ctx.getAttribute(vnfcRefKey + "IPADDRESS-V4-OAM-VIP");
// Get vnfc Data to be added
- String vserverName = ctx.getAttribute(aaiRefKey + "vserver-name");
+ String vserverName = ctx.getAttribute(aaiRefKey + ATTR_VSERVER_NAME);
String vnfcName = vserverName + vnfcFuncCode + "001";
String groupNotation = getGroupNotation(groupNotationType, groupNotationValue, vnfcName, vserverName,
- prefix, ctx, vnfcType, vnfcFuncCode, vmCount);
+ prefix, ctx, vnfcType, vnfcFuncCode, vmCount);
String ipAddressV4OamVip = null;
if ("Y".equals(populateIpAddressV4OamVip)) {
ipAddressV4OamVip = ctx.getAttribute("vnf-host-ip-address"); // from input
}
Map<String, String> vnfcParams =
- populateVnfcParams(ctx, aaiRefKey, ipAddressV4OamVip, groupNotation, vnfcType, vnfcFuncCode);
+ populateVnfcParams(ctx, aaiRefKey, ipAddressV4OamVip, groupNotation, vnfcType, vnfcFuncCode);
log.info("Vnfc name from AAI: " + vnfcNameAAI);
log.info("Vnfc name generated: " + vnfcName);
@@ -279,38 +303,36 @@ public class AaiService {
addVnfc(vnfcName, vnfcParams, prefix);
// Add VNFC Info to context for current added VNFC
- ctx.setAttribute(aaiRefKey + "vnfc-name", vnfcName);
+ ctx.setAttribute(aaiRefKey + ATTR_VNFC_NAME, vnfcName);
ctx.setAttribute(aaiRefKey + "vnfc-type", vnfcType);
ctx.setAttribute(aaiRefKey + "vnfc-function-code", vnfcFuncCode);
ctx.setAttribute(aaiRefKey + "group-notation", groupNotation);
}
}
- public List<String> getVnfcData(Map<String, String> params, SvcLogicContext ctx, int vnfcRefLen, int vmCount)
- throws Exception {
+ public List<String> getVnfcData(Map<String, String> params, SvcLogicContext ctx, int vnfcRefLen, int vmCount) {
String prefix = params.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
prefix = StringUtils.isNotBlank(prefix) ? (prefix + ".") : "";
- List<String> vnfcNames = new ArrayList<String>();
+ List<String> vnfcNames = new ArrayList<>();
int vnfcRefIndx = -1;
for (int i = 0; i < vmCount; i++) {
String aaiRefKey = prefix + "vm[" + i + "].";
- log.info("VNFCNAME IN INSERTVNFCS " + ctx.getAttribute(aaiRefKey + "vnfc-name"));
- if (ctx.getAttribute(aaiRefKey + "vnfc-name") != null) {
+ log.info(QUERY_STR_VNFC_NAME + ctx.getAttribute(aaiRefKey + ATTR_VNFC_NAME));
+ if (ctx.getAttribute(aaiRefKey + ATTR_VNFC_NAME) != null) {
continue;
} else {
vnfcRefIndx++;
}
- String vnfcRefKey = "vnfcReference[" + vnfcRefIndx + "].";
- log.info("VNFCREFKEY " + vnfcRefKey);
- log.info("AAIREFKEY " + aaiRefKey);
- String vnfcFuncCode = ctx.getAttribute(vnfcRefKey + "VNFC-FUNCTION-CODE");
+ String vnfcRefKey = STR_VNFC_REF + vnfcRefIndx + "].";
+ log.info(STR_VNFC_REF_KEY + vnfcRefKey);
+ log.info(STR_AAI_REF_KEY + aaiRefKey);
+ String vnfcFuncCode = ctx.getAttribute(vnfcRefKey + ATTR_VNFC_FUNC_CODE);
// Get vnfc Data to be added
- String vserverName = ctx.getAttribute(aaiRefKey + "vserver-name");
+ String vserverName = ctx.getAttribute(aaiRefKey + ATTR_VSERVER_NAME);
String vnfcName = vserverName + vnfcFuncCode + "001";
-
vnfcNames.add(vnfcName);
}
@@ -318,75 +340,78 @@ public class AaiService {
}
private Map<String, String> populateVnfcParams(SvcLogicContext ctx, String aaiRefKey, String ipAddressV4OamVip,
- String groupNotation, String vnfcType, String vnfcFuncCode) throws Exception {
+ String groupNotation, String vnfcType, String vnfcFuncCode) {
- Map<String, String> vnfcParams = new HashMap<String, String>();
+ Map<String, String> vnfcParams = new HashMap<>();
// Changes for vnfc-type renamed to nfc-function,vnfc-function-code renamed to
// nfc-naming-code
vnfcParams.put("nfc-naming-code", vnfcFuncCode);
vnfcParams.put("nfc-function", vnfcType);
vnfcParams.put("ipaddress-v4-oam-vip", ipAddressV4OamVip);
- vnfcParams.put("prov-status", "NVTPROV");
+ vnfcParams.put(PARAM_PROV_STATUS, PARAM_VAL_NVTPROV);
vnfcParams.put("orchestration-status", "CONFIGURED");
vnfcParams.put("in-maint", "false");
vnfcParams.put("is-closed-loop", "false");
vnfcParams.put("group-notation", groupNotation);
- vnfcParams.put("relationship-list.relationship[0].related-to", "vserver");
+ vnfcParams.put("relationship-list.relationship[0].related-to", PARAM_VSERVER);
vnfcParams.put("relationship-list.relationship[0].relationship-data[0].relationship-key", "vserver.vserver-id");
vnfcParams.put("relationship-list.relationship[0].relationship-data[0].relationship-value",
- ctx.getAttribute(aaiRefKey + "vserver-id"));
+ ctx.getAttribute(aaiRefKey + ATTR_VSERVER_ID));
vnfcParams.put("relationship-list.relationship[0].relationship-data[1].relationship-key", "tenant.tenant-id");
vnfcParams.put("relationship-list.relationship[0].relationship-data[1].relationship-value",
- ctx.getAttribute(aaiRefKey + "tenant-id"));
+ ctx.getAttribute(aaiRefKey + ATTR_TENANT_ID));
vnfcParams.put("relationship-list.relationship[0].relationship-data[2].relationship-key",
- "cloud-region.cloud-owner");
+ "cloud-region.cloud-owner");
vnfcParams.put("relationship-list.relationship[0].relationship-data[2].relationship-value",
- ctx.getAttribute(aaiRefKey + "cloud-owner"));
+ ctx.getAttribute(aaiRefKey + ATTR_CLOUD_OWNER));
vnfcParams.put("relationship-list.relationship[0].relationship-data[3].relationship-key",
- "cloud-region.cloud-region-id");
+ "cloud-region.cloud-region-id");
vnfcParams.put("relationship-list.relationship[0].relationship-data[3].relationship-value",
- ctx.getAttribute(aaiRefKey + "cloud-region-id"));
- vnfcParams.put("relationship-list.relationship[1].related-to", "generic-vnf");
+ ctx.getAttribute(aaiRefKey + ATTR_CLOUD_REGION_ID));
+ vnfcParams.put("relationship-list.relationship[1].related-to", PARAM_GENERIC_VNF);
vnfcParams.put("relationship-list.relationship[1].relationship-data[0].relationship-key", "generic-vnf.vnf-id");
vnfcParams.put("relationship-list.relationship[1].relationship-data[0].relationship-value",
- ctx.getAttribute("vnf-id"));
+ ctx.getAttribute(ATTR_VNF_ID));
vnfcParams.put("relationship-list.relationship[2].related-to", "vf-module");
vnfcParams.put("relationship-list.relationship[2].relationship-data[0].relationship-key", "generic-vnf.vnf-id");
vnfcParams.put("relationship-list.relationship[2].relationship-data[0].relationship-value",
- ctx.getAttribute("vnf-id"));
+ ctx.getAttribute(ATTR_VNF_ID));
vnfcParams.put("relationship-list.relationship[2].relationship-data[1].relationship-key",
- "vf-module.vf-module-id");
+ "vf-module.vf-module-id");
vnfcParams.put("relationship-list.relationship[2].relationship-data[1].relationship-value",
- ctx.getAttribute(aaiRefKey + "vf-module-id"));
+ ctx.getAttribute(aaiRefKey + "vf-module-id"));
return vnfcParams;
}
- public void addVnfc(String vnfcName, Map<String, String> params, String prefix) throws Exception {
+ public void addVnfc(String vnfcName, Map<String, String> params, String prefix)
+ throws AaiServiceInternalException, SvcLogicException {
+
log.info("Received addVnfc call with vnfcName : " + vnfcName);
log.info("Received addVnfc call with params : " + params);
- String resourceKey = "vnfc.vnfc-name = '" + vnfcName + "'";
+ String resourceKey = STR_VNFC_NAME + vnfcName + "'";
log.info("Received addVnfc call with resourceKey : " + resourceKey);
SvcLogicContext vnfcCtx = new SvcLogicContext();
SvcLogicResource.QueryStatus response =
- aaiClient.save("vnfc", true, false, resourceKey, params, prefix, vnfcCtx);
+ aaiClient.save("vnfc", true, false, resourceKey, params, prefix, vnfcCtx);
if (SvcLogicResource.QueryStatus.SUCCESS.equals(response)) {
log.info("Added VNFC SUCCESSFULLY " + vnfcName);
} else if (SvcLogicResource.QueryStatus.FAILURE.equals(response)) {
- throw new Exception("VNFC Add failed for for vnfc_name " + vnfcName);
+ throw new AaiServiceInternalException("VNFC Add failed for for vnfc_name " + vnfcName);
}
}
public String getGroupNotation(String groupNotationType, String groupNotationValue, String vnfcName,
- String vserverName, String prefix, SvcLogicContext ctx, String vnfcRefVnfcType, String vnfcFuncCode, int vmCount) throws Exception {
+ String vserverName, String prefix, SvcLogicContext ctx, String vnfcRefVnfcType, String vnfcFuncCode,
+ int vmCount) {
- String grpNotation = null;
+ String groupNotation = null;
if ("fixed-value".equals(groupNotationType)) {
- grpNotation = groupNotationValue;
+ groupNotation = groupNotationValue;
} else if ("first-vnfc-name".equals(groupNotationType)) {
/*
@@ -407,13 +432,7 @@ public class AaiService {
log.info("RETURNED FIRSTVNFCNAME" + tmpVnfcName);
log.info("CURRENTVNFCNAME" + vnfcName);
- if (tmpVnfcName == null) {
- log.info("CURRENTVNFCNAME" + vnfcName);
- // No Vnfcs currently exist. Use Current vnfcName
- grpNotation = vnfcName + groupNotationValue;
- } else {
- grpNotation = tmpVnfcName + groupNotationValue;
- }
+ groupNotation = resolveGroupNotation(groupNotationValue, vnfcName, tmpVnfcName);
} else if ("relative-value".equals(groupNotationType)) {
/*
@@ -427,11 +446,10 @@ public class AaiService {
// next and same cant be defined for first VM. if next will not generate grpNotation if Prior is not a
// number
- String tmpVserverName = null;
+ String tmpVserverName;
if (vserverName != null) {
String vmNamePrefix = vserverName.substring(0, vserverName.length() - 3);
-
String lastThreeChars = vserverName.substring(vserverName.length() - 3);
if (NumberUtils.isDigits(lastThreeChars)) {
@@ -443,56 +461,69 @@ public class AaiService {
tmpVserverName = vmNamePrefix + formatted;
String priorGroupNotation = getGroupNotationForVServer(ctx, prefix, tmpVserverName);
-
- if ("same".equals(groupNotationValue)) {
- grpNotation = priorGroupNotation;
- } else if ("next".equals(groupNotationValue)) {
- if (priorGroupNotation != null && NumberUtils.isDigits(priorGroupNotation)) {
- int nextGrpNotation = Integer.parseInt(priorGroupNotation) + 1;
- grpNotation = String.valueOf(nextGrpNotation);
- }
- }
+ groupNotation = resolveGroupNotation(groupNotationValue, priorGroupNotation);
}
}
+ } else if ("existing-value".equals(groupNotationType)) {
+ /* This is a new value being added. Find the existing vnfc records in A&AI inventory with the same vnfc-function code as the value in vnfc_reference table.
+ * Verify that the group-notation value is the same for all such records found in inventory.
+ * if all records do not have the same group-notation value, write the new vnfc record to A&AI inventory without a group-notation value and continue to the next VM in the vnfc_reference table. A 501 intermediate error message should be sent after all new VNFC records have been added to A&AI.
+ * If all records match, use the same group-notation value for the new vnfc record as found in the existing vnfc records.
+ */
+ groupNotation = getGroupNotationForExistigValue(ctx, prefix, vnfcFuncCode, vmCount);
+ }
+
+ log.info("RETURNED GROUPNOTATION " + groupNotation);
+ return groupNotation;
+ }
+
+ private String resolveGroupNotation(String groupNotationValue, String vnfcName, String tmpVnfcName) {
+ if (tmpVnfcName == null) {
+ log.info("CURRENTVNFCNAME" + vnfcName);
+ // No Vnfcs currently exist. Use Current vnfcName
+ return vnfcName + groupNotationValue;
+ } else {
+ return tmpVnfcName + groupNotationValue;
+ }
+ }
+
+ private String resolveGroupNotation(String groupNotationValue, String priorGroupNotation) {
+ if ("same".equals(groupNotationValue)) {
+ return priorGroupNotation;
+ } else if ("next".equals(groupNotationValue) && priorGroupNotation != null
+ && NumberUtils.isDigits(priorGroupNotation)) {
+
+ int nextGrpNotation = Integer.parseInt(priorGroupNotation) + 1;
+ return String.valueOf(nextGrpNotation);
}
- else if ("existing-value".equals(groupNotationType)) {
- /* This is a new value being added. Find the existing vnfc records in A&AI inventory with the same vnfc-function code as the value in vnfc_reference table.
- * Verify that the group-notation value is the same for all such records found in inventory.
- * if all records do not have the same group-notation value, write the new vnfc record to A&AI inventory without a group-notation value and continue to the next VM in the vnfc_reference table. A 501 intermediate error message should be sent after all new VNFC records have been added to A&AI.
- If all records match, use the same group-notation value for the new vnfc record as found in the existing vnfc records.
-*/
- grpNotation = getGroupNotationForExistigValue(ctx, prefix, vnfcFuncCode, vmCount);
- }
-
- log.info("RETURNED GROUPNOTATION " + grpNotation);
- return grpNotation;
+ return null;
}
- public String getGroupNotationForExistigValue(SvcLogicContext ctx, String prefix, String vnfcFuncCode, int vmCount) {
+ public String getGroupNotationForExistigValue(SvcLogicContext ctx, String prefix, String vnfcFuncCode,
+ int vmCount) {
String vfModuleId = ctx.getAttribute("req-vf-module-id"); //Coming from request-params
- boolean first=true;
- String aaiGroupNotationValue=null;
- for (int i=0;i<vmCount;i++ )
- {
- String ind = "tmp.vnfInfo.vm["+i+"].";
- String aaiFuncCode = ctx.getAttribute(ind+"vnfc-function-code");
- String aaiGroupNotation = ctx.getAttribute(ind+"group-notation");
- String aaiVfModuleId = ctx.getAttribute(ind+"vf-module-id");
-
- log.info("getGroupNotationForExistigValue()::: vfModuleId="+vfModuleId+", aaiFuncCode="+aaiFuncCode
- +", aaiGroupNotation="+aaiGroupNotation+",aaiVfMOduleId="+aaiVfModuleId);
+ boolean first = true;
+ String aaiGroupNotationValue = null;
+ for (int i = 0; i < vmCount; i++) {
+ String ind = "tmp.vnfInfo.vm[" + i + "].";
+ String aaiFuncCode = ctx.getAttribute(ind + "vnfc-function-code");
+ String aaiGroupNotation = ctx.getAttribute(ind + "group-notation");
+ String aaiVfModuleId = ctx.getAttribute(ind + "vf-module-id");
+
+ log.info("getGroupNotationForExistigValue()::: vfModuleId=" + vfModuleId + ", aaiFuncCode=" + aaiFuncCode
+ + ", aaiGroupNotation=" + aaiGroupNotation + ",aaiVfMOduleId=" + aaiVfModuleId);
if (StringUtils.isNotBlank(aaiFuncCode) && aaiFuncCode.equals(vnfcFuncCode) &&
- (StringUtils.isNotBlank(vfModuleId) && StringUtils.isNotBlank(aaiVfModuleId) && aaiVfModuleId.equals(vfModuleId))) {
- if (null==aaiGroupNotationValue && first) {
+ (StringUtils.isNotBlank(vfModuleId) && StringUtils.isNotBlank(aaiVfModuleId) && aaiVfModuleId
+ .equals(vfModuleId))) {
+ if (null == aaiGroupNotationValue && first) {
if (null == aaiGroupNotation) {//Return if null
return null;
}
- aaiGroupNotationValue = ctx.getAttribute(ind+"group-notation");
- first=false;
- }
- else {
- if (!StringUtils.equals(aaiGroupNotationValue, ctx.getAttribute(ind+"group-notation"))) {
+ aaiGroupNotationValue = ctx.getAttribute(ind + "group-notation");
+ first = false;
+ } else {
+ if (!StringUtils.equals(aaiGroupNotationValue, ctx.getAttribute(ind + "group-notation"))) {
log.info("Values are different, returning null");
return null;
}
@@ -511,7 +542,7 @@ public class AaiService {
return null;
}
- int vmCount = Integer.valueOf(vmCountStr);
+ int vmCount = Integer.parseInt(vmCountStr);
for (int i = 0; i < vmCount; i++) {
String tmpVserver = ctx.getAttribute(prefix + "vm[" + i + "].vserver-name");
@@ -520,19 +551,16 @@ public class AaiService {
return ctx.getAttribute(prefix + "vm[" + i + "].group-notation");
}
} // vmCount
-
return null;
}
public String getFirstVnfcNameForVnfcType(SvcLogicContext ctx, String prefix, String vnfcRefVnfcType) {
String vmCountStr = ctx.getAttribute(prefix + "vnf.vm-count");
-
if (vmCountStr == null) {
return null;
}
-
- int vmCount = Integer.valueOf(vmCountStr);
+ int vmCount = Integer.parseInt(vmCountStr);
for (int i = 0; i < vmCount; i++) {
String tmpvnfcType = ctx.getAttribute(prefix + "vm[" + i + "].vnfc-type");
@@ -544,57 +572,56 @@ public class AaiService {
return null;
}
- public void updateVServerStatus(Map<String, String> params, SvcLogicContext ctx, int vmCount) throws Exception {
+ public void updateVServerStatus(Map<String, String> params, SvcLogicContext ctx, int vmCount)
+ throws AaiServiceInternalException, SvcLogicException {
log.info("Received updateVServerStatus call with params : " + params);
String prefix = params.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
prefix = StringUtils.isNotBlank(prefix) ? (prefix + ".") : "";
- Map<String, String> vServerParams = new HashMap<String, String>();
+ Map<String, String> vServerParams = new HashMap<>();
// TODO - Should this just update prov-status or both? What about generic-vnf status? Will that be updated by
// Dispatcher?
- vServerParams.put("prov-status", "NVTPROV");
+ vServerParams.put(PARAM_PROV_STATUS, PARAM_VAL_NVTPROV);
for (int i = 0; i < vmCount; i++) {
String aaiRefKey = prefix + "vm[" + i + "].";
- log.info("VNFCNAME IN UpdateVServer " + ctx.getAttribute(aaiRefKey + "vnfc-name"));
+ log.info("VNFCNAME IN UpdateVServer " + ctx.getAttribute(aaiRefKey + ATTR_VNFC_NAME));
- if (ctx.getAttribute(aaiRefKey + "vnfc-name") != null) {
+ if (ctx.getAttribute(aaiRefKey + ATTR_VNFC_NAME) != null) {
continue;
}
- String resourceKey = "vserver.vserver-id = '" + ctx.getAttribute(aaiRefKey + "vserver-id") + "'"
- + " AND tenant.tenant-id = '" + ctx.getAttribute(aaiRefKey + "tenant-id") + "'"
- + " AND cloud-region.cloud-owner = '" + ctx.getAttribute(aaiRefKey + "cloud-owner") + "'"
- + " AND cloud-region.cloud-region-id = '" + ctx.getAttribute(aaiRefKey + "cloud-region-id") + "'";
+ String resourceKey = "vserver.vserver-id = '" + ctx.getAttribute(aaiRefKey + ATTR_VSERVER_ID) + "'"
+ + " AND tenant.tenant-id = '" + ctx.getAttribute(aaiRefKey + ATTR_TENANT_ID) + "'"
+ + " AND cloud-region.cloud-owner = '" + ctx.getAttribute(aaiRefKey + ATTR_CLOUD_OWNER) + "'"
+ + " AND cloud-region.cloud-region-id = '" + ctx.getAttribute(aaiRefKey + ATTR_CLOUD_REGION_ID) + "'";
- updateResource("vserver", resourceKey, vServerParams);
+ updateResource(PARAM_VSERVER, resourceKey, vServerParams);
}
}
- public void updateVnfStatus(Map<String, String> params, SvcLogicContext ctx) throws Exception {
+ public void updateVnfStatus(Map<String, String> params, SvcLogicContext ctx)
+ throws AaiServiceInternalException, SvcLogicException {
log.info("Received updateVnfStatus call with params : " + params);
- String prefix = params.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
-
- prefix = StringUtils.isNotBlank(prefix) ? (prefix + ".") : "";
-
- Map<String, String> vnfParams = new HashMap<String, String>();
+ Map<String, String> vnfParams = new HashMap<>();
// TODO - Should this just update prov-status or both? What about generic-vnf status? Will that be updated by
// Dispatcher?
- vnfParams.put("prov-status", "NVTPROV");
+ vnfParams.put(PARAM_PROV_STATUS, PARAM_VAL_NVTPROV);
- String resourceKey = "generic-vnf.vnf-id = '" + ctx.getAttribute("vnf-id") + "'";
+ String resourceKey = STR_VNF_ID + ctx.getAttribute(ATTR_VNF_ID) + "'";
- updateResource("generic-vnf", resourceKey, vnfParams);
+ updateResource(PARAM_GENERIC_VNF, resourceKey, vnfParams);
}
- public void updateResource(String resource, String resourceKey, Map<String, String> params) throws Exception {
+ public void updateResource(String resource, String resourceKey, Map<String, String> params)
+ throws AaiServiceInternalException, SvcLogicException {
log.info("Received updateResource call with Key : " + resourceKey);
@@ -605,27 +632,26 @@ public class AaiService {
log.info("Updated " + resource + " SUCCESSFULLY for " + resourceKey);
} else if (SvcLogicResource.QueryStatus.FAILURE.equals(response)) {
- throw new Exception(resource + " Update failed for " + resourceKey);
+ throw new AaiServiceInternalException(resource + " Update failed for " + resourceKey);
}
}
- public SvcLogicContext readResource(String query, String prefix, String resourceType) throws Exception {
+ public SvcLogicContext readResource(String query, String prefix, String resourceType)
+ throws AaiServiceInternalException, SvcLogicException {
SvcLogicContext resourceContext = new SvcLogicContext();
SvcLogicResource.QueryStatus response =
- aaiClient.query(resourceType, false, null, query, prefix, null, resourceContext);
+ aaiClient.query(resourceType, false, null, query, prefix, null, resourceContext);
log.info("AAIResponse: " + response.toString());
if (!SvcLogicResource.QueryStatus.SUCCESS.equals(response)) {
- throw new Exception("Error Retrieving " + resourceType + " from A&AI");
+ throw new AaiServiceInternalException("Error Retrieving " + resourceType + " from A&AI");
}
-
return resourceContext;
}
// Added for Backward Compatibility
-
public void checkAndUpdateVnfc(Map<String, String> params, SvcLogicContext ctx, int vnfcRefLen, int vmCount)
- throws Exception {
+ throws AaiServiceInternalException, SvcLogicException {
log.info("Received checkAndUpdateVnfcStatus call with params : " + params);
String prefix = params.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
@@ -635,41 +661,46 @@ public class AaiService {
for (int i = 0; i < vmCount; i++) {
String aaiRefKey = prefix + "vm[" + i + "].";
- log.info("VNFCNAME IN INSERTVNFCS " + aaiRefKey + "vnfc-name:" + ctx.getAttribute(aaiRefKey + "vnfc-name"));
+ log.info(QUERY_STR_VNFC_NAME + aaiRefKey + "vnfc-name:" + ctx.getAttribute(aaiRefKey + ATTR_VNFC_NAME));
- String vnfcNameAai = ctx.getAttribute(aaiRefKey + "vnfc-name");
+ String vnfcNameAai = ctx.getAttribute(aaiRefKey + ATTR_VNFC_NAME);
if (StringUtils.isNotBlank(vnfcNameAai)) {
// Get Vnfc_reference data
for (int vnfcRefIndx = 0; vnfcRefIndx < vnfcRefLen; vnfcRefIndx++) {
- String vnfcRefKey = "vnfcReference[" + vnfcRefIndx + "].";
+ String vnfcRefKey = STR_VNFC_REF + vnfcRefIndx + "].";
- log.info("VNFCREFKEY " + vnfcRefKey);
- log.info("AAIREFKEY " + aaiRefKey);
+ log.info(STR_VNFC_REF_KEY + vnfcRefKey);
+ log.info(STR_AAI_REF_KEY + aaiRefKey);
- String vnfcFuncCode = ctx.getAttribute(vnfcRefKey + "VNFC-FUNCTION-CODE");
- String vserverName = ctx.getAttribute(aaiRefKey + "vserver-name");
+ String vnfcFuncCode = ctx.getAttribute(vnfcRefKey + ATTR_VNFC_FUNC_CODE);
+ String vserverName = ctx.getAttribute(aaiRefKey + ATTR_VSERVER_NAME);
String vnfcNameReference = vserverName + vnfcFuncCode + "001";
-
- if (vnfcNameAai.equals(vnfcNameReference)) {
- updateVnfcStatus(vnfcNameAai, params, prefix);
- }
+ tryUpdateVnfcStatus(params, prefix, vnfcNameAai, vnfcNameReference);
}
}
}
}
- public void updateVnfcStatus(String vnfcName, Map<String, String> params, String prefix) throws Exception {
+ private void tryUpdateVnfcStatus(Map<String, String> params, String prefix, String vnfcNameAai,
+ String vnfcNameReference) throws AaiServiceInternalException, SvcLogicException {
+ if (vnfcNameAai.equals(vnfcNameReference)) {
+ updateVnfcStatus(vnfcNameAai, params, prefix);
+ }
+ }
+
+ public void updateVnfcStatus(String vnfcName, Map<String, String> params, String prefix)
+ throws AaiServiceInternalException, SvcLogicException {
log.info("Received updateVnfcStatus call with vnfcName : " + vnfcName);
log.info("Received updateVnfcStatus call with params : " + params);
- String resourceKey = "vnfc.vnfc-name = '" + vnfcName + "'";
+ String resourceKey = STR_VNFC_NAME + vnfcName + "'";
log.info("Received updateVnfcStatus call with resourceKey : " + resourceKey);
- Map<String, String> vnfcParams = new HashMap<String, String>();
- vnfcParams.put("prov-status", "NVTPROV");
+ Map<String, String> vnfcParams = new HashMap<>();
+ vnfcParams.put(PARAM_PROV_STATUS, PARAM_VAL_NVTPROV);
vnfcParams.put("orchestration-status", "CONFIGURED");
log.info("In updateVnfcStatus call with vnfcParams : " + vnfcParams);
@@ -679,22 +710,17 @@ public class AaiService {
log.info("End of updateVnfcStatus");
}
- public void updateVnfStatusWithOAMAddress(Map<String, String> params, SvcLogicContext ctx) throws Exception {
+ public void updateVnfStatusWithOAMAddress(Map<String, String> params, SvcLogicContext ctx)
+ throws AaiServiceInternalException, SvcLogicException {
log.info("Received updateVnfStatusWithOAMAddress call with params : " + params);
- String prefix = params.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
String ipAddress = ctx.getAttribute("vnf-host-ip-address");
log.debug("Vnf-host-ip-address" + ipAddress);
- prefix = StringUtils.isNotBlank(prefix) ? (prefix + ".") : "";
-
- Map<String, String> vnfParams = new HashMap<String, String>();
-
+ Map<String, String> vnfParams = new HashMap<>();
vnfParams.put("ipv4-oam-address", ipAddress);
-
- String resourceKey = "generic-vnf.vnf-id = '" + ctx.getAttribute("vnf-id") + "'";
-
- updateResource("generic-vnf", resourceKey, vnfParams);
+ String resourceKey = STR_VNF_ID + ctx.getAttribute(ATTR_VNF_ID) + "'";
+ updateResource(PARAM_GENERIC_VNF, resourceKey, vnfParams);
}
public void getVfModuleInfo(Map<String, String> params, SvcLogicContext vfModuleCtx) throws Exception {
@@ -705,14 +731,16 @@ public class AaiService {
String vnfId = params.get("vnfId");
String vfModuleId = params.get("vfModuleId");
String resourceKey = "generic-vnf.vnf-id = '" + vnfId +
- "' AND vf-module.vf-module-id = '" + vfModuleId + "'";
+ "' AND vf-module.vf-module-id = '" + vfModuleId + "'";
String queryPrefix = "vfModuleInfo";
String resourceType = "vf-module";
SvcLogicContext vfmCtx = readResource(resourceKey, queryPrefix, resourceType);
- String modelInvariantId=vfmCtx.getAttribute("vfModuleInfo.model-invariant-id");
- log.info("getVfModuleInfo():::modelInvariant="+modelInvariantId);
- vfModuleCtx.setAttribute(prefix+"vfModule.model-invariant-id", vfmCtx.getAttribute("vfModuleInfo.model-invariant-id"));
- vfModuleCtx.setAttribute(prefix+"vfModule.model-version-id", vfmCtx.getAttribute("vfModuleInfo.model-version-id"));
+ String modelInvariantId = vfmCtx.getAttribute("vfModuleInfo.model-invariant-id");
+ log.info("getVfModuleInfo():::modelInvariant=" + modelInvariantId);
+ vfModuleCtx.setAttribute(prefix + "vfModule.model-invariant-id",
+ vfmCtx.getAttribute("vfModuleInfo.model-invariant-id"));
+ vfModuleCtx
+ .setAttribute(prefix + "vfModule.model-version-id", vfmCtx.getAttribute("vfModuleInfo.model-version-id"));
log.info("End - getVfModuleInfo");
}
@@ -724,12 +752,12 @@ public class AaiService {
String modelInvariantId = modelParams.get("model-invariant-id");
String modelVersionId = modelParams.get("model-version-id");
String resourceKey = "model.model-invariant-id = '" + modelInvariantId +
- "' AND model-ver.model-version-id = '" + modelVersionId + "'";
+ "' AND model-ver.model-version-id = '" + modelVersionId + "'";
String queryPrefix = "modelInfo";
String resourceType = "model-ver";
SvcLogicContext vfmCtx = readResource(resourceKey, queryPrefix, resourceType);
- log.info("getModelVersionInfo():::modelname="+vfmCtx.getAttribute("modelInfo.model-name"));
- modelCtx.setAttribute(prefix+"vfModule.model-name", vfmCtx.getAttribute("modelInfo.model-name"));
+ log.info("getModelVersionInfo():::modelname=" + vfmCtx.getAttribute("modelInfo.model-name"));
+ modelCtx.setAttribute(prefix + "vfModule.model-name", vfmCtx.getAttribute("modelInfo.model-name"));
log.info("End - getModelVersionInfo");
}
diff --git a/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/aai/AaiServiceInternalException.java b/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/aai/AaiServiceInternalException.java
new file mode 100644
index 000000000..3deb53249
--- /dev/null
+++ b/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/aai/AaiServiceInternalException.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2018 Nokia Solutions and Networks
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.aai.client.aai;
+
+public class AaiServiceInternalException extends Exception{
+
+ public AaiServiceInternalException(String message) {
+ super(message);
+ }
+}
diff --git a/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/aai/MissingParameterException.java b/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/aai/MissingParameterException.java
new file mode 100644
index 000000000..5cfcb657a
--- /dev/null
+++ b/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/aai/MissingParameterException.java
@@ -0,0 +1,32 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2018 Nokia Solutions and Networks
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.aai.client.aai;
+
+public class MissingParameterException extends Exception {
+
+ public MissingParameterException(String message) {
+ super(message);
+ }
+}
diff --git a/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/aai/VServerInfo.java b/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/aai/VServerInfo.java
new file mode 100644
index 000000000..d2680a40c
--- /dev/null
+++ b/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/aai/VServerInfo.java
@@ -0,0 +1,74 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP : APPC
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Copyright (C) 2018 Nokia Solutions and Networks
+ * =============================================================================
+ * 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.
+ *
+ * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.appc.aai.client.aai;
+
+import java.util.Map;
+import org.apache.commons.lang3.StringUtils;
+
+public class VServerInfo {
+
+ private String vserverId;
+ private String tenantId;
+ private String cloudOwner;
+ private String cloudRegionId;
+
+ public VServerInfo(Map<String, String> params) throws MissingParameterException {
+ vserverId = params.get("vserverId");
+ if (StringUtils.isBlank(vserverId)) {
+ throw new MissingParameterException("VServerId is missing");
+ }
+
+ tenantId = params.get("tenantId");
+ if (StringUtils.isBlank(tenantId)) {
+ throw new MissingParameterException("TenantId is missing");
+ }
+
+ cloudOwner = params.get("cloudOwner");
+ if (StringUtils.isBlank(cloudOwner)) {
+ throw new MissingParameterException("Cloud Owner is missing");
+ }
+
+ cloudRegionId = params.get("cloudRegionId");
+ if (StringUtils.isBlank(cloudRegionId)) {
+ throw new MissingParameterException("Cloud region Id is missing");
+ }
+ }
+
+ public String getVserverId() {
+ return vserverId;
+ }
+
+ public String getTenantId() {
+ return tenantId;
+ }
+
+ public String getCloudOwner() {
+ return cloudOwner;
+ }
+
+ public String getCloudRegionId() {
+ return cloudRegionId;
+ }
+}
diff --git a/appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/aai/MockAaiService.java b/appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/aai/MockAaiService.java
index 724c8bf3b..6452883af 100644
--- a/appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/aai/MockAaiService.java
+++ b/appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/aai/MockAaiService.java
@@ -23,69 +23,55 @@
*/
package org.onap.appc.aai.client.aai;
-import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.commons.lang3.StringUtils;
-
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
-import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
-import org.onap.ccsdk.sli.core.sli.SvcLogicResource;
+import java.util.HashMap;
+import java.util.Map;
import org.onap.ccsdk.sli.adaptors.aai.AAIClient;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
public class MockAaiService extends AaiService {
-
+
//ONAP migration
-
+
private static final EELFLogger log = EELFManager.getInstance().getLogger(MockAaiService.class);
- private AAIClient aaiClient;
-
- public MockAaiService(AAIClient aaic) {
- super(aaic);
- }
-
-
- /*public MockAaiService() {
- super(new AAIClientMock());
- }*/
-
- public SvcLogicContext readResource(String query, String prefix, String resourceType) throws Exception {
- log.info("In MockRead Resource");
- SvcLogicContext resourceContext = new SvcLogicContext();
-
- //prefix = StringUtils.isNotBlank(prefix) ? (prefix+".") : "";
- if ( "generic-vnf".equals(resourceType) ) {
- populateGenericVnfContext(resourceContext, prefix);
- }
- else if("vserver".equals(resourceType) ) {
- populateVmContext(resourceContext, prefix);
- }
- else if("vnfc".equals(resourceType) ) {
- populateVnfcContext(resourceContext, prefix);
- }
-
-
- return resourceContext;
-
-
-
- }
-
- public void addVnfc(String vnfcName, Map<String, String> params, String prefix) throws Exception {
-
-
- if ( vnfcName.startsWith("ibcx")) {
- assertEquals("ibcxvm0002func0001", vnfcName);
-
-
- log.info("In AddVnfc " + vnfcName);
- Map<String, String> expectedParams = getExpectedParams();
+ private AAIClient aaiClient;
+
+ public MockAaiService(AAIClient aaic) {
+ super(aaic);
+ }
+
+ public SvcLogicContext readResource(String query, String prefix, String resourceType)
+ throws AaiServiceInternalException, SvcLogicException {
+ log.info("In MockRead Resource");
+ SvcLogicContext resourceContext = new SvcLogicContext();
+
+ //prefix = StringUtils.isNotBlank(prefix) ? (prefix+".") : "";
+ if ("generic-vnf".equals(resourceType)) {
+ populateGenericVnfContext(resourceContext, prefix);
+ } else if ("vserver".equals(resourceType)) {
+ populateVmContext(resourceContext, prefix);
+ } else if ("vnfc".equals(resourceType)) {
+ populateVnfcContext(resourceContext, prefix);
+ }
+
+ return resourceContext;
+
+
+ }
+
+ public void addVnfc(String vnfcName, Map<String, String> params, String prefix) {
+
+ if (vnfcName.startsWith("ibcx")) {
+ assertEquals("ibcxvm0002func0001", vnfcName);
+
+ log.info("In AddVnfc " + vnfcName);
+ Map<String, String> expectedParams = getExpectedParams();
/* for (Map.Entry<String, String> entry : params.entrySet()) {
@@ -96,137 +82,129 @@ public class MockAaiService extends AaiService {
log.info("key= " + key + "value = " + value );
}*/
- assertEquals(params, expectedParams);
- }
- }
-
-
- public void updateResource( String resource, String resourceKey, Map<String, String> params) throws Exception {
-
- Map<String, String> expectedParams = new HashMap<String, String>();
-
-
- expectedParams.put("prov-status", "NVTPROV");
- assertEquals(params, expectedParams);
-
- if ( "vserver".equals(resource)) {
-
- String key = "vserver.vserver-id = 'ibcx00000'" +
- " AND tenant.tenant-id = 'tenantId'" +
- " AND cloud-region.cloud-owner = 'cloudOwner'" +
- " AND cloud-region.cloud-region-id = 'cloudRegionId'";
-
- assertEquals(key, resourceKey);
- }
- else if ( "generic-vnf".equals(resource)) {
- assertEquals(resourceKey, "generic-vnf.vnf-id = 'ibcx000000'");
- }
- else
- fail("Invalid resource " + resource);
-
-
-
-
- }
-
- public Map<String, String> getExpectedParams() throws Exception {
- Map<String, String> vnfcParams = new HashMap<String, String>();
-
- vnfcParams.put("vnfc-function-code", "func0");
-
-
-
- vnfcParams.put("vnfc-type", "ssc0");
-
- vnfcParams.put("ipaddress-v4-oam-vip", "000.00.00.00");
-
- vnfcParams.put("prov-status", "NVTPROV");
- vnfcParams.put("orchestration-status", "CONFIGURED");
- vnfcParams.put("in-maint", "false");
- vnfcParams.put("is-closed-loop", "false");
- vnfcParams.put("group-notation","2");
-
-
- vnfcParams.put("relationship-list.relationship[0].related-to","vserver");
- vnfcParams.put("relationship-list.relationship[0].relationship-data[0].relationship-key","vserver.vserver-id");
- vnfcParams.put("relationship-list.relationship[0].relationship-data[0].relationship-value","ibcx00000");
-
-
- vnfcParams.put("relationship-list.relationship[0].relationship-data[1].relationship-key","tenant.tenant-id");
- vnfcParams.put("relationship-list.relationship[0].relationship-data[1].relationship-value","tenantId");
-
-
- vnfcParams.put("relationship-list.relationship[0].relationship-data[2].relationship-key","cloud-region.cloud-owner");
- vnfcParams.put("relationship-list.relationship[0].relationship-data[2].relationship-value","cloudOwner");
-
-
- vnfcParams.put("relationship-list.relationship[0].relationship-data[3].relationship-key","cloud-region.cloud-region-id");
- vnfcParams.put("relationship-list.relationship[0].relationship-data[3].relationship-value","cloudRegionId");
-
-
- vnfcParams.put("relationship-list.relationship[1].related-to","generic-vnf");
- vnfcParams.put("relationship-list.relationship[1].relationship-data[0].relationship-key","generic-vnf.vnf-id");
- vnfcParams.put("relationship-list.relationship[1].relationship-data[0].relationship-value","ibcx000000");
-
-
- vnfcParams.put("relationship-list.relationship[2].related-to","vf-module");
- vnfcParams.put("relationship-list.relationship[2].relationship-data[0].relationship-key","generic-vnf.vnf-id");
- vnfcParams.put("relationship-list.relationship[2].relationship-data[0].relationship-value","ibcx000000");
-
-
- vnfcParams.put("relationship-list.relationship[2].relationship-data[1].relationship-key","vf-module.vf-module-id");
- vnfcParams.put("relationship-list.relationship[2].relationship-data[1].relationship-value","vfModuleId");
-
- return vnfcParams;
+ assertEquals(params, expectedParams);
}
- public void populateVnfcContext(SvcLogicContext ctx, String prefix) {
- log.info("In populateVnfcContext " + prefix);
-
- ctx.setAttribute(prefix + ".vnfc-type", "vnfctype1");
- ctx.setAttribute(prefix + ".vnfc-function-code", "funccode1");
- ctx.setAttribute(prefix + ".group-notation", "grpnot1");
- }
-
- public void populateVmContext(SvcLogicContext ctx, String prefix) {
- log.info("In populateVmContext " + prefix);
-
- ctx.setAttribute(prefix + ".vserver-name", "ibcx0000000");
-
-
- ctx.setAttribute(prefix + ".relationship-list.relationship_length", "3");
-
- // Junk
- ctx.setAttribute(prefix + ".relationship-list.relationship[0].related-to", "test");
- ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data_length", "1");
- ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[0].relationship-key", "vnfc.vnfc-name");
- ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[0].relationship-value", "test");
-
-
-
- // VNFC
- ctx.setAttribute(prefix + ".relationship-list.relationship[1].related-to", "vnfc");
- ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data_length", "1");
- ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[0].relationship-key", "vnfc.vnfc-name");
- ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[0].relationship-value", "ibcx0001vm001vnfc1");
-
-
- // VFModule
-
- ctx.setAttribute(prefix + ".relationship-list.relationship[2].related-to", "vf-module");
- ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data_length", "1");
- ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[0].relationship-key", "vf-module.vf-module-id");
- ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[0].relationship-value", "vfModule1");
-
-
+ }
+
+
+ public void updateResource(String resource, String resourceKey, Map<String, String> params) {
+
+ Map<String, String> expectedParams = new HashMap<String, String>();
+
+ expectedParams.put("prov-status", "NVTPROV");
+ assertEquals(params, expectedParams);
+
+ if ("vserver".equals(resource)) {
+
+ String key = "vserver.vserver-id = 'ibcx00000'" +
+ " AND tenant.tenant-id = 'tenantId'" +
+ " AND cloud-region.cloud-owner = 'cloudOwner'" +
+ " AND cloud-region.cloud-region-id = 'cloudRegionId'";
+
+ assertEquals(key, resourceKey);
+ } else if ("generic-vnf".equals(resource)) {
+ assertEquals(resourceKey, "generic-vnf.vnf-id = 'ibcx000000'");
+ } else {
+ fail("Invalid resource " + resource);
}
- public void populateGenericVnfContext(SvcLogicContext ctx, String prefix) throws Exception {
-
- log.info("In populateGenericVnf " + prefix);
- ctx.setAttribute(prefix + ".vnf-name", "ibvcx0001");
- ctx.setAttribute(prefix + ".vnf-type", "vUSP-Metaswitch");
-
- ctx.setAttribute(prefix + ".relationship-list.relationship_length", "3");
+
+ }
+
+ public Map<String, String> getExpectedParams() {
+ Map<String, String> vnfcParams = new HashMap<String, String>();
+
+ vnfcParams.put("vnfc-function-code", "func0");
+
+ vnfcParams.put("vnfc-type", "ssc0");
+
+ vnfcParams.put("ipaddress-v4-oam-vip", "000.00.00.00");
+
+ vnfcParams.put("prov-status", "NVTPROV");
+ vnfcParams.put("orchestration-status", "CONFIGURED");
+ vnfcParams.put("in-maint", "false");
+ vnfcParams.put("is-closed-loop", "false");
+ vnfcParams.put("group-notation", "2");
+
+ vnfcParams.put("relationship-list.relationship[0].related-to", "vserver");
+ vnfcParams.put("relationship-list.relationship[0].relationship-data[0].relationship-key", "vserver.vserver-id");
+ vnfcParams.put("relationship-list.relationship[0].relationship-data[0].relationship-value", "ibcx00000");
+
+ vnfcParams.put("relationship-list.relationship[0].relationship-data[1].relationship-key", "tenant.tenant-id");
+ vnfcParams.put("relationship-list.relationship[0].relationship-data[1].relationship-value", "tenantId");
+
+ vnfcParams
+ .put("relationship-list.relationship[0].relationship-data[2].relationship-key", "cloud-region.cloud-owner");
+ vnfcParams.put("relationship-list.relationship[0].relationship-data[2].relationship-value", "cloudOwner");
+
+ vnfcParams.put("relationship-list.relationship[0].relationship-data[3].relationship-key",
+ "cloud-region.cloud-region-id");
+ vnfcParams.put("relationship-list.relationship[0].relationship-data[3].relationship-value", "cloudRegionId");
+
+ vnfcParams.put("relationship-list.relationship[1].related-to", "generic-vnf");
+ vnfcParams.put("relationship-list.relationship[1].relationship-data[0].relationship-key", "generic-vnf.vnf-id");
+ vnfcParams.put("relationship-list.relationship[1].relationship-data[0].relationship-value", "ibcx000000");
+
+ vnfcParams.put("relationship-list.relationship[2].related-to", "vf-module");
+ vnfcParams.put("relationship-list.relationship[2].relationship-data[0].relationship-key", "generic-vnf.vnf-id");
+ vnfcParams.put("relationship-list.relationship[2].relationship-data[0].relationship-value", "ibcx000000");
+
+ vnfcParams
+ .put("relationship-list.relationship[2].relationship-data[1].relationship-key", "vf-module.vf-module-id");
+ vnfcParams.put("relationship-list.relationship[2].relationship-data[1].relationship-value", "vfModuleId");
+
+ return vnfcParams;
+ }
+
+ public void populateVnfcContext(SvcLogicContext ctx, String prefix) {
+ log.info("In populateVnfcContext " + prefix);
+
+ ctx.setAttribute(prefix + ".vnfc-type", "vnfctype1");
+ ctx.setAttribute(prefix + ".vnfc-function-code", "funccode1");
+ ctx.setAttribute(prefix + ".group-notation", "grpnot1");
+ }
+
+ public void populateVmContext(SvcLogicContext ctx, String prefix) {
+ log.info("In populateVmContext " + prefix);
+
+ ctx.setAttribute(prefix + ".vserver-name", "ibcx0000000");
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship_length", "3");
+
+ // Junk
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].related-to", "test");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data_length", "1");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[0].relationship-key",
+ "vnfc.vnfc-name");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[0].relationship-value", "test");
+
+ // VNFC
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].related-to", "vnfc");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data_length", "1");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[0].relationship-key",
+ "vnfc.vnfc-name");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[0].relationship-value",
+ "ibcx0001vm001vnfc1");
+
+ // VFModule
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].related-to", "vf-module");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data_length", "1");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[0].relationship-key",
+ "vf-module.vf-module-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[0].relationship-value",
+ "vfModule1");
+
+
+ }
+
+ public void populateGenericVnfContext(SvcLogicContext ctx, String prefix) {
+
+ log.info("In populateGenericVnf " + prefix);
+ ctx.setAttribute(prefix + ".vnf-name", "ibvcx0001");
+ ctx.setAttribute(prefix + ".vnf-type", "vUSP-Metaswitch");
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship_length", "3");
/* // VM1
ctx.setAttribute(prefix + ".relationship-list.relationship[0].related-to", "vserver");
@@ -242,300 +220,266 @@ public class MockAaiService extends AaiService {
//ctx.setAttribute(prefix + ".relationship-list.relationship_length", "3");
-*/
- // VM1
- ctx.setAttribute(prefix + ".relationship-list.relationship[0].related-to", "vserver");
- ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data_length", "4");
- ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[0].relationship-key", "vserver.vserver-id");
- ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[0].relationship-value", "ibcx001vm001-id");
- ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[1].relationship-key", "tenant.tenant-id");
- ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[1].relationship-value", "sometenant");
- ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[2].relationship-key", "cloud-region.cloud-owner");
- ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[2].relationship-value", "ATTAIC");
- ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[3].relationship-key", "cloud-region.cloud-region-id");
- ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[3].relationship-value", "testcloudregionid");
-
-
- // VM2
- ctx.setAttribute(prefix + ".relationship-list.relationship[1].related-to", "vserver");
- ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data_length", "4");
- ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[0].relationship-key", "vserver.vserver-id");
- ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[0].relationship-value", "ibcx000000");
-
-
- ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[1].relationship-key", "tenant.tenant-id");
- ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[1].relationship-value", "sometenant");
-
- ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[2].relationship-key", "cloud-region.cloud-owner");
- ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[2].relationship-value", "ATTAIC");
-
- ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[3].relationship-key", "cloud-region.cloud-region-id");
- ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[3].relationship-value", "testcloudregionid");
-
-
- // Unrelated
- ctx.setAttribute(prefix + ".relationship-list.relationship[2].related-to", "junk");
-
- ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data_length", "4");
-
-
- ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[0].relationship-key", "test");
- ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[0].relationship-value", "ibcx000000");
-
-
- ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[1].relationship-key", "test1");
- ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[1].relationship-value", "sometenant");
-
- ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[2].relationship-key", "test2");
- ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[2].relationship-value", "ATTAIC");
-
- ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[3].relationship-key", "test3");
- ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[3].relationship-value", "testcloudregionid");
- }
-
-
-
- public void populateFirstVnfcData(SvcLogicContext ctx, String prefix) throws Exception {
-
-
-
- ctx.setAttribute(prefix + "vnf.vm-count", "4");
-
- ctx.setAttribute(prefix+ "vm[0].vnfc-type", "mmc");
- ctx.setAttribute(prefix+ "vm[0].vnfc-name", "vnfcname1");
-
- ctx.setAttribute(prefix+ "vm[1].vnfc-type", "mmc");
- ctx.setAttribute(prefix+ "vm[1].vnfc-name", "vnfcname2");
-
- ctx.setAttribute(prefix+ "vm[2].vnfc-type", "ssc");
- ctx.setAttribute(prefix+ "vm[2].vnfc-name", "vnfcname3");
-
- ctx.setAttribute(prefix+ "vm[3].vnfc-type", "ssc");
- ctx.setAttribute(prefix+ "vm[3].vnfc-name", "vnfcname4");
- }
-
-
-
- public void populateGroupNotation(SvcLogicContext ctx, String prefix) throws Exception {
-
-
-
- ctx.setAttribute(prefix + "vnf.vm-count", "5");
-
- ctx.setAttribute(prefix+ "vm[0].vserver-name", "ibcxvm0001");
- ctx.setAttribute(prefix+ "vm[0].group-notation", "grpNot1");
-
- ctx.setAttribute(prefix+ "vm[1].vserver-name", "ibcxvm0002");
- ctx.setAttribute(prefix+ "vm[1].group-notation", "grpNot2");
-
-
- ctx.setAttribute(prefix+ "vm[2].vserver-name", "ibcxvm0003");
- ctx.setAttribute(prefix+ "vm[2].group-notation", "grpNot3");
-
- ctx.setAttribute(prefix+ "vm[3].vserver-name", "ibcxvm0004");
- ctx.setAttribute(prefix+ "vm[3].group-notation", "4");
-
- ctx.setAttribute(prefix+ "vm[4].vserver-name", "ibcxvm0005");
- ctx.setAttribute(prefix+ "vm[4].group-notation", "4");
- }
-
-
- public void populateVnfcRef(SvcLogicContext ctx) throws Exception {
-
- for (int i = 0; i < 2; i++ ) {
-
- String vnfcRefKey = "vnfcReference[" + i+ "].";
-
-
-
- ctx.setAttribute(vnfcRefKey+ "VM-INSTANCE", String.valueOf(i));
- ctx.setAttribute(vnfcRefKey+ "VNFC-INSTANCE", "1");
-
-
- //if ( i == 0 || i == 1 ) {
- ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-TYPE", "fixed-value");
- ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-VALUE", "2");
- //}
-
- ctx.setAttribute(vnfcRefKey+ "VNFC-TYPE", "ssc"+i );
-
- ctx.setAttribute(vnfcRefKey+ "VNFC-FUNCTION-CODE", "func" +i);
-
- ctx.setAttribute(vnfcRefKey+ "IPADDRESS-V4-OAM-VIP", "Y");
- }
-
- }
-
- public void populateAllVnfInfo(SvcLogicContext ctx, String prefix) throws Exception {
-
- ctx.setAttribute("vnf-id", "ibcx000000");
-
- ctx.setAttribute("vnf-host-ip-address", "000.00.00.00");
- ctx.setAttribute(prefix + ".vnf.vm-count", "2");
-
-
-
-
- ctx.setAttribute(prefix+ ".vm[0].vserver-name", "ibcxvm0000");
- ctx.setAttribute(prefix+ ".vm[0].vnfc-name", "VNFCNAME");
-
- ctx.setAttribute(prefix+ ".vm[0].vserver-id", "ibcxvm0001id");
- ctx.setAttribute(prefix+ ".vm[0].tenant-id", "tenantid");
- ctx.setAttribute(prefix+ ".vm[0].cloud-owner", "cloudOwner");
- ctx.setAttribute(prefix+ ".vm[0].cloud-region-id", "cloudRegionId");
-
- ctx.setAttribute(prefix+ ".vm[0].vf-module-id", "vfModuleId");
-
-
-
- ctx.setAttribute(prefix+ ".vm[1].vserver-name", "ibcxvm0002");
-
- ctx.setAttribute(prefix+ ".vm[1].vserver-id", "ibcx00000");
- ctx.setAttribute(prefix+ ".vm[1].tenant-id", "tenantId");
- ctx.setAttribute(prefix+ ".vm[1].cloud-owner", "cloudOwner");
- ctx.setAttribute(prefix+ ".vm[1].cloud-region-id", "cloudRegionId");
-
- ctx.setAttribute(prefix+ ".vm[1].vf-module-id", "vfModuleId");
-
-
- //ctx.setAttribute(prefix+ ".vm[1].vserver-name", "ibcxvm0002");
-
-
-
-
- }
-
-
-
- public void populateAllVnfInfo1(SvcLogicContext ctx, String prefix) throws Exception {
-
- ctx.setAttribute("vnf-id", "dbjx0001v");
-
- ctx.setAttribute("vnf-host-ip-address", "000.00.00.00");
- ctx.setAttribute(prefix + ".vnf.vm-count", "2");
-
-
-
-
- ctx.setAttribute(prefix+ ".vm[0].vserver-name", "dbjx0001vm001");
-
-
- ctx.setAttribute(prefix+ ".vm[0].vserver-id", "dbjx0001vm0001id");
- ctx.setAttribute(prefix+ ".vm[0].tenant-id", "tenantid1");
- ctx.setAttribute(prefix+ ".vm[0].cloud-owner", "cloudOwner1");
- ctx.setAttribute(prefix+ ".vm[0].cloud-region-id", "cloudRegionId1");
-
- ctx.setAttribute(prefix+ ".vm[0].vf-module-id", "vfModuleId1");
-
-
-
- ctx.setAttribute(prefix+ ".vm[1].vserver-name", "dbjx0001vm002");
-
- ctx.setAttribute(prefix+ ".vm[1].vserver-id", "dbjx0001vm0002id");
- ctx.setAttribute(prefix+ ".vm[1].tenant-id", "tenantId2");
- ctx.setAttribute(prefix+ ".vm[1].cloud-owner", "cloudOwner2");
- ctx.setAttribute(prefix+ ".vm[1].cloud-region-id", "cloudRegionId2");
-
- ctx.setAttribute(prefix+ ".vm[1].vf-module-id", "vfModuleId2");
-
-
-
- }
-
- public void populateVnfcRefFirstVnfcName(SvcLogicContext ctx) throws Exception {
-
-
- for (int i = 0; i < 2; i++ ) {
-
- String vnfcRefKey = "vnfcReference[" + i+ "].";
-
-
-
- ctx.setAttribute(vnfcRefKey+ "VM-INSTANCE", String.valueOf(i));
- ctx.setAttribute(vnfcRefKey+ "VNFC-INSTANCE", "1");
-
-
-
- ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-TYPE", "first-vnfc-name");
- ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-VALUE", "pair");
-
-
- ctx.setAttribute(vnfcRefKey+ "VNFC-TYPE", "vDBE-I? - DBJX" );
-
- ctx.setAttribute(vnfcRefKey+ "VNFC-FUNCTION-CODE", "dbj");
-
- ctx.setAttribute(vnfcRefKey+ "IPADDRESS-V4-OAM-VIP", "Y");
- }
-
- }
-
- public void populateVnfcRefRelValueSame(SvcLogicContext ctx) throws Exception {
-
-
- for (int i = 0; i < 2; i++ ) {
-
- String vnfcRefKey = "vnfcReference[" + i+ "].";
-
-
-
- ctx.setAttribute(vnfcRefKey+ "VM-INSTANCE", String.valueOf(i));
- ctx.setAttribute(vnfcRefKey+ "VNFC-INSTANCE", "1");
-
-
-
- if ( i == 0 ) {
- ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-TYPE", "fixed-value");
- ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-VALUE", "1");
- }
- else {
- ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-TYPE", "relative-value");
- ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-VALUE", "same");
- }
-
-
-
- ctx.setAttribute(vnfcRefKey+ "VNFC-TYPE", "v-I? - DBJX" );
-
- ctx.setAttribute(vnfcRefKey+ "VNFC-FUNCTION-CODE", "dbj");
-
- ctx.setAttribute(vnfcRefKey+ "IPADDRESS-V4-OAM-VIP", "Y");
- }
-
- }
-
-
- public void populateVnfcRefRelValueNext(SvcLogicContext ctx) throws Exception {
-
-
- for (int i = 0; i < 2; i++ ) {
-
- String vnfcRefKey = "vnfcReference[" + i+ "].";
-
-
-
- ctx.setAttribute(vnfcRefKey+ "VM-INSTANCE", String.valueOf(i));
- ctx.setAttribute(vnfcRefKey+ "VNFC-INSTANCE", "1");
-
-
-
- if ( i == 0 ) {
- ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-TYPE", "fixed-value");
- ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-VALUE", "1");
- }
- else {
- ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-TYPE", "relative-value");
- ctx.setAttribute(vnfcRefKey+ "GROUP-NOTATION-VALUE", "next");
- }
-
-
-
- ctx.setAttribute(vnfcRefKey+ "VNFC-TYPE", "v-I? - DBJX" );
-
- ctx.setAttribute(vnfcRefKey+ "VNFC-FUNCTION-CODE", "dbj");
-
- ctx.setAttribute(vnfcRefKey+ "IPADDRESS-V4-OAM-VIP", "Y");
- }
-
- }
+*/
+ // VM1
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].related-to", "vserver");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data_length", "4");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[0].relationship-key",
+ "vserver.vserver-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[0].relationship-value",
+ "ibcx001vm001-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[1].relationship-key",
+ "tenant.tenant-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[1].relationship-value",
+ "sometenant");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[2].relationship-key",
+ "cloud-region.cloud-owner");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[2].relationship-value",
+ "ATTAIC");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[3].relationship-key",
+ "cloud-region.cloud-region-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[3].relationship-value",
+ "testcloudregionid");
+
+ // VM2
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].related-to", "vserver");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data_length", "4");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[0].relationship-key",
+ "vserver.vserver-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[0].relationship-value",
+ "ibcx000000");
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[1].relationship-key",
+ "tenant.tenant-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[1].relationship-value",
+ "sometenant");
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[2].relationship-key",
+ "cloud-region.cloud-owner");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[0].relationship-data[2].relationship-value",
+ "ATTAIC");
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[3].relationship-key",
+ "cloud-region.cloud-region-id");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[1].relationship-data[3].relationship-value",
+ "testcloudregionid");
+
+ // Unrelated
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].related-to", "junk");
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data_length", "4");
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[0].relationship-key", "test");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[0].relationship-value",
+ "ibcx000000");
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[1].relationship-key", "test1");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[1].relationship-value",
+ "sometenant");
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[2].relationship-key", "test2");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[2].relationship-value",
+ "ATTAIC");
+
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[3].relationship-key", "test3");
+ ctx.setAttribute(prefix + ".relationship-list.relationship[2].relationship-data[3].relationship-value",
+ "testcloudregionid");
+ }
+
+
+ public void populateFirstVnfcData(SvcLogicContext ctx, String prefix) throws Exception {
+
+ ctx.setAttribute(prefix + "vnf.vm-count", "4");
+
+ ctx.setAttribute(prefix + "vm[0].vnfc-type", "mmc");
+ ctx.setAttribute(prefix + "vm[0].vnfc-name", "vnfcname1");
+
+ ctx.setAttribute(prefix + "vm[1].vnfc-type", "mmc");
+ ctx.setAttribute(prefix + "vm[1].vnfc-name", "vnfcname2");
+
+ ctx.setAttribute(prefix + "vm[2].vnfc-type", "ssc");
+ ctx.setAttribute(prefix + "vm[2].vnfc-name", "vnfcname3");
+
+ ctx.setAttribute(prefix + "vm[3].vnfc-type", "ssc");
+ ctx.setAttribute(prefix + "vm[3].vnfc-name", "vnfcname4");
+ }
+
+
+ public void populateGroupNotation(SvcLogicContext ctx, String prefix) throws Exception {
+
+ ctx.setAttribute(prefix + "vnf.vm-count", "5");
+
+ ctx.setAttribute(prefix + "vm[0].vserver-name", "ibcxvm0001");
+ ctx.setAttribute(prefix + "vm[0].group-notation", "grpNot1");
+
+ ctx.setAttribute(prefix + "vm[1].vserver-name", "ibcxvm0002");
+ ctx.setAttribute(prefix + "vm[1].group-notation", "grpNot2");
+
+ ctx.setAttribute(prefix + "vm[2].vserver-name", "ibcxvm0003");
+ ctx.setAttribute(prefix + "vm[2].group-notation", "grpNot3");
+
+ ctx.setAttribute(prefix + "vm[3].vserver-name", "ibcxvm0004");
+ ctx.setAttribute(prefix + "vm[3].group-notation", "4");
+
+ ctx.setAttribute(prefix + "vm[4].vserver-name", "ibcxvm0005");
+ ctx.setAttribute(prefix + "vm[4].group-notation", "4");
+ }
+
+
+ public void populateVnfcRef(SvcLogicContext ctx) throws Exception {
+
+ for (int i = 0; i < 2; i++) {
+
+ String vnfcRefKey = "vnfcReference[" + i + "].";
+
+ ctx.setAttribute(vnfcRefKey + "VM-INSTANCE", String.valueOf(i));
+ ctx.setAttribute(vnfcRefKey + "VNFC-INSTANCE", "1");
+
+ //if ( i == 0 || i == 1 ) {
+ ctx.setAttribute(vnfcRefKey + "GROUP-NOTATION-TYPE", "fixed-value");
+ ctx.setAttribute(vnfcRefKey + "GROUP-NOTATION-VALUE", "2");
+ //}
+
+ ctx.setAttribute(vnfcRefKey + "VNFC-TYPE", "ssc" + i);
+
+ ctx.setAttribute(vnfcRefKey + "VNFC-FUNCTION-CODE", "func" + i);
+
+ ctx.setAttribute(vnfcRefKey + "IPADDRESS-V4-OAM-VIP", "Y");
+ }
+
+ }
+
+ public void populateAllVnfInfo(SvcLogicContext ctx, String prefix) throws Exception {
+
+ ctx.setAttribute("vnf-id", "ibcx000000");
+
+ ctx.setAttribute("vnf-host-ip-address", "000.00.00.00");
+ ctx.setAttribute(prefix + ".vnf.vm-count", "2");
+
+ ctx.setAttribute(prefix + ".vm[0].vserver-name", "ibcxvm0000");
+ ctx.setAttribute(prefix + ".vm[0].vnfc-name", "VNFCNAME");
+
+ ctx.setAttribute(prefix + ".vm[0].vserver-id", "ibcxvm0001id");
+ ctx.setAttribute(prefix + ".vm[0].tenant-id", "tenantid");
+ ctx.setAttribute(prefix + ".vm[0].cloud-owner", "cloudOwner");
+ ctx.setAttribute(prefix + ".vm[0].cloud-region-id", "cloudRegionId");
+
+ ctx.setAttribute(prefix + ".vm[0].vf-module-id", "vfModuleId");
+
+ ctx.setAttribute(prefix + ".vm[1].vserver-name", "ibcxvm0002");
+
+ ctx.setAttribute(prefix + ".vm[1].vserver-id", "ibcx00000");
+ ctx.setAttribute(prefix + ".vm[1].tenant-id", "tenantId");
+ ctx.setAttribute(prefix + ".vm[1].cloud-owner", "cloudOwner");
+ ctx.setAttribute(prefix + ".vm[1].cloud-region-id", "cloudRegionId");
+
+ ctx.setAttribute(prefix + ".vm[1].vf-module-id", "vfModuleId");
+
+ //ctx.setAttribute(prefix+ ".vm[1].vserver-name", "ibcxvm0002");
+
+ }
+
+
+ public void populateAllVnfInfo1(SvcLogicContext ctx, String prefix) throws Exception {
+
+ ctx.setAttribute("vnf-id", "dbjx0001v");
+
+ ctx.setAttribute("vnf-host-ip-address", "000.00.00.00");
+ ctx.setAttribute(prefix + ".vnf.vm-count", "2");
+
+ ctx.setAttribute(prefix + ".vm[0].vserver-name", "dbjx0001vm001");
+
+ ctx.setAttribute(prefix + ".vm[0].vserver-id", "dbjx0001vm0001id");
+ ctx.setAttribute(prefix + ".vm[0].tenant-id", "tenantid1");
+ ctx.setAttribute(prefix + ".vm[0].cloud-owner", "cloudOwner1");
+ ctx.setAttribute(prefix + ".vm[0].cloud-region-id", "cloudRegionId1");
+
+ ctx.setAttribute(prefix + ".vm[0].vf-module-id", "vfModuleId1");
+
+ ctx.setAttribute(prefix + ".vm[1].vserver-name", "dbjx0001vm002");
+
+ ctx.setAttribute(prefix + ".vm[1].vserver-id", "dbjx0001vm0002id");
+ ctx.setAttribute(prefix + ".vm[1].tenant-id", "tenantId2");
+ ctx.setAttribute(prefix + ".vm[1].cloud-owner", "cloudOwner2");
+ ctx.setAttribute(prefix + ".vm[1].cloud-region-id", "cloudRegionId2");
+
+ ctx.setAttribute(prefix + ".vm[1].vf-module-id", "vfModuleId2");
+
+
+ }
+
+ public void populateVnfcRefFirstVnfcName(SvcLogicContext ctx) throws Exception {
+
+ for (int i = 0; i < 2; i++) {
+
+ String vnfcRefKey = "vnfcReference[" + i + "].";
+
+ ctx.setAttribute(vnfcRefKey + "VM-INSTANCE", String.valueOf(i));
+ ctx.setAttribute(vnfcRefKey + "VNFC-INSTANCE", "1");
+
+ ctx.setAttribute(vnfcRefKey + "GROUP-NOTATION-TYPE", "first-vnfc-name");
+ ctx.setAttribute(vnfcRefKey + "GROUP-NOTATION-VALUE", "pair");
+
+ ctx.setAttribute(vnfcRefKey + "VNFC-TYPE", "vDBE-I? - DBJX");
+
+ ctx.setAttribute(vnfcRefKey + "VNFC-FUNCTION-CODE", "dbj");
+
+ ctx.setAttribute(vnfcRefKey + "IPADDRESS-V4-OAM-VIP", "Y");
+ }
+
+ }
+
+ public void populateVnfcRefRelValueSame(SvcLogicContext ctx) throws Exception {
+
+ for (int i = 0; i < 2; i++) {
+
+ String vnfcRefKey = "vnfcReference[" + i + "].";
+
+ ctx.setAttribute(vnfcRefKey + "VM-INSTANCE", String.valueOf(i));
+ ctx.setAttribute(vnfcRefKey + "VNFC-INSTANCE", "1");
+
+ if (i == 0) {
+ ctx.setAttribute(vnfcRefKey + "GROUP-NOTATION-TYPE", "fixed-value");
+ ctx.setAttribute(vnfcRefKey + "GROUP-NOTATION-VALUE", "1");
+ } else {
+ ctx.setAttribute(vnfcRefKey + "GROUP-NOTATION-TYPE", "relative-value");
+ ctx.setAttribute(vnfcRefKey + "GROUP-NOTATION-VALUE", "same");
+ }
+
+ ctx.setAttribute(vnfcRefKey + "VNFC-TYPE", "v-I? - DBJX");
+
+ ctx.setAttribute(vnfcRefKey + "VNFC-FUNCTION-CODE", "dbj");
+
+ ctx.setAttribute(vnfcRefKey + "IPADDRESS-V4-OAM-VIP", "Y");
+ }
+
+ }
+
+
+ public void populateVnfcRefRelValueNext(SvcLogicContext ctx) throws Exception {
+
+ for (int i = 0; i < 2; i++) {
+
+ String vnfcRefKey = "vnfcReference[" + i + "].";
+
+ ctx.setAttribute(vnfcRefKey + "VM-INSTANCE", String.valueOf(i));
+ ctx.setAttribute(vnfcRefKey + "VNFC-INSTANCE", "1");
+
+ if (i == 0) {
+ ctx.setAttribute(vnfcRefKey + "GROUP-NOTATION-TYPE", "fixed-value");
+ ctx.setAttribute(vnfcRefKey + "GROUP-NOTATION-VALUE", "1");
+ } else {
+ ctx.setAttribute(vnfcRefKey + "GROUP-NOTATION-TYPE", "relative-value");
+ ctx.setAttribute(vnfcRefKey + "GROUP-NOTATION-VALUE", "next");
+ }
+
+ ctx.setAttribute(vnfcRefKey + "VNFC-TYPE", "v-I? - DBJX");
+
+ ctx.setAttribute(vnfcRefKey + "VNFC-FUNCTION-CODE", "dbj");
+
+ ctx.setAttribute(vnfcRefKey + "IPADDRESS-V4-OAM-VIP", "Y");
+ }
+
+ }
}
diff --git a/appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/node/MockAaiService.java b/appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/node/MockAaiService.java
index ddbb97954..d72a508fb 100644
--- a/appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/node/MockAaiService.java
+++ b/appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/node/MockAaiService.java
@@ -24,6 +24,7 @@
package org.onap.appc.aai.client.node;
+
import static junit.framework.Assert.assertEquals;
import java.util.HashMap;
@@ -37,6 +38,7 @@ import org.onap.appc.aai.client.aai.AaiService;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
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 org.onap.ccsdk.sli.adaptors.aai.AAIClient;
@@ -44,56 +46,55 @@ public class MockAaiService extends AaiService {
// ONAP merging
private static final EELFLogger log = EELFManager.getInstance().getLogger(MockAaiService.class);
- private AAIClient aaiClient;
+ private AAIClient aaiClient;
/*public MockAaiService() {
super(new AAIClientMock());
}*/
- public MockAaiService(AAIClient aaic) {
- super(aaic);
- }
-
- public void getVMInfo(Map<String, String> params,SvcLogicContext ctx ) throws Exception {
- log.info("Received Mock getVmInfo call with params : " + params);
- String vserverId = params.get("vserverId");
- String prefix = params.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
- if ( vserverId.equals("ibcm0001id")) {
- ctx.setAttribute(prefix + ".vm.vserver-name", "vserverName1");
- ctx.setAttribute(prefix + ".vm.vf-module-id", "vfModule1");
- }
- else {
- ctx.setAttribute(prefix + ".vm.vserver-name", "vserverName2");
- ctx.setAttribute(prefix + ".vm.vf-module-id", "vfModule2");
- ctx.setAttribute(prefix + ".vm.vnfc[0].vnfc-name", "vnfcName2");
- }
-
+ public MockAaiService(AAIClient aaic) {
+ super(aaic);
+ }
+
+ public void getVMInfo(Map<String, String> params, SvcLogicContext ctx) throws SvcLogicException {
+ log.info("Received Mock getVmInfo call with params : " + params);
+ String vserverId = params.get("vserverId");
+ String prefix = params.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
+ if (vserverId.equals("ibcm0001id")) {
+ ctx.setAttribute(prefix + ".vm.vserver-name", "vserverName1");
+ ctx.setAttribute(prefix + ".vm.vf-module-id", "vfModule1");
+ } else {
+ ctx.setAttribute(prefix + ".vm.vserver-name", "vserverName2");
+ ctx.setAttribute(prefix + ".vm.vf-module-id", "vfModule2");
+ ctx.setAttribute(prefix + ".vm.vnfc[0].vnfc-name", "vnfcName2");
}
+ }
- public void getVnfcInfo(Map<String, String> params,SvcLogicContext ctx ) throws Exception {
- log.info("Received Mock getVmInfo call with params : " + params);
- String prefix = params.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
-
- String vnfcName = params.get("vnfcName");
- if ( vnfcName.equals("vnfcName2") ) {
- ctx.setAttribute(prefix + ".vnfc.vnfc-type", "vnfcType2");
- ctx.setAttribute(prefix + ".vnfc.vnfc-function-code", "vnfcFuncCode2");
- ctx.setAttribute(prefix + ".vnfc.group-notation", "vnfcGrpNot2");
- }
+ public void getVnfcInfo(Map<String, String> params, SvcLogicContext ctx) throws SvcLogicException {
+ log.info("Received Mock getVmInfo call with params : " + params);
+ String prefix = params.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
+ String vnfcName = params.get("vnfcName");
+ if (vnfcName.equals("vnfcName2")) {
+ ctx.setAttribute(prefix + ".vnfc.vnfc-type", "vnfcType2");
+ ctx.setAttribute(prefix + ".vnfc.vnfc-function-code", "vnfcFuncCode2");
+ ctx.setAttribute(prefix + ".vnfc.group-notation", "vnfcGrpNot2");
}
- @Override
- public SvcLogicContext readResource(String query, String prefix, String resourceType) throws Exception {
- SvcLogicContext resourceContext = new SvcLogicContext();
- resourceContext.setAttribute("vfModuleInfo.model-invariant-id","invid01");
- resourceContext.setAttribute("vfModuleInfo.model-version-id","versid01");
- resourceContext.setAttribute("modelInfo.model-name","model0001");
- return resourceContext;
- }
+ }
+
+ @Override
+ public SvcLogicContext readResource(String query, String prefix, String resourceType) throws SvcLogicException {
+ SvcLogicContext resourceContext = new SvcLogicContext();
+ resourceContext.setAttribute("vfModuleInfo.model-invariant-id", "invid01");
+ resourceContext.setAttribute("vfModuleInfo.model-version-id", "versid01");
+ resourceContext.setAttribute("modelInfo.model-name", "model0001");
+
+ return resourceContext;
+ }
}