From e178b07914d5dc40157dede0078e16f645f20f17 Mon Sep 17 00:00:00 2001 From: Anand Chaturvedi Date: Mon, 14 Aug 2017 20:10:36 -0400 Subject: Added review comment Initial commit for Network-Inv and AAI client commit 61419e46211f1f1e763d4a84214c62a5e699bdf2 Author: Anand Chaturvedi Date: Mon Aug 14 19:54:11 2017 -0400 Issue-Id: APPC-21 [OnapMigration] OnapMigration for APPC OutBound Services.. Change-Id: I7db4bcb52b050988b601f3abac544c43f34c677b Signed-off-by: Anand Chaturvedi --- appc-outbound/appc-aai-client/.gitignore | 1 + appc-outbound/appc-aai-client/features/.gitignore | 1 + appc-outbound/appc-aai-client/features/pom.xml | 110 +++ .../features/src/main/resources/features.xml | 49 ++ appc-outbound/appc-aai-client/installer/.gitignore | 1 + appc-outbound/appc-aai-client/installer/pom.xml | 134 ++++ .../src/assembly/assemble_installer_zip.xml | 62 ++ .../src/assembly/assemble_mvnrepo_zip.xml | 50 ++ .../src/main/resources/scripts/install-feature.sh | 43 ++ appc-outbound/appc-aai-client/pom.xml | 48 ++ appc-outbound/appc-aai-client/provider/.gitignore | 1 + appc-outbound/appc-aai-client/provider/pom.xml | 124 ++++ .../appc/aai/client/AppcAaiClientActivator.java | 64 ++ .../appc/aai/client/AppcAaiClientConstant.java | 51 ++ .../openecomp/appc/aai/client/aai/AaiService.java | 781 +++++++++++++++++++++ .../appc/aai/client/node/AAIResourceNode.java | 514 ++++++++++++++ .../appc/aai/client/aai/MockAaiService.java | 46 ++ .../appc/aai/client/aai/TestAaiService.java | 63 ++ .../appc/aai/client/node/MockAaiService.java | 44 ++ .../appc/aai/client/node/TestAAIResourceNode.java | 57 ++ 20 files changed, 2244 insertions(+) create mode 100755 appc-outbound/appc-aai-client/.gitignore create mode 100755 appc-outbound/appc-aai-client/features/.gitignore create mode 100755 appc-outbound/appc-aai-client/features/pom.xml create mode 100644 appc-outbound/appc-aai-client/features/src/main/resources/features.xml create mode 100755 appc-outbound/appc-aai-client/installer/.gitignore create mode 100755 appc-outbound/appc-aai-client/installer/pom.xml create mode 100644 appc-outbound/appc-aai-client/installer/src/assembly/assemble_installer_zip.xml create mode 100644 appc-outbound/appc-aai-client/installer/src/assembly/assemble_mvnrepo_zip.xml create mode 100644 appc-outbound/appc-aai-client/installer/src/main/resources/scripts/install-feature.sh create mode 100755 appc-outbound/appc-aai-client/pom.xml create mode 100755 appc-outbound/appc-aai-client/provider/.gitignore create mode 100755 appc-outbound/appc-aai-client/provider/pom.xml create mode 100644 appc-outbound/appc-aai-client/provider/src/main/java/org/openecomp/appc/aai/client/AppcAaiClientActivator.java create mode 100644 appc-outbound/appc-aai-client/provider/src/main/java/org/openecomp/appc/aai/client/AppcAaiClientConstant.java create mode 100644 appc-outbound/appc-aai-client/provider/src/main/java/org/openecomp/appc/aai/client/aai/AaiService.java create mode 100644 appc-outbound/appc-aai-client/provider/src/main/java/org/openecomp/appc/aai/client/node/AAIResourceNode.java create mode 100644 appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/aai/MockAaiService.java create mode 100644 appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/aai/TestAaiService.java create mode 100644 appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/node/MockAaiService.java create mode 100644 appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/node/TestAAIResourceNode.java (limited to 'appc-outbound/appc-aai-client') diff --git a/appc-outbound/appc-aai-client/.gitignore b/appc-outbound/appc-aai-client/.gitignore new file mode 100755 index 000000000..b83d22266 --- /dev/null +++ b/appc-outbound/appc-aai-client/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/appc-outbound/appc-aai-client/features/.gitignore b/appc-outbound/appc-aai-client/features/.gitignore new file mode 100755 index 000000000..b83d22266 --- /dev/null +++ b/appc-outbound/appc-aai-client/features/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/appc-outbound/appc-aai-client/features/pom.xml b/appc-outbound/appc-aai-client/features/pom.xml new file mode 100755 index 000000000..413f3a7ae --- /dev/null +++ b/appc-outbound/appc-aai-client/features/pom.xml @@ -0,0 +1,110 @@ + + + 4.0.0 + + appc-aai-client + org.openecomp.appc + 1.1.0-SNAPSHOT + + appc-aai-client-features + APPC AAI Client Plugin - Features + jar + + + + org.openecomp.appc + appc-aai-client-provider + ${project.version} + + + + commons-lang + commons-lang + compile + + + + org.opendaylight.mdsal + features-mdsal + features + xml + + runtime + + + + + + org.opendaylight.controller + opendaylight-karaf-empty + zip + + + + + + org.opendaylight.odlparent + features-test + ${odl.commons.opendaylight.version} + test + + + + + + + + true + src/main/resources + + + + + org.apache.maven.plugins + maven-resources-plugin + + + filter + + resources + + generate-resources + + + + + + org.codehaus.mojo + build-helper-maven-plugin + + + attach-artifacts + + attach-artifact + + package + + + + ${project.build.directory}/classes/${features.file} + xml + features + + + + + + + + + diff --git a/appc-outbound/appc-aai-client/features/src/main/resources/features.xml b/appc-outbound/appc-aai-client/features/src/main/resources/features.xml new file mode 100644 index 000000000..84017dd7c --- /dev/null +++ b/appc-outbound/appc-aai-client/features/src/main/resources/features.xml @@ -0,0 +1,49 @@ + + + + + + + + mvn:org.opendaylight.mdsal/features-mdsal/${odl.mdsal.features.version}/xml/features + + + + odl-mdsal-broker + + sdnc-sli + sdnc-aai-service + mvn:commons-lang/commons-lang/2.6 + + mvn:commons-collections/commons-collections/3.2.1 + wrap:mvn:com.att.eelf/eelf-core/${eelf.version} + mvn:ch.qos.logback/logback-core/${logback.version} + mvn:ch.qos.logback/logback-classic/${logback.version} + mvn:org.openecomp.appc/appc-aai-client-provider/${project.version} + + diff --git a/appc-outbound/appc-aai-client/installer/.gitignore b/appc-outbound/appc-aai-client/installer/.gitignore new file mode 100755 index 000000000..b83d22266 --- /dev/null +++ b/appc-outbound/appc-aai-client/installer/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/appc-outbound/appc-aai-client/installer/pom.xml b/appc-outbound/appc-aai-client/installer/pom.xml new file mode 100755 index 000000000..99e3fe067 --- /dev/null +++ b/appc-outbound/appc-aai-client/installer/pom.xml @@ -0,0 +1,134 @@ + + + 4.0.0 + + appc-aai-client + org.openecomp.appc + 1.1.0-SNAPSHOT + + appc-aai-client-installer + APPC AAI Client -Installer + pom + + + appc-aai-client + appc-aai-client + mvn:org.openecomp.appc/appc-aai-client-features/${project.version}/xml/features + false + + + + + + org.openecomp.appc + appc-aai-client-features + ${project.version} + features + xml + + + * + * + + + + + org.openecomp.appc + appc-aai-client-provider + ${project.version} + + + + + + + + maven-assembly-plugin + + + maven-repo-zip + + single + + package + + false + false + stage/${application.name}-${project.version} + + src/assembly/assemble_mvnrepo_zip.xml + + + + + installer-zip + + single + + package + + false + true + ${application.name}-${project.version} + + src/assembly/assemble_installer_zip.xml + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + + + copy-dependencies + + copy-dependencies + + prepare-package + + false + ${project.build.directory}/assembly/system + false + true + true + true + false + false + org.opendaylight + provided + + + + + + maven-resources-plugin + + + copy-version + + copy-resources + + + validate + + ${basedir}/target/stage + + + src/main/resources/scripts + + install-feature.sh + + true + + + + + + + + + + diff --git a/appc-outbound/appc-aai-client/installer/src/assembly/assemble_installer_zip.xml b/appc-outbound/appc-aai-client/installer/src/assembly/assemble_installer_zip.xml new file mode 100644 index 000000000..e54eede04 --- /dev/null +++ b/appc-outbound/appc-aai-client/installer/src/assembly/assemble_installer_zip.xml @@ -0,0 +1,62 @@ + + + + + + controller + + zip + + + + false + + + + target/stage/ + ${application.name} + 755 + + *.sh + + + + target/stage/ + ${application.name} + 644 + + *.sh + + + + + + + diff --git a/appc-outbound/appc-aai-client/installer/src/assembly/assemble_mvnrepo_zip.xml b/appc-outbound/appc-aai-client/installer/src/assembly/assemble_mvnrepo_zip.xml new file mode 100644 index 000000000..fc99e918e --- /dev/null +++ b/appc-outbound/appc-aai-client/installer/src/assembly/assemble_mvnrepo_zip.xml @@ -0,0 +1,50 @@ + + + + + + controller + + zip + + + + false + + + + target/assembly/ + . + + + + + + diff --git a/appc-outbound/appc-aai-client/installer/src/main/resources/scripts/install-feature.sh b/appc-outbound/appc-aai-client/installer/src/main/resources/scripts/install-feature.sh new file mode 100644 index 000000000..05b4ae373 --- /dev/null +++ b/appc-outbound/appc-aai-client/installer/src/main/resources/scripts/install-feature.sh @@ -0,0 +1,43 @@ +### +# ============LICENSE_START======================================================= +# ONAP : APPC +# ================================================================================ +# Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. +# ================================================================================ +# Copyright (C) 2017 Amdocs +# ============================================================================= +# 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========================================================= +### + +#!/bin/bash + +ODL_HOME=${ODL_HOME:-/opt/opendaylight/current} +ODL_KARAF_CLIENT=${ODL_KARAF_CLIENT:-${ODL_HOME}/bin/client} +ODL_KARAF_CLIENT_OPTS=${ODL_KARAF_CLIENT_OPTS:-"-u karaf"} +INSTALLERDIR=$(dirname $0) + +REPOZIP=${INSTALLERDIR}/${features.boot}-${project.version}.zip + +if [ -f ${REPOZIP} ] +then + unzip -n -d ${ODL_HOME} ${REPOZIP} +else + echo "ERROR : repo zip ($REPOZIP) not found" + exit 1 +fi + +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:repo-add ${features.repositories} +${ODL_KARAF_CLIENT} ${ODL_KARAF_CLIENT_OPTS} feature:install ${features.boot} diff --git a/appc-outbound/appc-aai-client/pom.xml b/appc-outbound/appc-aai-client/pom.xml new file mode 100755 index 000000000..5c25bb3ba --- /dev/null +++ b/appc-outbound/appc-aai-client/pom.xml @@ -0,0 +1,48 @@ + + + + org.openecomp.appc + appc-outbound + 1.1.0-SNAPSHOT + + + 4.0.0 + pom + appc-aai-client + + APPC AAI Client for Node + http://wiki.sdn.labs.att.com + Common Utilities for DG + + + + + org.openecomp.appc + appc-aai-client.features + features + xml + ${project.version} + + + + org.openecomp.appc + appc-aai-client.provider + ${project.version} + + + org.openecomp.appc + appc-aai-client.installer + ${project.version} + + + + + + + + provider + features + installer + + diff --git a/appc-outbound/appc-aai-client/provider/.gitignore b/appc-outbound/appc-aai-client/provider/.gitignore new file mode 100755 index 000000000..b83d22266 --- /dev/null +++ b/appc-outbound/appc-aai-client/provider/.gitignore @@ -0,0 +1 @@ +/target/ diff --git a/appc-outbound/appc-aai-client/provider/pom.xml b/appc-outbound/appc-aai-client/provider/pom.xml new file mode 100755 index 000000000..0604b1ad0 --- /dev/null +++ b/appc-outbound/appc-aai-client/provider/pom.xml @@ -0,0 +1,124 @@ + + + 4.0.0 + + org.openecomp.appc + appc-aai-client + 1.1.0-SNAPSHOT + + appc-aai-client-provider + bundle + APPC AAI Client - Provider + + + UTF-8 + + + + equinoxSDK381 + org.eclipse.osgi + ${equinox.osgi.version} + + + org.openecomp.sdnc.core + sli-provider + compile + + + + org.openecomp.sdnc.adaptors + aai-service-provider + compile + + + + + commons-io + commons-io + 2.5 + + + + com.att.eelf + eelf-core + + + + junit + junit + test + + + + + + + + + maven-resources-plugin + 2.6 + + + copy-xsl + + copy-resources + + validate + + ${basedir}/target/templates/xslt/sbg + + + src/main/resources/xsl + + * + + true + + + + + + copy-properties + + copy-resources + + validate + + ${basedir}/target/properties/ + + + src/main/resources + + *.properties + + true + + + + + + + + org.apache.felix + maven-bundle-plugin + ${bundle.plugin.version} + true + + + org.openecomp.appc.aai.client + org.openecomp.appc.aai.client.AppcAaiClientActivator + org.openecomp.appc.aai.client + * + * + + ${project.basedir}/src/main/resources/META-INF + + + + + + + + + diff --git a/appc-outbound/appc-aai-client/provider/src/main/java/org/openecomp/appc/aai/client/AppcAaiClientActivator.java b/appc-outbound/appc-aai-client/provider/src/main/java/org/openecomp/appc/aai/client/AppcAaiClientActivator.java new file mode 100644 index 000000000..2f35805b7 --- /dev/null +++ b/appc-outbound/appc-aai-client/provider/src/main/java/org/openecomp/appc/aai/client/AppcAaiClientActivator.java @@ -0,0 +1,64 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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.openecomp.appc.aai.client; + +import java.util.LinkedList; +import java.util.List; +import java.util.Properties; + +import org.openecomp.appc.aai.client.node.AAIResourceNode; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +public class AppcAaiClientActivator implements BundleActivator { + + private static final EELFLogger log = EELFManager.getInstance().getLogger(AppcAaiClientActivator.class); + private List registrations = new LinkedList(); + + @Override + public void start(BundleContext ctx) throws Exception { + + + + AAIResourceNode aaiResourceNode = new AAIResourceNode(); + log.info("Registering service-- " + aaiResourceNode.getClass().getName()); + registrations.add(ctx.registerService(aaiResourceNode.getClass().getName(), aaiResourceNode, null)); + + + } + + @Override + public void stop(BundleContext arg0) throws Exception { + for (ServiceRegistration registration : registrations) { + registration.unregister(); + registration = null; + } + } +} diff --git a/appc-outbound/appc-aai-client/provider/src/main/java/org/openecomp/appc/aai/client/AppcAaiClientConstant.java b/appc-outbound/appc-aai-client/provider/src/main/java/org/openecomp/appc/aai/client/AppcAaiClientConstant.java new file mode 100644 index 000000000..7521d76da --- /dev/null +++ b/appc-outbound/appc-aai-client/provider/src/main/java/org/openecomp/appc/aai/client/AppcAaiClientConstant.java @@ -0,0 +1,51 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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.openecomp.appc.aai.client; + +public class AppcAaiClientConstant { + + + + + public static String INPUT_PARAM_RESPONSE_PREFIX = "responsePrefix"; + public static String OUTPUT_STATUS_SUCCESS = "success"; + public static String OUTPUT_STATUS_FAILURE = "failure"; + + public static String OUTPUT_PARAM_STATUS = "status"; + public static String OUTPUT_PARAM_ERROR_MESSAGE = "error-message"; + + + public static final String INPUT_PARAM_VM_INSTANCE = "vmInstance"; + + + public static final Object INPUT_PARAM_VNF_ID = "vnfId"; + public static final Object INPUT_PARAM_VM_NAME = "vmName"; + + public static final String INPUT_PARAM_FILE_ID = "fileId"; + + + + +} diff --git a/appc-outbound/appc-aai-client/provider/src/main/java/org/openecomp/appc/aai/client/aai/AaiService.java b/appc-outbound/appc-aai-client/provider/src/main/java/org/openecomp/appc/aai/client/aai/AaiService.java new file mode 100644 index 000000000..388f5caa1 --- /dev/null +++ b/appc-outbound/appc-aai-client/provider/src/main/java/org/openecomp/appc/aai/client/aai/AaiService.java @@ -0,0 +1,781 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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.openecomp.appc.aai.client.aai; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; + +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.math.NumberUtils; + +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicResource; +import org.openecomp.sdnc.sli.SvcLogicResource.QueryStatus; + +import org.openecomp.appc.aai.client.AppcAaiClientConstant; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.openecomp.sdnc.sli.aai.AAIClient; +import org.openecomp.sdnc.sli.aai.AAIService; +import org.osgi.framework.BundleContext; +import org.osgi.framework.FrameworkUtil; +import org.osgi.framework.ServiceReference; + +public class AaiService { + + private static final EELFLogger log = EELFManager.getInstance().getLogger(AaiService.class); + private AAIClient aaiClient; + + + public AaiService(AAIClient aaiClient) { + this.aaiClient = aaiClient; + } + + public AaiService() { + BundleContext bctx = FrameworkUtil.getBundle(this.getClass()).getBundleContext(); + ServiceReference sref = bctx.getServiceReference(AAIService.class); + aaiClient = (AAIClient) bctx.getService(sref); + } + + public void getGenericVnfInfo(Map params, SvcLogicContext ctx) throws Exception { + + + String vnfId = params.get("vnfId"); + if(StringUtils.isBlank(vnfId)){ + throw new Exception("VnfId is missing"); + } + + String prefix = params.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX); + + + prefix = StringUtils.isNotBlank(prefix) ? (prefix+".") : ""; + + + //String resourceKey = "generic-vnf.vnf-id = '" + vnfId + "' AND relationship-key = 'vserver.vserver-id'"; + + String resourceKey = "generic-vnf.vnf-id = '" + vnfId + "'"; + + String resourceType = "generic-vnf"; + String queryPrefix = "vnfInfo"; + SvcLogicContext vnfCtx = readResource(resourceKey,queryPrefix,resourceType); + + + + + ctx.setAttribute(prefix + "vnf.vnf-name", vnfCtx.getAttribute("vnfInfo.vnf-name")); + ctx.setAttribute(prefix + "vnf.vnf-type", vnfCtx.getAttribute("vnfInfo.vnf-type")); + ctx.setAttribute(prefix + "vnf.prov-status", vnfCtx.getAttribute("vnfInfo.prov-status")); + ctx.setAttribute(prefix + "vnf.orchestration-status", vnfCtx.getAttribute("vnfInfo.orchestration-status")); + + + + int vmCount = 0; + + + String relLen = vnfCtx.getAttribute("vnfInfo.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 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 cloudRegionId = getRelationshipValue(i, vnfCtx, "vserver", "cloud-region.cloud-region-id", "vnfInfo"); + + 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); + + vmCount++; + } + } + + + + ctx.setAttribute(prefix + "vm-count", String.valueOf(vmCount)); + + log.info("VMCOUNT FROM VNF INFO " + ctx.getAttribute(prefix + "vm-count")); + + + + + } + + + + public void getVMInfo(Map 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); + + + + + + 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", "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 { + + + if ( relatedTo.equals(ctx.getAttribute(prefix + ".relationship-list.relationship[" + i + "].related-to")) ) { + + + log.info("RELATEDTO " + relatedTo); + int relationshipDataLength = 0; + String relDataLen = ctx.getAttribute(prefix + ".relationship-list.relationship[" + 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 value = ctx.getAttribute(prefix + ".relationship-list.relationship[" + i + "].relationship-data[" + j + "].relationship-value"); + + log.info("GENERIC KEY " + key); + log.info("GENERIC VALUE " + value); + + if (relationshipKey.equals(key)) { + return value; + + } + + } // relationshipDataLength + + + } // if related-To + + + return null; + + + } + + + public void getVnfcInfo(Map params,SvcLogicContext ctx ) throws Exception { + log.info("Received getVnfc call with params : " + params); + + String prefix = params.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX); + prefix = StringUtils.isNotBlank(prefix) ? (prefix+".") : ""; + + String vnfcName = params.get("vnfcName"); + if(StringUtils.isBlank(vnfcName)){ + throw new Exception("Vnfc Name is missing"); + } + + String resourceKey = "vnfc.vnfc-name = '" + vnfcName + "'"; + + String queryPrefix = "vnfcInfo"; + String resourceType = "vnfc"; + SvcLogicContext vnfcCtx = readResource(resourceKey,queryPrefix,resourceType); + + // Changes for US 315820 for 1710 vnfc-type renamed to nfc-function,vnfc-function-code renamed to nfc-naming-code + + /*ctx.setAttribute(prefix+ "vnfc.vnfc-type", vnfcCtx.getAttribute("vnfcInfo.vnfc-type")); + ctx.setAttribute(prefix+ "vnfc.vnfc-function-code", vnfcCtx.getAttribute("vnfcInfo.vnfc-function-code")); + ctx.setAttribute(prefix+ "vnfc.group-notation", vnfcCtx.getAttribute("vnfcInfo.group-notation"));*/ + + ctx.setAttribute(prefix+ "vnfc.vnfc-type", vnfcCtx.getAttribute("vnfcInfo.nfc-function")); + ctx.setAttribute(prefix+ "vnfc.vnfc-function-code", vnfcCtx.getAttribute("vnfcInfo.nfc-naming-code")); + ctx.setAttribute(prefix+ "vnfc.group-notation", vnfcCtx.getAttribute("vnfcInfo.group-notation")); + + + } + + public void insertVnfcs(Map params,SvcLogicContext ctx, int vnfcRefLen, int vmCount) throws Exception { + log.info("Received insertVnfcs call with params : " + params); + + String prefix = params.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX); + + prefix = StringUtils.isNotBlank(prefix) ? (prefix+".") : ""; + + + + 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")); + String numVnfcsStr = ctx.getAttribute(aaiRefKey + "vnfc-count"); + + + //if ( numVnfcsStr != null || Integer.parseInt(numVnfcsStr) >= 1 ) + + + if ( ctx.getAttribute(aaiRefKey + "vnfc-name") != null ) + continue; + else + vnfcRefIndx++; + + + // Get Vnfc_reference data + String vnfcRefKey = "vnfcReference[" + vnfcRefIndx + "]."; + + log.info("VNFCREFKEY " + vnfcRefKey); + log.info("AAIREFKEY " + aaiRefKey); + + String vmInstance = ctx.getAttribute(vnfcRefKey+ "VM-INSTANCE"); + String vnfcInstance = ctx.getAttribute(vnfcRefKey+ "VNFC-INSTANCE"); + + 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 populateIpAddressV4OamVip = ctx.getAttribute(vnfcRefKey+ "IPADDRESS-V4-OAM-VIP"); + + + // Get vnfc Data to be added + String vserverName = ctx.getAttribute(aaiRefKey + "vserver-name"); + String vnfcName = vserverName + vnfcFuncCode + "001"; + + String groupNotation = getGroupNotation(groupNotationType, groupNotationValue, vnfcName, vserverName,prefix, ctx, vnfcType); + + + String ipAddressV4OamVip = null; + if ( "Y".equals(populateIpAddressV4OamVip)) + ipAddressV4OamVip = ctx.getAttribute("vnf-host-ip-address"); // from input + + + Map vnfcParams = populateVnfcParams(ctx, aaiRefKey, ipAddressV4OamVip, groupNotation, vnfcType, vnfcFuncCode); + + + addVnfc( vnfcName, vnfcParams, prefix); + + // Add VNFC Info to context for current added VNFC + ctx.setAttribute(aaiRefKey + "vnfc-name", vnfcName); + ctx.setAttribute(aaiRefKey + "vnfc-type", vnfcType); + ctx.setAttribute(aaiRefKey + "vnfc-function-code", vnfcFuncCode); + ctx.setAttribute(aaiRefKey + "group-notation", groupNotation); + + } + + + } + + + + public Map populateVnfcParams(SvcLogicContext ctx, String aaiRefKey, + String ipAddressV4OamVip, String groupNotation, String vnfcType, String vnfcFuncCode) throws Exception { + + + Map vnfcParams = new HashMap(); + + // Changes for US 315820 for 1710 vnfc-type renamed to nfc-function,vnfc-function-code renamed to nfc-naming-code + + /* + vnfcParams.put("vnfc-function-code", vnfcFuncCode); + vnfcParams.put("vnfc-type", vnfcType); + */ + 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("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].relationship-data[0].relationship-key","vserver.vserver-id"); + vnfcParams.put("relationship-list.relationship[0].relationship-data[0].relationship-value",ctx.getAttribute(aaiRefKey + "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")); + + + 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",ctx.getAttribute(aaiRefKey + "cloud-owner")); + + + 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",ctx.getAttribute(aaiRefKey + "cloud-region-id")); + + + + 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",ctx.getAttribute("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")); + + + 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",ctx.getAttribute(aaiRefKey + "vf-module-id")); + + + return vnfcParams; + } + + public void addVnfc(String vnfcName, Map params, String prefix) throws Exception { + + log.info("Received addVnfc call with vnfcName : " +vnfcName); + log.info("Received addVnfc call with params : " + params); + String resourceKey = "vnfc.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) ; + + 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); + + } + + + } + + public String getGroupNotation(String groupNotationType, String groupNotationValue, String vnfcName, + String vserverName, String prefix, SvcLogicContext ctx, String vnfcRefVnfcType) throws Exception { + + String grpNotation = null; + + if ( "fixed-value".equals(groupNotationType)) { + grpNotation = groupNotationValue; + + } + else if ( "first-vnfc-name".equals(groupNotationType) ) { + + /*If the group-notation-type value = ?first-vnfc-name?, + * then populate the group-notation value with the concatenation of + * [vnfc name associated with the first vnfc for the vnfc-type (e.g., *******)] + * and [the value in group-notation-value (e.g., pair)]. + * There may be several vnfc-types associated with the VM?s. + */ + /* Vnfc-type should be from refrence data */ + + /* vDBE has 2 VNFCs with same VNFC type . The pair name should be same for both . */ + /* When first VNFC is added details should be added to context so FirstVnfcName doesnt return null second time. */ + String tmpVnfcName = getFirstVnfcNameForVnfcType(ctx, prefix, vnfcRefVnfcType); + + 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; + + + } + else if ( "relative-value".equals(groupNotationType) ) { + + /*If the group-notation-type = ?relative-value?, then find the group-notation value + * from the prior vnfc (where prior means the vnfc with where the last three digits of the + * vm-name is one lower than the current one; note that this vnfc may have been previously configured.) + 1. If the group-notation-value = next, then add 1 to the group-notation value from the prior vnfc and use this value + 2. If the group-notation-value = same, then use the group-notation-value from the prior vnfc record*/ + + // next and same cant be defined for first VM. if next will not generate grpNotation if Prior is not a number + String tmpVserverName = null; + if ( vserverName != null ) { + + String vmNamePrefix = vserverName.substring(0,vserverName.length()-3); + + String lastThreeChars = vserverName.substring(vserverName.length() - 3); + + if ( NumberUtils.isDigits(lastThreeChars)) { + int vmNum = Integer.parseInt(lastThreeChars) - 1; + String formatted = String.format("%03d", vmNum); + + log.info("FORMATTED " + formatted); + + 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); + } + } + } + + } + + + + } + + + log.info("RETURNED GROUPNOTATION " + grpNotation); + return grpNotation; + } + + public String getGroupNotationForVServer(SvcLogicContext ctx, String prefix, String vserverName) throws Exception { + + + String vmCountStr = ctx.getAttribute(prefix+"vnf.vm-count"); + + if ( vmCountStr == null ) + return null; + + int vmCount = Integer.valueOf(vmCountStr); + for ( int i = 0; i < vmCount ; i++ ) { + + String tmpVserver = ctx.getAttribute(prefix+ "vm[" + i + "].vserver-name"); + + if (vserverName.equals(tmpVserver)) + return ctx.getAttribute(prefix+ "vm[" + i + "].group-notation"); + + } // vmCount + + return null; + + } + + + + + public String getFirstVnfcNameForVnfcType(SvcLogicContext ctx, String prefix, String vnfcRefVnfcType) throws Exception { + + + + /*if(StringUtils.isBlank(vnfcRefVnfcType)){ + throw new Exception("Vnfc Reference : VNFC Type is missing"); + }*/ + + + String vmCountStr = ctx.getAttribute(prefix+"vnf.vm-count"); + + if ( vmCountStr == null ) + return null; + + int vmCount = Integer.valueOf(vmCountStr); + for ( int i = 0; i < vmCount ; i++ ) { + + String tmpvnfcType = ctx.getAttribute(prefix+ "vm[" + i + "].vnfc-type"); + + if (vnfcRefVnfcType.equals(tmpvnfcType)) + return ctx.getAttribute(prefix+ "vm[" + i + "].vnfc-name"); + + } // vmCount + + + + return null; + + } + + public void updateVServerStatus(Map params,SvcLogicContext ctx, int vmCount) throws Exception { + log.info("Received updateVServerStatus call with params : " + params); + + String prefix = params.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX); + + prefix = StringUtils.isNotBlank(prefix) ? (prefix+".") : ""; + + + Map 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("orchestration-status", "CONFIGURED"); + + + for ( int i = 0; i < vmCount ; i++ ) { + String aaiRefKey = prefix + "vm[" + i + "]."; + + log.info("VNFCNAME IN UpdateVServer " + ctx.getAttribute(aaiRefKey + "vnfc-name")); + + if ( ctx.getAttribute(aaiRefKey + "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") + "'"; + + + updateResource( "vserver", resourceKey, vServerParams); + + } + + + } + + + + public void updateVnfStatus(Map params,SvcLogicContext ctx) throws Exception { + log.info("Received updateVnfStatus call with params : " + params); + + String prefix = params.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX); + + prefix = StringUtils.isNotBlank(prefix) ? (prefix+".") : ""; + + + Map 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("orchestration-status", "CONFIGURED"); + + + String resourceKey = "generic-vnf.vnf-id = '" + ctx.getAttribute("vnf-id") + "'"; + + updateResource( "generic-vnf" , resourceKey, vnfParams); + + + + + } + + public void updateResource( String resource, String resourceKey, Map params) throws Exception { + + log.info("Received updateResource call with Key : " +resourceKey); + + + SvcLogicContext ctx = new SvcLogicContext(); + + + SvcLogicResource.QueryStatus response = aaiClient.update(resource, resourceKey , params, "tmp.update", ctx); + + + + if (SvcLogicResource.QueryStatus.SUCCESS.equals(response)) { + log.info("Updated " + resource + " SUCCESSFULLY for " + resourceKey); + + } + else if (SvcLogicResource.QueryStatus.FAILURE.equals(response)) { + throw new Exception(resource + " Update failed for " + resourceKey); + + } + } + + public SvcLogicContext readResource(String query, String prefix, String resourceType) throws Exception { + SvcLogicContext resourceContext = new SvcLogicContext(); + + SvcLogicResource.QueryStatus response = 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"); + } + + return resourceContext; + + + + } + + //Added 1710 & Backward Compatibility + + public void checkAndUpdateVnfc(Map params,SvcLogicContext ctx, int vnfcRefLen, int vmCount) throws Exception { + log.info("Received checkAndUpdateVnfcStatus call with params : " + params); + + String prefix = params.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX); + + prefix = StringUtils.isNotBlank(prefix) ? (prefix+".") : ""; + + 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")); + + String numVnfcsStr = ctx.getAttribute(aaiRefKey + "vnfc-count"); + String vnfcNameAai = ctx.getAttribute(aaiRefKey + "vnfc-name"); + + if (StringUtils.isNotBlank(vnfcNameAai)) { + // Get Vnfc_reference data + for(int vnfcRefIndx=0;vnfcRefIndx < vnfcRefLen;vnfcRefIndx++ ) { + + String vnfcRefKey = "vnfcReference[" + vnfcRefIndx + "]."; + + log.info("VNFCREFKEY " + vnfcRefKey); + log.info("AAIREFKEY " + aaiRefKey); + + String vnfcFuncCode = ctx.getAttribute(vnfcRefKey+ "VNFC-FUNCTION-CODE"); + String vserverName = ctx.getAttribute(aaiRefKey + "vserver-name"); + String vnfcNameReference = vserverName + vnfcFuncCode + "001"; + + if(vnfcNameAai.equals(vnfcNameReference)) { + + updateVnfcStatus( vnfcNameAai, params, prefix); + } + + + } + } + + + + + + + } + + + } + + public void updateVnfcStatus(String vnfcName, Map params, String prefix) throws Exception { + + log.info("Received updateVnfcStatus call with vnfcName : " +vnfcName); + log.info("Received updateVnfcStatus call with params : " + params); + + String resourceKey = "vnfc.vnfc-name = '" + vnfcName + "'"; + log.info("Received updateVnfcStatus call with resourceKey : " + resourceKey); + + + Map vnfcParams = new HashMap(); + vnfcParams.put("prov-status", "NVTPROV"); + vnfcParams.put("orchestration-status", "CONFIGURED"); + + log.info("In updateVnfcStatus call with vnfcParams : " + vnfcParams); + + updateResource( "vnfc" , resourceKey, vnfcParams); + + log.info("End of updateVnfcStatus"); + + + } + + + + //Added for 1710 + + +} diff --git a/appc-outbound/appc-aai-client/provider/src/main/java/org/openecomp/appc/aai/client/node/AAIResourceNode.java b/appc-outbound/appc-aai-client/provider/src/main/java/org/openecomp/appc/aai/client/node/AAIResourceNode.java new file mode 100644 index 000000000..d2797c8db --- /dev/null +++ b/appc-outbound/appc-aai-client/provider/src/main/java/org/openecomp/appc/aai/client/node/AAIResourceNode.java @@ -0,0 +1,514 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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.openecomp.appc.aai.client.node; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.lang3.StringUtils; + +import org.openecomp.appc.aai.client.AppcAaiClientConstant; +import org.openecomp.appc.aai.client.aai.AaiService; + + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicException; +import org.openecomp.sdnc.sli.SvcLogicJavaPlugin; + +//import com.fasterxml.jackson.databind.ObjectMapper; + + +public class AAIResourceNode implements SvcLogicJavaPlugin { + + private static final EELFLogger log = EELFManager.getInstance().getLogger(AAIResourceNode.class); + + + public AaiService getAaiService() { + return new AaiService(); + } + /* Gets VNF Info and All VServers associated with Vnf */ + public void getVnfInfo(Map inParams, SvcLogicContext ctx) throws SvcLogicException { + + log.info("Received getVnfInfo call with params : " + inParams); + + String responsePrefix = inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX); + + try { + + + responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : ""; + AaiService aai = getAaiService(); + + + + aai.getGenericVnfInfo(inParams,ctx); + + + + + ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS, + AppcAaiClientConstant.OUTPUT_STATUS_SUCCESS); + log.info("getVnfInfo Successful "); + } catch (Exception e) { + ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS, + AppcAaiClientConstant.OUTPUT_STATUS_FAILURE); + ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage()); + log.error("Failed in getVnfInfo " + e.getMessage()); + + throw new SvcLogicException(e.getMessage()); + } + } + + + + public void getAllVServersVnfcsInfo(Map inParams, SvcLogicContext ctx) throws SvcLogicException { + + log.info("Received getAllVServersVnfcsInfo call with params : " + inParams); + + String responsePrefix = inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX); + + try { + responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : ""; + AaiService aai = getAaiService(); + + + + ArrayList> vservers = new ArrayList>(); + + int vmWithNoVnfcsCount = 0; + String vmCountStr = ctx.getAttribute(responsePrefix + "vm-count"); + + if ( vmCountStr == null ) + throw new Exception("Unable to get VServers for the VNF"); + + int vmCount = Integer.parseInt(vmCountStr); + for ( int i = 0; i < vmCount; i++ ) { + + SvcLogicContext vmServerCtx = new SvcLogicContext(); + + Map paramsVm = new HashMap(); + paramsVm.put("vserverId", ctx.getAttribute(responsePrefix + "vm[" + i + "].vserver-id")); + paramsVm.put("tenantId", ctx.getAttribute(responsePrefix +"vm[" + i + "].tenant-id")); + paramsVm.put("cloudOwner", ctx.getAttribute(responsePrefix +"vm[" + i + "].cloud-owner")); + paramsVm.put("cloudRegionId", ctx.getAttribute(responsePrefix +"vm[" + i + "].cloud-region-id")); + paramsVm.put(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX, inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX)); + + + + aai.getVMInfo(paramsVm, vmServerCtx); + + HashMap vserverMap = new HashMap(); + vserverMap.put("vserver-id", ctx.getAttribute(responsePrefix + "vm[" + i + "].vserver-id")); + vserverMap.put("tenant-id", ctx.getAttribute(responsePrefix +"vm[" + i + "].tenant-id")); + vserverMap.put("cloud-owner", ctx.getAttribute(responsePrefix +"vm[" + i + "].cloud-owner")); + vserverMap.put("cloud-region-id", ctx.getAttribute(responsePrefix +"vm[" + i + "].cloud-region-id")); + + // Parameters returned by getVMInfo + vserverMap.put("vserver-name", vmServerCtx.getAttribute(responsePrefix + "vm.vserver-name")); + vserverMap.put("vf-module-id", vmServerCtx.getAttribute(responsePrefix + "vm.vf-module-id")); + + + // as Per 17.07 requirements we are supporting only one VNFC per VM. + + String vnfcName = vmServerCtx.getAttribute(responsePrefix + "vm.vnfc[0].vnfc-name"); + vserverMap.put("vnfc-name", vnfcName); + + + String vnfcCount = vmServerCtx.getAttribute(responsePrefix + "vm.vnfc-count"); + if ( vnfcCount == null ) + vnfcCount = "0"; + + vserverMap.put("vnfc-count", vnfcCount); + + if ( vnfcName != null ) { + Map paramsVnfc = new HashMap(); + paramsVnfc.put("vnfcName", vnfcName); + + paramsVnfc.put(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX, inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX)); + + SvcLogicContext vnfcCtx = new SvcLogicContext(); + + aai.getVnfcInfo(paramsVnfc, vnfcCtx); + + vserverMap.put("vnfc-type", vnfcCtx.getAttribute(responsePrefix + "vnfc.vnfc-type")); + vserverMap.put("vnfc-function-code", vnfcCtx.getAttribute(responsePrefix + "vnfc.vnfc-function-code")); + vserverMap.put("group-notation", vnfcCtx.getAttribute(responsePrefix + "vnfc.group-notation")); + + + } + else + vmWithNoVnfcsCount++; + + + + vservers.add(vserverMap); + + } // vmCount + + + + + Collections.sort(vservers, new Comparator>() { + @Override + public int compare(Map o1, Map o2) { + return o1.get("vserver-name").compareTo(o2.get("vserver-name")); + } + }); + + log.info("SORTED VSERVERS " + vservers.toString()); + + populateContext(vservers, ctx, responsePrefix); + + log.info("VMCOUNT IN GETALLVSERVERS " + vmCount); + log.info("VMSWITHNOVNFCSCOUNT IN GETALLVSERVERS " + vmWithNoVnfcsCount); + ctx.setAttribute(responsePrefix+"vnf.vm-count", String.valueOf(vmCount)); + ctx.setAttribute(responsePrefix+"vnf.vm-with-no-vnfcs-count", String.valueOf(vmWithNoVnfcsCount)); + + + } catch (Exception e) { + ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS, + AppcAaiClientConstant.OUTPUT_STATUS_FAILURE); + ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage()); + log.error("Failed in getAllVServersVnfcsInfo " + e.getMessage()); + + throw new SvcLogicException(e.getMessage()); + } + } + + + + + public void populateContext(ArrayList> vservers, SvcLogicContext ctx, String prefix) { + + + log.info("Populating Final Context"); + int ctr = 0; + + for (Map entry : vservers) { + for (String key : entry.keySet()) { + String value = entry.get(key); + + ctx.setAttribute(prefix+ "vm[" + ctr + "]."+ key, value); + log.info("Populating Context Key = " + prefix+ "vm[" + ctr + "]."+ key + " Value = " + value); + + } + + + ctr++; + } + + String firstVServerName = null; + for ( int i =0; i < ctr; i++ ) { + String vnfcName = ctx.getAttribute(prefix + "vm[" + i + "].vnfc-name"); + log.info("VNFCNAME " + i + vnfcName); + if ( vnfcName == null && firstVServerName == null ) { + firstVServerName = ctx.getAttribute(prefix + "vm[" + i + "].vserver-name"); + ctx.setAttribute("vm-name" , firstVServerName); + log.info("Populating Context Key = " + "vm-name" + " Value = " + firstVServerName); + } + } + } + + + + public void addVnfcs(Map inParams, SvcLogicContext ctx) throws SvcLogicException { + + log.info("Received addVnfcs call with params : " + inParams); + + String responsePrefix = inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX); + + int vnfcRefLen =0 ; + int vmCount = 0; + int vmWithNoVnfcCount = 0; + + try { + + responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : ""; + AaiService aai = getAaiService(); + + + + String vnfcRefLenStr = ctx.getAttribute("vnfcReference_length"); + + if ( vnfcRefLenStr == null) { + log.info("Vnfc Reference data is missing"); + throw new Exception("Vnfc Reference data is missing"); + + } + else + vnfcRefLen = Integer.parseInt(vnfcRefLenStr); + + String vmWithNoVnfcCountStr = ctx.getAttribute(responsePrefix+"vnf.vm-with-no-vnfcs-count"); + + //Commented for backward compatibility + + /*if ( vmWithNoVnfcCountStr == null) { + throw new Exception("VNFCs to be added data from A&AI is missing"); + //log.info("VNFCs to be added data from A&AI is missing"); + } + else + vmWithNoVnfcCount = Integer.parseInt(vmWithNoVnfcCountStr); + + if ( vmWithNoVnfcCount!= vnfcRefLen ) + throw new Exception("Unable to Add Vnfcs to A&AI. Reference data mismatch."); + + String vmCountStr = ctx.getAttribute(responsePrefix+"vnf.vm-count"); + + if ( vmCountStr == null) + throw new Exception("VM data from A&AI is missing"); + else + vmCount = Integer.parseInt(vmCountStr); + + + log.info("VMCOUNT " + vmCount); + log.info("VNFCREFLEN " + vnfcRefLen); + aai.insertVnfcs(inParams,ctx, vnfcRefLen, vmCount); + + */ + + + // Modified for 1710 + + if ( vmWithNoVnfcCountStr == null) { + log.info("Parameter VM without VNFCs(vmWithNoVnfcCountStr) from A&AI is Null"); + } + else + vmWithNoVnfcCount = Integer.parseInt(vmWithNoVnfcCountStr); + + log.info("No of VM without VNFCs(vmWithNoVnfcCount) from A&AI is " +vmWithNoVnfcCount); + + String vmCountStr = ctx.getAttribute(responsePrefix+"vnf.vm-count"); + + if ( vmCountStr == null) + throw new Exception("VM data from A&AI is missing"); + else + vmCount = Integer.parseInt(vmCountStr); + + log.info("VMCOUNT " + vmCount); + log.info("VNFCREFLEN " + vnfcRefLen); + + if ( vmWithNoVnfcCount!= vnfcRefLen ) { + //throw new Exception("Unable to Add Vnfcs to A&AI. Reference data mismatch."); + log.info("vmWithNoVnfcCount and vnfcRefLen data from table are not same "); + aai.checkAndUpdateVnfc(inParams,ctx, vnfcRefLen, vmCount); + } + + else { + + aai.insertVnfcs(inParams,ctx, vnfcRefLen, vmCount); + } + + //// Modified 1710 + + ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS, + AppcAaiClientConstant.OUTPUT_STATUS_SUCCESS); + + log.info("addVnfcs Successful "); + } catch (Exception e) { + ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS, + AppcAaiClientConstant.OUTPUT_STATUS_FAILURE); + ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage()); + log.error("Failed in addVnfcs " + e.getMessage()); + + throw new SvcLogicException(e.getMessage()); + } + } + + + public void updateVnfAndVServerStatus(Map inParams, SvcLogicContext ctx) throws SvcLogicException { + + log.info("Received updateVnfAndVServerStatus call with params : " + inParams); + + String responsePrefix = inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX); + + + int vmCount = 0; + + + try { + + responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : ""; + AaiService aai = getAaiService(); + + + + String vmCountStr = ctx.getAttribute(responsePrefix+"vnf.vm-count"); + + if ( vmCountStr == null) + throw new Exception("VM data from A&AI is missing"); + else + vmCount = Integer.parseInt(vmCountStr); + + + log.info("VMCOUNT " + vmCount); + + + aai.updateVnfStatus(inParams, ctx); + aai.updateVServerStatus(inParams,ctx, vmCount); + + ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS, + AppcAaiClientConstant.OUTPUT_STATUS_SUCCESS); + + log.info("updateVnfAndVServerStatus Successful "); + } catch (Exception e) { + ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS, + AppcAaiClientConstant.OUTPUT_STATUS_FAILURE); + ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage()); + log.error("Failed in updateVnfAndVServerStatus " + e.getMessage()); + + throw new SvcLogicException(e.getMessage()); + } + } + + /*public void getDummyValues(Map inParams, SvcLogicContext ctx) throws SvcLogicException { + + log.info("Received getDummyValues call with params : " + inParams); + + String responsePrefix = inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX); + + try { + + responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : ""; + String instarKeys = inParams.get("instarKeys"); + ObjectMapper mapper = new ObjectMapper(); + if ( instarKeys != null ) { + + List keyList = mapper.readValue(instarKeys, ArrayList.class); + + Map instarParams =new HashMap(); + if(keyList != null){ + //System.out.println(keyList.toString()); + + + for(int i=0;i"+keyList.get(i)); + + //ctx.setAttribute(keyList.get(i), "test" + i); + + instarParams.put( keyList.get(i), "test" + i); + } + + } + log.info("INSTARPARAMMAP " + instarParams); + String jsonString = mapper.writeValueAsString(instarParams); + log.info(jsonString); + ctx.setAttribute(responsePrefix + "configuration-parameters", jsonString); + + } + + log.info("getDummyValues Successful "); + } catch (Exception e) { + ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS, + AppcAaiClientConstant.OUTPUT_STATUS_FAILURE); + ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage()); + log.error("Failed in getDummyValues " + e.getMessage()); + + throw new SvcLogicException(e.getMessage()); + } + + } + + */ + /*public void getRequestKeys(Map inParams, SvcLogicContext ctx) throws SvcLogicException { + + log.info("Received getRequestKeys call with params : " + inParams); + + String responsePrefix = inParams.get(AppcAaiClientConstant.INPUT_PARAM_RESPONSE_PREFIX); + + try { + + responsePrefix = StringUtils.isNotBlank(responsePrefix) ? (responsePrefix+".") : ""; + String instarKeys = inParams.get("instarKeys"); + + ObjectMapper mapper = new ObjectMapper(); + if ( instarKeys != null ) { + + List keyList = mapper.readValue(instarKeys, ArrayList.class); + + //Map instarParams =new HashMap(); + if(keyList != null){ + + + for(int i=0;i"+keyList.get(i)); + + + String instarParameter = ctx.getAttribute("INSTAR." + keyList.get(i)); + log.info("INSTARPARAMETER " + instarParameter); + Parameter param = parseParameterContent(instarParameter); + + log.info("PARAMETER KEY SIZE " + param.getRequestKeys().size()); + log.info("RULE TYPE " + param.getClassType()); + + for ( int j =0 ; j < param.getRequestKeys().size() ; j++ ) { + + log.info(" PARAM KEY NAME " + param.getRequestKeys().get(j).getKeyName()); + log.info(" PARAM KEY VALUE " + param.getRequestKeys().get(j).getKeyValue()); + } + + // instarParams.put( keyList.get(i), "test" + i); + } + + } + //log.info("INSTARPARAMMAP " + instarParams); + //String jsonString = mapper.writeValueAsString(instarParams); + //log.info(jsonString); + //ctx.setAttribute(responsePrefix + "configuration-parameters", jsonString); + + } + + log.info("getRequestKeys Successful "); + } catch (Exception e) { + ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_STATUS, + AppcAaiClientConstant.OUTPUT_STATUS_FAILURE); + ctx.setAttribute(responsePrefix + AppcAaiClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage()); + log.error("Failed in getRequestKeys " + e.getMessage()); + + throw new SvcLogicException(e.getMessage()); + } + + } + + + public Parameter parseParameterContent(String parameter) throws JsonParseException, JsonMappingException, IOException{ + Parameter parameterDefinition = null; + if(StringUtils.isNotBlank(parameter)){ + ObjectMapper mapper = new ObjectMapper(); + parameterDefinition = mapper.readValue(parameter, Parameter.class); + } + return parameterDefinition; + }*/ +} diff --git a/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/aai/MockAaiService.java b/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/aai/MockAaiService.java new file mode 100644 index 000000000..92f57ff94 --- /dev/null +++ b/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/aai/MockAaiService.java @@ -0,0 +1,46 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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.openecomp.appc.aai.client.aai; +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.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.SvcLogicResource; +import org.openecomp.sdnc.sli.aai.AAIClient; + +public class MockAaiService extends AaiService { + + //ONAP migration + +} diff --git a/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/aai/TestAaiService.java b/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/aai/TestAaiService.java new file mode 100644 index 000000000..4cf6acf1f --- /dev/null +++ b/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/aai/TestAaiService.java @@ -0,0 +1,63 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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.openecomp.appc.aai.client.aai; + +import java.awt.List; +import java.io.File; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.Map; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.StringUtils; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.openecomp.appc.aai.client.AppcAaiClientConstant; +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; +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.aai.AAIClient; +import org.openecomp.sdnc.sli.aai.AAIService; +import org.openecomp.sdnc.sli.SvcLogicResource; + +import java.util.HashMap; +import java.util.Map; + +import static org.junit.Assert.*; + + + +public class TestAaiService { + // ONAP merging +} diff --git a/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/node/MockAaiService.java b/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/node/MockAaiService.java new file mode 100644 index 000000000..41fa6da06 --- /dev/null +++ b/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/node/MockAaiService.java @@ -0,0 +1,44 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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.openecomp.appc.aai.client.node; +import static junit.framework.Assert.assertEquals; + +import java.util.HashMap; +import java.util.Map; + +import org.apache.commons.lang3.StringUtils; +import org.openecomp.appc.aai.client.AppcAaiClientConstant; +//import org.openecomp.appc.aai.client.aai.AAIClientMock; +import org.openecomp.appc.aai.client.aai.AaiService; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.aai.AAIClient; + +public class MockAaiService extends AaiService { + + // ONAP merging +} diff --git a/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/node/TestAAIResourceNode.java b/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/node/TestAAIResourceNode.java new file mode 100644 index 000000000..5f88a9af8 --- /dev/null +++ b/appc-outbound/appc-aai-client/provider/src/test/java/org/openecomp/appc/aai/client/node/TestAAIResourceNode.java @@ -0,0 +1,57 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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.openecomp.appc.aai.client.node; + +import static org.junit.Assert.*; + +import java.io.File; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.Collections; +import java.util.Comparator; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.junit.Assert; +import org.junit.Test; +import org.openecomp.appc.aai.client.AppcAaiClientConstant; +import org.openecomp.appc.aai.client.aai.AaiService; +import org.openecomp.appc.aai.client.aai.TestAaiService; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; +import org.openecomp.sdnc.sli.SvcLogicContext; +import org.openecomp.sdnc.sli.aai.AAIClient; + +import com.fasterxml.jackson.databind.ObjectMapper; + + +public class TestAAIResourceNode { + + //Removed for ONAP integration +} -- cgit 1.2.3-korg