summaryrefslogtreecommitdiffstats
path: root/appc-dg/appc-dg-shared/appc-dg-aai
diff options
context:
space:
mode:
authorPatrick Brady <pb071s@att.com>2017-06-01 10:45:37 -0700
committerPatrick Brady <pb071s@att.com>2017-06-02 13:05:15 -0700
commitc7d0075d223eab9f89fd28853c4b138792059be9 (patch)
tree40aa3e41e598ea7a59bcf6899a2004c1abab11c2 /appc-dg/appc-dg-shared/appc-dg-aai
parent8aac2df744820304ee29354333661699e9695939 (diff)
Merge of new rebased code
Change-Id: I9b8d1f69eb3e0af1935ed8304fea4bf54c1aac47 Signed-off-by: Patrick Brady <pb071s@att.com>
Diffstat (limited to 'appc-dg/appc-dg-shared/appc-dg-aai')
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-aai/pom.xml16
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/AAIPlugin.java10
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/exception/AAIQueryException.java29
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/impl/AAIPluginImpl.java302
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/impl/Constants.java2
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/objects/AAIQueryResult.java49
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/objects/Relationship.java66
-rw-r--r--appc-dg/appc-dg-shared/appc-dg-aai/src/main/test/java/org/openecomp/appc/dg/aai/impl/AAIPluginImplTest.java16
8 files changed, 453 insertions, 37 deletions
diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/pom.xml b/appc-dg/appc-dg-shared/appc-dg-aai/pom.xml
index 814386788..db5dcf390 100644
--- a/appc-dg/appc-dg-shared/appc-dg-aai/pom.xml
+++ b/appc-dg/appc-dg-shared/appc-dg-aai/pom.xml
@@ -30,6 +30,11 @@
<groupId>org.openecomp.sdnc.adaptors</groupId>
<artifactId>aai-service-provider</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-dg-dependency-model</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>junit</groupId>
@@ -56,6 +61,11 @@
<version>1.6.2</version>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.openecomp.appc</groupId>
+ <artifactId>appc-dg-domain-model-lib</artifactId>
+ <version>${project.version}</version>
+ </dependency>
</dependencies>
@@ -69,12 +79,12 @@
<instructions>
<Bundle-SymbolicName>appc-dg-aai</Bundle-SymbolicName>
<Export-Package>org.openecomp.appc.dg.aai</Export-Package>
- <Private-Package>org.openecomp.appc.dg.aai.impl.*</Private-Package>
+ <Private-Package>org.openecomp.appc.dg.aai.exception,org.openecomp.appc.dg.aai.objects,org.openecomp.appc.dg.aai.impl.*</Private-Package>
<Import-Package>
- !org.apache.log,!org.apache.commons.logging,!groovy.lang,!javax.jms,!org.codehaus.commons.compiler,!org.codehaus.groovy.*,!org.codehaus.janino,!com.ibm.icu.*,!com.sun.faces.*,!org.jasypt.*,*;resolution:=optional
+ *;resolution:=optional
</Import-Package>
<Embed-Dependency>
- appc-common,eelf-core,logback-core,logback-classic;scope=compile|runtime;inline=false
+ appc-dg-domain-model-lib;scope=compile|runtime;inline=false
</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/AAIPlugin.java b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/AAIPlugin.java
index e220182f2..7985dc454 100644
--- a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/AAIPlugin.java
+++ b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/AAIPlugin.java
@@ -27,9 +27,17 @@ import org.openecomp.appc.exceptions.APPCException;
import org.openecomp.sdnc.sli.SvcLogicContext;
import org.openecomp.sdnc.sli.SvcLogicJavaPlugin;
-
public interface AAIPlugin extends SvcLogicJavaPlugin {
void postGenericVnfData(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
void getGenericVnfData(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+
+ void getVnfHierarchy(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+
+ void getResource(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+
+ void postResource(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+
+ void deleteResource(Map<String, String> params, SvcLogicContext ctx) throws APPCException;
+
}
diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/exception/AAIQueryException.java b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/exception/AAIQueryException.java
new file mode 100644
index 000000000..f9f781b50
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/exception/AAIQueryException.java
@@ -0,0 +1,29 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.dg.aai.exception;
+
+
+public class AAIQueryException extends Exception{
+ public AAIQueryException(String message){
+ super(message);
+ }
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/impl/AAIPluginImpl.java b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/impl/AAIPluginImpl.java
index 6eae559e8..830147ca2 100644
--- a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/impl/AAIPluginImpl.java
+++ b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/impl/AAIPluginImpl.java
@@ -20,10 +20,17 @@
*/
package org.openecomp.appc.dg.aai.impl;
+import org.openecomp.appc.domainmodel.Vnf;
+import org.openecomp.appc.domainmodel.Vnfc;
+import org.openecomp.appc.domainmodel.Vserver;
+import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.appc.i18n.Msg;
+import com.att.eelf.i18n.EELFResourceManager;
import org.openecomp.appc.dg.aai.AAIPlugin;
-import org.openecomp.appc.dg.aai.impl.Constants;
-import org.openecomp.appc.exceptions.APPCException;
+import org.openecomp.appc.dg.aai.exception.AAIQueryException;
+import org.openecomp.appc.dg.aai.objects.AAIQueryResult;
+import org.openecomp.appc.dg.aai.objects.Relationship;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
import org.openecomp.sdnc.sli.SvcLogicContext;
@@ -35,8 +42,7 @@ import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.ServiceReference;
-import java.util.HashMap;
-import java.util.Map;
+import java.util.*;
public class AAIPluginImpl implements AAIPlugin {
@@ -68,20 +74,23 @@ public class AAIPluginImpl implements AAIPlugin {
try {
SvcLogicResource.QueryStatus response = aaiClient.update("generic-vnf", key, data, prefix, ctx);
if (SvcLogicResource.QueryStatus.NOT_FOUND.equals(response)) {
- String errorMessage = String.format("VNF not found for vnf_id = %s", vnf_id);
- ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, errorMessage);
- throw new APPCException(errorMessage);
+ String msg = EELFResourceManager.format(Msg.VNF_NOT_FOUND, vnf_id);
+ ctx.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, msg);
+ throw new APPCException(msg);
}
logger.info("AAIResponse: " + response.toString());
if (SvcLogicResource.QueryStatus.FAILURE.equals(response)) {
- String errorMessage = String.format("Error Querying AAI with vnfID = %s", vnf_id);
- ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, errorMessage);
- throw new APPCException(errorMessage);
+ String msg = EELFResourceManager.format(Msg.AAI_QUERY_FAILED, vnf_id);
+ ctx.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, msg);
+ throw new APPCException(msg);
}
+ String msg = EELFResourceManager.format(Msg.SUCCESS_EVENT_MESSAGE, "PostGenericVnfData", "VNF ID " + vnf_id);
+ ctx.setAttribute(org.openecomp.appc.Constants.ATTRIBUTE_SUCCESS_MESSAGE, msg);
+
} catch (SvcLogicException e) {
- String errorMessage = String.format("Error in postVnfdata %s", e);
- ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, errorMessage);
- logger.error(errorMessage);
+ String msg = EELFResourceManager.format(Msg.AAI_QUERY_FAILED, vnf_id);
+ ctx.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, msg);
+ logger.error(msg);
throw new APPCException(e);
}
}
@@ -95,13 +104,14 @@ public class AAIPluginImpl implements AAIPlugin {
try {
SvcLogicResource.QueryStatus response = aaiClient.query("generic-vnf", false, null, key, prefix, null, ctx);
if (SvcLogicResource.QueryStatus.NOT_FOUND.equals(response)) {
- String errorMessage = String.format("VNF not found for vnf_id = %s", vnf_id);
- ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, errorMessage);
- throw new APPCException(errorMessage);
+ String msg = EELFResourceManager.format(Msg.VNF_NOT_FOUND, vnf_id);
+// String errorMessage = String.format("VNF not found for vnf_id = %s", vnf_id);
+ ctx.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, msg);
+ throw new APPCException(msg);
} else if (SvcLogicResource.QueryStatus.FAILURE.equals(response)) {
- String errorMessage = String.format("Error Querying AAI with vnfID = %s", vnf_id);
- ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, errorMessage);
- throw new APPCException(errorMessage);
+ String msg = EELFResourceManager.format(Msg.AAI_QUERY_FAILED, vnf_id);
+ ctx.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, msg);
+ throw new APPCException(msg);
}
String aaiEntitlementPoolUuid = ctx.getAttribute(Constants.AAI_ENTITLMENT_POOL_UUID_NAME);
if (null == aaiEntitlementPoolUuid) aaiEntitlementPoolUuid = "";
@@ -110,13 +120,261 @@ public class AAIPluginImpl implements AAIPlugin {
ctx.setAttribute(Constants.IS_RELEASE_ENTITLEMENT_REQUIRE, Boolean.toString(!aaiEntitlementPoolUuid.isEmpty()));
ctx.setAttribute(Constants.IS_RELEASE_LICENSE_REQUIRE, Boolean.toString(!aaiLicenseKeyGroupUuid.isEmpty()));
+ String msg = EELFResourceManager.format(Msg.SUCCESS_EVENT_MESSAGE, "GetGenericVnfData","VNF ID " + vnf_id);
+ ctx.setAttribute(org.openecomp.appc.Constants.ATTRIBUTE_SUCCESS_MESSAGE, msg);
logger.info("AAIResponse: " + response.toString());
} catch (SvcLogicException e) {
- String errorMessage = String.format("Error in getVnfdata %s", e);
- ctx.setAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE, errorMessage);
- logger.error(errorMessage);
+ String msg = EELFResourceManager.format(Msg.AAI_QUERY_FAILED, vnf_id);
+ ctx.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, msg);
+ logger.error(msg);
throw new APPCException(e);
}
}
+
+ @Override
+ public void getVnfHierarchy(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+
+ Map<Vnfc,Set<Vserver>> vnfcMap = new HashMap<>();
+ String vnfType,vnfVersion = null;
+ String vnfId = params.get("resourceKey");
+ AAIQueryResult vnfQueryResult = null;
+ int vmCount =0;
+ try {
+ vnfQueryResult = readVnf(vnfId);
+
+ vnfType = vnfQueryResult.getAdditionProperties().get("vnf-type");
+ vnfVersion = vnfQueryResult.getAdditionProperties().get("persona-model-version");
+
+ for(Relationship vnfRelationship:vnfQueryResult.getRelationshipList()){
+ if("vserver".equalsIgnoreCase(vnfRelationship.getRelatedTo())){
+ vmCount++;
+ String tenantId = vnfRelationship.getRelationShipDataMap().get("tenant.tenant-id");
+ String vmId = vnfRelationship.getRelationShipDataMap().get("vserver.vserver-id");
+ String vmRelatedLink = vnfRelationship.getRelatedLink();
+ String vmName = vnfRelationship.getRelatedProperties().get("vserver.vserver-name");
+ String cloudOwner = vnfRelationship.getRelationShipDataMap().get("cloud-region.cloud-owner");
+ String cloudRegionId = vnfRelationship.getRelationShipDataMap().get("cloud-region.cloud-region-id");
+
+ AAIQueryResult vmQueryResult = readVM(vmId,tenantId,cloudOwner,cloudRegionId);
+ String vmURL = vmQueryResult.getAdditionProperties().get("vserver-selflink");
+
+ Vserver vm = new Vserver(vmURL,tenantId,vmId,vmRelatedLink,vmName);
+ for(Relationship vmRelation:vmQueryResult.getRelationshipList()){
+
+ if("vnfc".equalsIgnoreCase(vmRelation.getRelatedTo())){
+ String vnfcName = vmRelation.getRelationShipDataMap().get("vnfc.vnfc-name");
+ AAIQueryResult vnfcQueryResult = readVnfc(vnfcName);
+ String vnfcType = vnfcQueryResult.getAdditionProperties().get("vnfc-type");
+
+ Vnfc vnfc = new Vnfc(vnfcType,null,vnfcName);
+ Set<Vserver> vmSet = vnfcMap.get(vnfc);
+ if(vmSet == null){
+ vmSet = new HashSet<>();
+ vnfcMap.put(vnfc,vmSet);
+ }
+ vmSet.add(vm);
+ }
+ }
+ }
+ }
+ ctx.setAttribute("VNF.VMCount",String.valueOf(vmCount));
+ } catch (AAIQueryException e) {
+ ctx.setAttribute("getVnfHierarchy_result", "FAILURE");
+ String msg = EELFResourceManager.format(Msg.AAI_QUERY_FAILED, vnfId);
+ ctx.setAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE, msg);
+ logger.error("Failed in getVnfHierarchy, Error retrieving VNF details. Error message: " + ctx
+ .getAttribute("getResource_result"));
+ logger.warn("Incorrect or Incomplete VNF Hierarchy");
+ throw new APPCException("Error Retrieving VNF hierarchy");
+ }
+
+ Vnf vnf = new Vnf(vnfId,vnfType,vnfVersion);
+ for(Vnfc vnfc:vnfcMap.keySet()){
+ for(Vserver vm:vnfcMap.get(vnfc)){
+ vnfc.addVm(vm);
+ }
+ vnf.addVnfc(vnfc);
+ }
+
+ populateContext(vnf,ctx);
+ ctx.setAttribute("getVnfHierarchy_result", "SUCCESS");
+ String msg = EELFResourceManager.format(Msg.SUCCESS_EVENT_MESSAGE, "GetVNFHierarchy","VNF ID " + vnfId);
+ ctx.setAttribute(org.openecomp.appc.Constants.ATTRIBUTE_SUCCESS_MESSAGE, msg);
+
+ }
+
+ private void populateContext(Vnf vnf ,SvcLogicContext ctx) {
+ ctx.setAttribute("vnf.type",vnf.getVnfType());
+ ctx.setAttribute("vnf.version",vnf.getVnfVersion());
+ ctx.setAttribute("vnf.vnfcCount",String.valueOf(vnf.getVnfcs().size()));
+ int vnfcCount =0;
+ for(Vnfc vnfc:vnf.getVnfcs()){
+ ctx.setAttribute("vnf.vnfc["+vnfcCount+"].name",vnfc.getVnfcName());
+ ctx.setAttribute("vnf.vnfc["+vnfcCount+"].type",vnfc.getVnfcType());
+ ctx.setAttribute("vnf.vnfc["+vnfcCount+"].vm_count",String.valueOf(vnfc.getVserverList().size()));
+ int vmCount =0;
+ for(Vserver vm:vnfc.getVserverList()){
+ ctx.setAttribute("vnf.vnfc["+vnfcCount+"].vm["+ vmCount++ +"].url",vm.getUrl());
+ }
+ vnfcCount++;
+ }
+ }
+
+ private AAIQueryResult readVnfc(String vnfcName) throws AAIQueryException {
+ String query = "vnfc.vnfc-name = '" + vnfcName + "'";
+ String prefix = "VNFC";
+ String resourceType = "vnfc";
+ SvcLogicContext vnfContext = readResource(query,prefix,resourceType);
+ String[] additionalProperties = new String[]{"vnfc-type","vnfc-name",
+ "vnfc-function-code","in-maint","prov-status",
+ "is-closed-loop-disabled","orchestration-status","resource-version"};
+ AAIQueryResult result = readRelationDataAndProperties(prefix, vnfContext,additionalProperties);
+ return result;
+ }
+
+ private AAIQueryResult readVM(String vmId,String tenantId,String cloudOwner,String cloudRegionId) throws AAIQueryException {
+ String query = "vserver.vserver-id = '" + vmId + "' AND tenant.tenant_id = '" + tenantId + "' AND cloud-region.cloud-owner = '"
+ + cloudOwner + "' AND cloud-region.cloud-region-id = '" + cloudRegionId + "'";
+ String prefix = "VM";
+ String resourceType = "vserver";
+ SvcLogicContext vnfContext = readResource(query,prefix,resourceType);
+ String[] additionalProperties = new String[]{"vserver-id","vserver-selflink",
+ "vserver-name","in-maint","prov-status","is-closed-loop-disabled",
+ "vserver-name2","resource-version",};
+ AAIQueryResult result = readRelationDataAndProperties(prefix, vnfContext,additionalProperties);
+
+ return result;
+ }
+
+ private AAIQueryResult readVnf(String vnfId) throws AAIQueryException {
+ String query = "generic-vnf.vnf-id = '" + vnfId + "'";
+ String prefix = "VNF";
+ String resourceType = "generic-vnf";
+ SvcLogicContext vnfContext = readResource(query,prefix,resourceType);
+
+ String[] additionalProperties = new String[]{"vnf-type","vnf-name",
+ "in-maint","prov-status","heat-stack-id",
+ "is-closed-loop-disabled","orchestration-status","resource-version","persona-model-version"};
+
+ AAIQueryResult result = readRelationDataAndProperties(prefix, vnfContext,additionalProperties);
+
+ return result;
+ }
+
+ private AAIQueryResult readRelationDataAndProperties(String prefix, SvcLogicContext context,String[] additionalProperties) {
+ AAIQueryResult result = new AAIQueryResult();
+
+ Integer relationsCount = Integer.parseInt(context.getAttribute(prefix + ".relationship-list.relationship_length"));
+ for(int i=0;i<relationsCount;i++){
+ Relationship relationShip = new Relationship();
+ relationShip.setRelatedLink(context.getAttribute(prefix + ".relationship-list.relationship["+i+"].related-link"));
+ relationShip.setRelatedTo(context.getAttribute(prefix + ".relationship-list.relationship["+i+"].related-to"));
+ Integer relationDataCount = Integer.parseInt(context.getAttribute(prefix + ".relationship-list.relationship["+i+"].relationship-data_length"));
+ for(int j=0;j<relationDataCount;j++){
+ String key = context.getAttribute(prefix+".relationship-list.relationship["+i+"].relationship-data["+j+"].relationship-key");
+ String value = context.getAttribute(prefix+".relationship-list.relationship["+i+"].relationship-data["+j+"].relationship-value");
+ relationShip.getRelationShipDataMap().put(key,value);
+ }
+ Integer relatedPropertyCount = 0;
+ String relatedPropertyCountStr = null;
+ try{
+ relatedPropertyCountStr =context.getAttribute(prefix + ".relationship-list.relationship["+i+"].related-to-property_length");
+ relatedPropertyCount = Integer.parseInt(relatedPropertyCountStr);
+ }
+ catch (NumberFormatException e){
+ logger.debug("Invalid value in the context for Related Property Count " + relatedPropertyCountStr);
+ }
+
+ for(int j=0;j<relatedPropertyCount;j++){
+ String key = context.getAttribute(prefix+".relationship-list.relationship["+i+"].related-to-property["+j+"].property-key");
+ String value = context.getAttribute(prefix+".relationship-list.relationship["+i+"].related-to-property["+j+"].property-value");
+ relationShip.getRelatedProperties().put(key,value);
+ }
+ result.getRelationshipList().add(relationShip);
+ }
+
+ for(String key:additionalProperties){
+ result.getAdditionProperties().put(key,context.getAttribute(prefix+"."+key));
+ }
+ return result;
+ }
+
+ private SvcLogicContext readResource(String query, String prefix, String resourceType) throws AAIQueryException {
+ SvcLogicContext resourceContext = new SvcLogicContext();
+ try {
+ SvcLogicResource.QueryStatus response = aaiClient.query(resourceType,false,null,query,prefix,null,resourceContext);
+ logger.info("AAIResponse: " + response.toString());
+ if(!SvcLogicResource.QueryStatus.SUCCESS.equals(response)){
+ throw new AAIQueryException("Error Retrieving VNF hierarchy from A&AI");
+ }
+ } catch (SvcLogicException e) {
+ logger.error(EELFResourceManager.format(Msg.AAI_GET_DATA_FAILED, query, "", e.getMessage()));
+ throw new AAIQueryException("Error Retrieving VNF hierarchy from A&AI");
+ }
+ return resourceContext;
+ }
+
+ @Override public void getResource(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ String resourceType = params.get("resourceType"), ctx_prefix = params.get("prefix"), resourceKey =
+ params.get("resourceKey");
+ if (logger.isDebugEnabled()) {
+ logger.debug("inside getResorce");
+ logger.debug("Retrieving " + resourceType + " details from A&AI for Key : " + resourceKey);
+ }
+ try {
+ SvcLogicResource.QueryStatus response =
+ aaiClient.query(resourceType, false, null, resourceKey, ctx_prefix, null, ctx);
+ logger.info("AAIResponse: " + response.toString());
+ ctx.setAttribute("getResource_result", response.toString());
+ } catch (SvcLogicException e) {
+ logger.error(EELFResourceManager.format(Msg.AAI_GET_DATA_FAILED, resourceKey, "", e.getMessage()));
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("exiting getResource======");
+ }
+ }
+
+ @Override public void postResource(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ String resourceType = params.get("resourceType"), ctx_prefix = params.get("prefix"), resourceKey =
+ params.get("resourceKey"), att_name = params.get("attributeName"), att_value =
+ params.get("attributeValue");
+ if (logger.isDebugEnabled()) {
+ logger.debug("inside postResource");
+ logger.debug("Updating " + resourceType + " details in A&AI for Key : " + resourceKey);
+ logger.debug("Updating " + att_name + " to : " + att_value);
+ }
+ Map<String, String> data = new HashMap<String, String>();
+ data.put(att_name, att_value);
+
+ try {
+ SvcLogicResource.QueryStatus response = aaiClient.update(resourceType, resourceKey, data, ctx_prefix, ctx);
+ logger.info("AAIResponse: " + response.toString());
+ ctx.setAttribute("postResource_result", response.toString());
+ } catch (SvcLogicException e) {
+ logger.error(EELFResourceManager.format(Msg.AAI_UPDATE_FAILED, resourceKey, att_value, e.getMessage()));
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("exiting postResource======");
+ }
+ }
+
+ @Override public void deleteResource(Map<String, String> params, SvcLogicContext ctx) throws APPCException {
+ String resourceType = params.get("resourceType"), resourceKey = params.get("resourceKey");
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("inside deleteResource");
+ logger.debug("Deleting " + resourceType + " details From A&AI for Key : " + resourceKey);
+ }
+ try {
+ SvcLogicResource.QueryStatus response = aaiClient.delete(resourceType, resourceKey, ctx);
+ logger.info("AAIResponse: " + response.toString());
+ ctx.setAttribute("deleteResource_result", response.toString());
+ } catch (SvcLogicException e) {
+ logger.error(EELFResourceManager.format(Msg.AAI_DELETE_FAILED, resourceKey, e.getMessage()));
+ }
+ if (logger.isDebugEnabled()) {
+ logger.debug("exiting deleteResource======");
+ }
+ }
}
diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/impl/Constants.java b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/impl/Constants.java
index 3feab4795..8957d3a8f 100644
--- a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/impl/Constants.java
+++ b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/impl/Constants.java
@@ -71,7 +71,7 @@ public class Constants {
public static final String VNF_HOST_IP_ADDRESS_FIELD_NAME = "vnf-host-ip-address";
public static final String UPGRADE_VERSION = "upgrade-version";
public static final String DG_ERROR_FIELD_NAME = "org.openecomp.appc.dg.error";
- public static final String DG_OUTPUT_STATUS_MESSAGE = "output.status.message";
+ public static final String ATTRIBUTE_ERROR_MESSAGE = "error-message";
public static final String RESOURCEKEY = "resourceKey";
public static final String REQ_ID_FIELD_NAME = "org.openecomp.appc.reqid";
public static final String API_VERSION_FIELD_NAME = "org.openecomp.appc.apiversion";
diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/objects/AAIQueryResult.java b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/objects/AAIQueryResult.java
new file mode 100644
index 000000000..0ad6292f9
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/objects/AAIQueryResult.java
@@ -0,0 +1,49 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.dg.aai.objects;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+
+public class AAIQueryResult {
+ private List<Relationship> relationshipList;
+
+ private Map<String,String> additionProperties;
+
+
+ public AAIQueryResult(){
+ relationshipList = new ArrayList<>();
+ additionProperties = new HashMap<>();
+ }
+
+
+ public List<Relationship> getRelationshipList() {
+ return relationshipList;
+ }
+
+ public Map<String, String> getAdditionProperties() {
+ return additionProperties;
+ }
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/objects/Relationship.java b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/objects/Relationship.java
new file mode 100644
index 000000000..63e6392a5
--- /dev/null
+++ b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/java/org/openecomp/appc/dg/aai/objects/Relationship.java
@@ -0,0 +1,66 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.dg.aai.objects;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+public class Relationship {
+
+ private String relatedTo;
+
+ private String relatedLink;
+
+ private Map<String,String> relationShipDataMap;
+
+ private Map<String,String> relatedProperties;
+
+ public Relationship(){
+ relationShipDataMap = new HashMap<>();
+ relatedProperties = new HashMap<>();
+ }
+
+ public String getRelatedTo() {
+ return relatedTo;
+ }
+
+ public String getRelatedLink() {
+ return relatedLink;
+ }
+
+ public Map<String, String> getRelationShipDataMap() {
+ return relationShipDataMap;
+ }
+
+ public Map<String, String> getRelatedProperties() {
+ return relatedProperties;
+ }
+
+ public void setRelatedTo(String relatedTo) {
+ this.relatedTo = relatedTo;
+ }
+
+ public void setRelatedLink(String relatedLink) {
+ this.relatedLink = relatedLink;
+ }
+}
diff --git a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/test/java/org/openecomp/appc/dg/aai/impl/AAIPluginImplTest.java b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/test/java/org/openecomp/appc/dg/aai/impl/AAIPluginImplTest.java
index 8d6fea0cf..eae221bc4 100644
--- a/appc-dg/appc-dg-shared/appc-dg-aai/src/main/test/java/org/openecomp/appc/dg/aai/impl/AAIPluginImplTest.java
+++ b/appc-dg/appc-dg-shared/appc-dg-aai/src/main/test/java/org/openecomp/appc/dg/aai/impl/AAIPluginImplTest.java
@@ -21,9 +21,7 @@
package org.openecomp.appc.dg.aai.impl;
-import org.junit.*;
import org.junit.runner.RunWith;
-import org.mockito.*;
import org.openecomp.appc.dg.aai.Constants;
import org.openecomp.appc.dg.aai.impl.AAIPluginImpl;
import org.openecomp.appc.dg.common.dao.DAOService;
@@ -40,12 +38,10 @@ import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
-import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;
import static org.junit.Assert.*;
-import static org.powermock.api.support.SuppressCode.suppressConstructor;
@RunWith(PowerMockRunner.class)
@@ -119,7 +115,7 @@ public class AAIPluginImplTest {
aaiPlugin.postGenericVnfData(params, ctx);
Assert.assertTrue(false);
} catch (APPCException e) {
- Assert.assertNotNull(ctx.getAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE));
+ Assert.assertNotNull(ctx.getAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE));
}
}
@@ -143,7 +139,7 @@ public class AAIPluginImplTest {
aaiPlugin.postGenericVnfData(params, ctx);
Assert.assertTrue(false);
} catch (APPCException e) {
- Assert.assertNotNull(ctx.getAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE));
+ Assert.assertNotNull(ctx.getAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE));
}
}
@@ -167,7 +163,7 @@ public class AAIPluginImplTest {
aaiPlugin.postGenericVnfData(params, ctx);
Assert.assertTrue(false);
} catch (APPCException e) {
- Assert.assertNotNull(ctx.getAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE));
+ Assert.assertNotNull(ctx.getAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE));
}
}
@@ -219,7 +215,7 @@ public class AAIPluginImplTest {
aaiPlugin.getGenericVnfData(params, ctx);
Assert.assertTrue(false);
} catch (APPCException e) {
- Assert.assertNotNull(ctx.getAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE));
+ Assert.assertNotNull(ctx.getAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE));
}
}
@@ -236,7 +232,7 @@ public class AAIPluginImplTest {
aaiPlugin.getGenericVnfData(params, ctx);
Assert.assertTrue(false);
} catch (APPCException e) {
- Assert.assertNotNull(ctx.getAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE));
+ Assert.assertNotNull(ctx.getAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE));
}
}
@@ -253,7 +249,7 @@ public class AAIPluginImplTest {
aaiPlugin.getGenericVnfData(params, ctx);
Assert.assertTrue(false);
} catch (APPCException e) {
- Assert.assertNotNull(ctx.getAttribute(Constants.DG_OUTPUT_STATUS_MESSAGE));
+ Assert.assertNotNull(ctx.getAttribute(Constants.ATTRIBUTE_ERROR_MESSAGE));
}
}