- 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"));
+ ctx.setAttribute(prefix + "vm.vserver-selflink", vmCtx.getAttribute("vmInfo.vserver-selflink"));
+
+ 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);
+ }