aboutsummaryrefslogtreecommitdiffstats
path: root/appc-outbound
diff options
context:
space:
mode:
authorMei Su <ms6523@att.com>2018-07-03 08:56:08 -0400
committerMei Su <ms6523@att.com>2018-07-03 17:52:58 -0400
commit9fec029349301e7bc54033a08270ca8707f4b9bd (patch)
treec1f6445277fd463b7af645bc8293e5b388e6168d /appc-outbound
parent41db847244b0ad79e1c9fe0caecddc2baae1372c (diff)
Add feature to support reboot lcm command
Add method getIdentityUrl to fetch identity-url Issue-ID: APPC-1044 Change-Id: I8fe6f774754e04b0329fe3e735f4b927d6db10bc Signed-off-by: Mei Su <ms6523@att.com>
Diffstat (limited to 'appc-outbound')
-rw-r--r--appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/aai/AaiService.java25
-rw-r--r--appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/node/AAIResourceNode.java8
-rw-r--r--appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/aai/MockAaiService.java2
-rw-r--r--appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/aai/TestAaiService.java17
4 files changed, 51 insertions, 1 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 0f0f5a452..b10abc47e 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
@@ -149,6 +149,7 @@ public class AaiService {
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"));
+ ctx.setAttribute(prefix + "vm.vserver-selflink", vmCtx.getAttribute("vmInfo.vserver-selflink"));
String relLen = vmCtx.getAttribute("vmInfo.relationship-list.relationship_length");
int relationshipLength = 0;
@@ -399,7 +400,7 @@ public class AaiService {
if (SvcLogicResource.QueryStatus.SUCCESS.equals(response)) {
log.info("Added VNFC SUCCESSFULLY " + vnfcName);
} else if (SvcLogicResource.QueryStatus.FAILURE.equals(response)) {
- throw new AaiServiceInternalException("VNFC Add failed for for vnfc_name " + vnfcName);
+ throw new AaiServiceInternalException("VNFC Add failed for vnfc_name " + vnfcName);
}
}
@@ -760,4 +761,26 @@ public class AaiService {
log.info("End - getModelVersionInfo");
}
+
+ public void getIdentityUrl(Map<String, String> params, SvcLogicContext ctx) throws Exception{
+ log.info("Recieved getIdentityUrl call with params : "+params);
+ String prefix = params.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX);
+ prefix = StringUtils.isNotBlank(prefix) ? (prefix + ".") : "";
+
+ String cloudOwner = params.get("cloudOwner");
+ String cloudRegionId = params.get("cloudRegionId");
+ // per comment from git review, we need to sanitize the two parameters
+ // to avoid security issues
+ cloudOwner = cloudOwner.replaceAll("'", "");
+ cloudRegionId = cloudRegionId.replaceAll("'", "");
+ log.debug("cloudOwner" +cloudOwner +"," +"cloudRegionId"+ cloudRegionId);
+ String resourceKey = "cloud-region.cloud-owner = '" + cloudOwner +
+ "' AND cloud-region.cloud-region-id = '" + cloudRegionId + "'";
+ String queryPrefix ="urlInfo";
+ String resourceType = "cloud-region";
+ SvcLogicContext urlCtx = readResource(resourceKey, queryPrefix, resourceType);
+ log.info("IdentityUrl: "+urlCtx.getAttribute("urlInfo.identity-url"));
+ ctx.setAttribute(prefix+"cloud-region.identity-url", urlCtx.getAttribute("urlInfo.identity-url"));
+
+ }
}
diff --git a/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/node/AAIResourceNode.java b/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/node/AAIResourceNode.java
index 99949e931..cc084d426 100644
--- a/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/node/AAIResourceNode.java
+++ b/appc-outbound/appc-aai-client/provider/src/main/java/org/onap/appc/aai/client/node/AAIResourceNode.java
@@ -47,6 +47,7 @@ public class AAIResourceNode implements SvcLogicJavaPlugin {
private static final String STR_TENANT_ID = "].tenant-id";
private static final String STR_CLOUD_OWNER = "].cloud-owner";
private static final String STR_CLOUD_REGION_ID = "].cloud-region-id";
+ private static final String STR_VSERVER_SELFLINK ="].vserver-selflink";
private static final String STR_TMP_VNF_INFO = "tmp.vnfInfo.vm[";
private static final String PARAM_VSERVER_ID = "vserverId";
@@ -54,6 +55,7 @@ public class AAIResourceNode implements SvcLogicJavaPlugin {
private static final String PARAM_CLOUD_OWNER = "cloudOwner";
private static final String PARAM_CLOUD_REGION_ID = "cloudRegionId";
private static final String PARAM_VSERVER_NAME = "vserver-name";
+ private static final String PARAM_VSERVER_SELFLINK = "vserver-selflink";
private static final String PARAM_VNFC_NAME = "vnfcName";
private static final String ATTR_VNF_VM_COUNT = "vnf.vm-count";
@@ -122,6 +124,7 @@ public class AAIResourceNode implements SvcLogicJavaPlugin {
paramsVm.put(PARAM_TENANT_ID, ctx.getAttribute(responsePrefix + "vm[" + i + STR_TENANT_ID));
paramsVm.put(PARAM_CLOUD_OWNER, ctx.getAttribute(responsePrefix + "vm[" + i + STR_CLOUD_OWNER));
paramsVm.put(PARAM_CLOUD_REGION_ID, ctx.getAttribute(responsePrefix + "vm[" + i + STR_CLOUD_REGION_ID));
+ paramsVm.put(PARAM_VSERVER_SELFLINK, ctx.getAttribute(responsePrefix + "vm[" + i + STR_VSERVER_SELFLINK));
paramsVm.put(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX,
inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX));
@@ -136,6 +139,9 @@ public class AAIResourceNode implements SvcLogicJavaPlugin {
// Parameters returned by getVMInfo
vserverMap.put(PARAM_VSERVER_NAME, vmServerCtx.getAttribute(responsePrefix + "vm.vserver-name"));
vserverMap.put("vf-module-id", vmServerCtx.getAttribute(responsePrefix + "vm.vf-module-id"));
+ vserverMap.put("vserver-selflink", vmServerCtx.getAttribute(responsePrefix + "vm.vserver-selflink"));
+
+ log.info("VSERVER-LINK VALUE:" + vmServerCtx.getAttribute(responsePrefix + "vm.vserver-selflink"));
// as Per 17.07 requirements we are supporting only one VNFC per VM.
@@ -473,12 +479,14 @@ public class AAIResourceNode implements SvcLogicJavaPlugin {
String tenantId = ctx.getAttribute(STR_TMP_VNF_INFO + arrayIndex + STR_TENANT_ID);
String cloudOwner = ctx.getAttribute(STR_TMP_VNF_INFO + arrayIndex + STR_CLOUD_OWNER);
String cloudRegionId = ctx.getAttribute(STR_TMP_VNF_INFO + arrayIndex + STR_CLOUD_REGION_ID);
+ String vserverSelflink = ctx.getAttribute(STR_TMP_VNF_INFO + arrayIndex + STR_VSERVER_SELFLINK);
log.info("setVmParams()::tenantId=" + tenantId + " cloudOwner=" + cloudOwner + " cloudRegiodId= "
+ cloudRegionId);
params.put(PARAM_VSERVER_ID, vServerId);
params.put(PARAM_TENANT_ID, tenantId);
params.put(PARAM_CLOUD_OWNER, cloudOwner);
params.put(PARAM_CLOUD_REGION_ID, cloudRegionId);
+ params.put(PARAM_VSERVER_SELFLINK, vserverSelflink);
log.info("setVmParams()::setVmParamsVM level action:" + params.toString());
return params;
}
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 55fd39268..8dec463d0 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
@@ -57,6 +57,8 @@ public class MockAaiService extends AaiService {
populateVmContext(resourceContext, prefix);
} else if ("vnfc".equals(resourceType)) {
populateVnfcContext(resourceContext, prefix);
+ } else if ("cloud-region".equals(resourceType)) {
+ resourceContext.setAttribute(prefix + ".identity-url", "TestUrl");
}
return resourceContext;
diff --git a/appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/aai/TestAaiService.java b/appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/aai/TestAaiService.java
index fbfe40bb2..0f3d84c4c 100644
--- a/appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/aai/TestAaiService.java
+++ b/appc-outbound/appc-aai-client/provider/src/test/java/org/onap/appc/aai/client/aai/TestAaiService.java
@@ -381,4 +381,21 @@ public class TestAaiService {
assertEquals (groupNotationValue4,"gn1");
}
+
+ @Test
+ public void testgetIdentityUrl() throws Exception {
+
+ MockAaiService mockAai = new MockAaiService(aaiClient);
+
+ Map<String, String> inParams = new HashMap<String, String>();
+ inParams.put("responsePrefix", "tmp.vnfInfo");
+ inParams.put("cloudOwner", "testCloudOwner");
+ inParams.put("cloudRegionId", "testCloudRegionId");
+
+ SvcLogicContext ctx = new SvcLogicContext();
+ mockAai.getIdentityUrl(inParams, ctx);
+ assertEquals(ctx.getAttribute("tmp.vnfInfo.cloud-region.identity-url"), "TestUrl");
+
+ }
+
}