summaryrefslogtreecommitdiffstats
path: root/appc-outbound/appc-network-inventory-client/provider
diff options
context:
space:
mode:
authorDilip kumar Pampana <dp583p@att.com>2018-01-09 17:24:35 -0500
committerSkip Wonnell <skip@att.com>2018-01-10 11:13:11 -0600
commit8a10978ba382816c1497639034617928a2c003f8 (patch)
treeb39081bf167462069b0613a95799fc67fd36f0f7 /appc-outbound/appc-network-inventory-client/provider
parent14ee9cc1ceb81bd6fe963e4d3580595830885714 (diff)
Network Inventory Client Updates
Supporting IPv4/v6 Subnet and Gateway Addresses From INSTAR,Added code to process A&AI as source in PD file,New Requirement to extract vnfc information for single vserver for VM level operations Issue-ID: APPC-351 Change-Id: I5c91d03a64fc6987e58ab48681f51dc5795bed07 Signed-off-by: Dilip kumar Pampana <dp583p@att.com>
Diffstat (limited to 'appc-outbound/appc-network-inventory-client/provider')
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/aai/data/AaiVmInfo.java57
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/aai/data/AaiVnfInfo.java68
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/aai/data/AaiVnfcInfo.java64
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/aai/interfaceImpl/AaiInterfaceRulesHandler.java275
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/aai/utils/AaiClientConstant.java38
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/instar/dme2client/Dme2Client.java274
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/instar/interfaceImpl/InstarResponseHandlerImpl.java102
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/instar/node/InstarClientNode.java178
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/instar/utils/InstarClientConstant.java94
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/interfaceImpl/TestInstarResponseHandlerImpl.java92
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/node/TestDme2Client.java14
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/node/TestInstarClientNode.java81
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter.txt16
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter2.txt18
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter3.txt18
-rw-r--r--appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter4.txt16
16 files changed, 1091 insertions, 314 deletions
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/aai/data/AaiVmInfo.java b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/aai/data/AaiVmInfo.java
new file mode 100644
index 000000000..7e1c893dc
--- /dev/null
+++ b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/aai/data/AaiVmInfo.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.onap.appc.aai.data;
+
+import java.util.ArrayList;
+
+public class AaiVmInfo {
+ public String getVserverId() {
+ return vserverId;
+ }
+
+ public void setVserverId(String vserverId) {
+ this.vserverId = vserverId;
+ }
+
+ public String getVserverName() {
+ return vserverName;
+ }
+
+ public void setVserverName(String vserverName) {
+ this.vserverName = vserverName;
+ }
+
+ public ArrayList<AaiVnfcInfo> getVnfcInfo() {
+ return vnfcInfo;
+ }
+
+ public void setVnfcInfo(ArrayList<AaiVnfcInfo> vnfcInfo) {
+ this.vnfcInfo = vnfcInfo;
+ }
+
+ String vserverId;
+ String vserverName;
+ ArrayList<AaiVnfcInfo> vnfcInfo;
+}
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/aai/data/AaiVnfInfo.java b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/aai/data/AaiVnfInfo.java
new file mode 100644
index 000000000..d990ae23d
--- /dev/null
+++ b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/aai/data/AaiVnfInfo.java
@@ -0,0 +1,68 @@
+/*-
+ * ============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.onap.appc.aai.data;
+
+import java.util.ArrayList;
+
+public class AaiVnfInfo {
+
+ String vnfId;
+
+ public String getVnfId() {
+ return vnfId;
+ }
+
+ public void setVnfId(String vnfId) {
+ this.vnfId = vnfId;
+ }
+
+ public String getVnfName() {
+ return vnfName;
+ }
+
+ public void setVnfName(String vnfName) {
+ this.vnfName = vnfName;
+ }
+
+ public String getVnfOamIpAddress() {
+ return vnfOamIpAddress;
+ }
+
+ public void setVnfOamIpAddress(String vnfOamIpAddress) {
+ this.vnfOamIpAddress = vnfOamIpAddress;
+ }
+
+ public ArrayList<AaiVmInfo> getVmInfo() {
+ return vmInfo;
+ }
+
+ public void setVmInfo(ArrayList<AaiVmInfo> vmInfo) {
+ this.vmInfo = vmInfo;
+ }
+
+ String vnfName;
+ String vnfOamIpAddress;
+ ArrayList<AaiVmInfo> vmInfo;
+}
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/aai/data/AaiVnfcInfo.java b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/aai/data/AaiVnfcInfo.java
new file mode 100644
index 000000000..29b3c592a
--- /dev/null
+++ b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/aai/data/AaiVnfcInfo.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.onap.appc.aai.data;
+
+public class AaiVnfcInfo {
+ public String getVnfcId() {
+ return vnfcId;
+ }
+
+ public void setVnfcId(String vnfcId) {
+ this.vnfcId = vnfcId;
+ }
+
+ public String getVnfcName() {
+ return vnfcName;
+ }
+
+ public void setVnfcName(String vnfcName) {
+ this.vnfcName = vnfcName;
+ }
+
+ public String getVnfcFunctionCode() {
+ return vnfcFunctionCode;
+ }
+
+ public void setVnfcFunctionCode(String vnfcFunctionCode) {
+ this.vnfcFunctionCode = vnfcFunctionCode;
+ }
+
+ public String getVnfcOamIpAddress() {
+ return vnfcOamIpAddress;
+ }
+
+ public void setVnfcOamIpAddress(String vnfcOamIpAddress) {
+ this.vnfcOamIpAddress = vnfcOamIpAddress;
+ }
+
+ String vnfcId;
+ String vnfcName;
+ String vnfcFunctionCode;
+ String vnfcOamIpAddress;
+}
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/aai/interfaceImpl/AaiInterfaceRulesHandler.java b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/aai/interfaceImpl/AaiInterfaceRulesHandler.java
new file mode 100644
index 000000000..47a763bfd
--- /dev/null
+++ b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/aai/interfaceImpl/AaiInterfaceRulesHandler.java
@@ -0,0 +1,275 @@
+/*-
+ * ============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.onap.appc.aai.interfaceImpl;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.commons.lang.StringUtils;
+import org.json.JSONObject;
+import org.onap.appc.aai.data.AaiVmInfo;
+import org.onap.appc.aai.data.AaiVnfInfo;
+import org.onap.appc.aai.data.AaiVnfcInfo;
+import org.onap.appc.instar.interfaces.RuleHandlerInterface;
+import org.onap.appc.aai.utils.AaiClientConstant;
+import org.onap.sdnc.config.params.data.Parameter;
+import org.onap.sdnc.config.params.data.ResponseKey;
+import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+public class AaiInterfaceRulesHandler implements RuleHandlerInterface {
+
+ private static final EELFLogger log = EELFManager.getInstance().getLogger(AaiInterfaceRulesHandler.class);
+ private Parameter parameters;
+ private SvcLogicContext context;
+ private AaiVnfInfo vnfInfoData;
+
+ public AaiInterfaceRulesHandler(Parameter params, SvcLogicContext ctx) {
+ this.parameters = params;
+ this.context = ctx;
+ this.setVnfInfoData(generateAaiVnfInfoData());
+ }
+
+ @Override
+ public void processRule() throws Exception {
+
+ String fn = "AaiInterfaceIpAddressHandler.processRule";
+ log.info(fn + "Processing rule :" + parameters.getRuleType());
+ List<ResponseKey> responseKeyList = parameters.getResponseKeys();
+ ResponseKey respKeys = new ResponseKey();
+ if (responseKeyList != null && responseKeyList.size() > 0) {
+ for (ResponseKey filterKeys : responseKeyList) {
+ if (null != filterKeys) {
+ if (StringUtils.isNotBlank(filterKeys.getUniqueKeyName()))
+ respKeys.setUniqueKeyName(filterKeys.getUniqueKeyName());
+ if (StringUtils.isNotBlank(filterKeys.getUniqueKeyValue()))
+ respKeys.setUniqueKeyValue(filterKeys.getUniqueKeyValue());
+ if (StringUtils.isNotBlank(filterKeys.getFieldKeyName()))
+ respKeys.setFieldKeyName(filterKeys.getFieldKeyName());
+ if (StringUtils.isNotBlank(filterKeys.getFilterByField()))
+ respKeys.setFilterByField(filterKeys.getFilterByField());
+ if (StringUtils.isNotBlank(filterKeys.getFilterByValue()))
+ respKeys.setFilterByValue(filterKeys.getFilterByValue());
+ }
+ }
+ } else {
+ throw new Exception("NO response Keys set for : " + parameters.getRuleType());
+ }
+ processKeys(respKeys, parameters.getName());
+ }
+
+ public void processKeys(ResponseKey filterKey, String aaiKey) throws Exception {
+
+ String fn = "AaiInterfaceRulesHandler.processKeys()::";
+ log.info(fn + "processing for " + aaiKey);
+ String values = new String();
+ JSONObject aaiKeyValues = null;
+ log.info("Aai Data in Context : " + context.getAttribute(AaiClientConstant.AAI_KEY_VALUES));
+ if (context.getAttribute(AaiClientConstant.AAI_KEY_VALUES) != null) {
+ aaiKeyValues = new JSONObject(context.getAttribute(AaiClientConstant.AAI_KEY_VALUES));
+ log.info("Aai data already exsits : " + aaiKeyValues.toString());
+ } else {
+ aaiKeyValues = new JSONObject();
+ }
+
+ if (StringUtils.equalsIgnoreCase(filterKey.getUniqueKeyValue(), "vnf")) {
+ values = getVnfDetailsFromContext(filterKey.getFieldKeyName());
+
+ }
+ if (StringUtils.equalsIgnoreCase(filterKey.getUniqueKeyValue(), "vnfc")) {
+ values = getVnfcDetailsFromContext(filterKey.getFieldKeyName(), filterKey.getFilterByField(),
+ filterKey.getFilterByValue());
+ }
+ if (StringUtils.equalsIgnoreCase(filterKey.getUniqueKeyValue(), "vserver")) {
+ values = getVServerDetailsFromContext(filterKey.getFieldKeyName(), filterKey.getFilterByField(),
+ filterKey.getFilterByValue());
+ }
+ aaiKeyValues.put(aaiKey, values);
+ context.setAttribute(AaiClientConstant.AAI_KEY_VALUES, aaiKeyValues.toString());
+ return;
+ }
+
+ private String getVServerDetailsFromContext(String fieldKeyName, String filterByField, String filterByValue) {
+ String fn = "AaiInterfaceRulesHander::getVServerDetailsFromContext():";
+ String values = "";
+ log.info(fn + "FieldKeyName:" + fieldKeyName + " FilterByName:" + filterByField + " FilterByValue:"
+ + filterByValue);
+ if (StringUtils.equalsIgnoreCase(fieldKeyName, "vserver-name")) {
+ if (StringUtils.isNotEmpty(filterByField) && StringUtils.isNotEmpty(filterByField)
+ && StringUtils.isNotEmpty(filterByValue) && StringUtils.isNotEmpty(filterByValue)) {
+ int vmIndex = 0;
+ for (AaiVmInfo vm : vnfInfoData.getVmInfo()) {
+ if (StringUtils.equalsIgnoreCase(filterByField, "vm-number") && null != filterByValue) {
+ int vmNumber = Integer.parseInt(filterByValue);
+ if (vmNumber == vmIndex) {
+ if (StringUtils.isBlank(values))
+ values = vm.getVserverName();
+ else
+ values = values + "," + vm.getVserverName();
+ }
+ }
+ vmIndex++;
+ }
+ } else {
+ for (AaiVmInfo vm : vnfInfoData.getVmInfo()) {
+ if (StringUtils.isBlank(values))
+ values = vm.getVserverName();
+ else
+ values = values + "," + vm.getVserverName();
+ }
+ }
+ }
+ log.info(fn + "Returning values:" + values);
+ return values;
+
+ }
+
+ private String getVnfcDetailsFromContext(String fieldKeyName, String filterByField, String filterByValue) {
+ String fn = "AaiInterfaceRulesHander::getVnfcDetailsFromContext()";
+ String values = "";
+ log.info(fn + "FieldKeyName:" + fieldKeyName + " FilterByField:" + filterByField + " FilterByValue:"
+ + filterByValue);
+ if (StringUtils.equalsIgnoreCase(fieldKeyName, "ipaddress-v4-oam-vip")) {
+ if (StringUtils.isNotEmpty(filterByField) && StringUtils.isNotEmpty(filterByValue)) {
+ for (AaiVmInfo vm : vnfInfoData.getVmInfo()) {
+ for (AaiVnfcInfo vnfcInfo : vm.getVnfcInfo()) {
+ if (StringUtils.equalsIgnoreCase(filterByField, "vnfc-function-code")
+ && StringUtils.equalsIgnoreCase(filterByValue, vnfcInfo.getVnfcFunctionCode()))
+ if (StringUtils.isBlank(values))
+ values = vnfcInfo.getVnfcOamIpAddress();
+ else
+ values = values + "," + vnfcInfo.getVnfcOamIpAddress();
+ }
+
+ }
+ } else {
+ for (AaiVmInfo vm : vnfInfoData.getVmInfo()) {
+ for (AaiVnfcInfo vnfcInfo : vm.getVnfcInfo()) {
+ if (StringUtils.isBlank(values))
+ values = vnfcInfo.getVnfcOamIpAddress();
+ else
+ values = values + "," + vnfcInfo.getVnfcOamIpAddress();
+ }
+ }
+
+ }
+ }
+ if (StringUtils.equalsIgnoreCase(fieldKeyName, "vnfc-name")) {
+ if (StringUtils.isNotBlank(filterByField) && StringUtils.isNotBlank(filterByValue)) {
+ for (AaiVmInfo vm : vnfInfoData.getVmInfo()) {
+ for (AaiVnfcInfo vnfcInfo : vm.getVnfcInfo()) {
+ if (StringUtils.equalsIgnoreCase(filterByField, "vnfc-function-code")
+ && StringUtils.equalsIgnoreCase(filterByValue, vnfcInfo.getVnfcFunctionCode()))
+ if (StringUtils.isBlank(values))
+ values = vnfcInfo.getVnfcName();
+ else
+ values = values + "," + vnfcInfo.getVnfcName();
+ }
+
+ }
+ } else {
+ for (AaiVmInfo vm : vnfInfoData.getVmInfo()) {
+ for (AaiVnfcInfo vnfcInfo : vm.getVnfcInfo()) {
+ if (StringUtils.isBlank(values))
+ values = vnfcInfo.getVnfcName();
+ else
+ values = values + "," + vnfcInfo.getVnfcName();
+ }
+ }
+
+ }
+ }
+ log.info(fn + "Returning values:" + values);
+ return values;
+
+ }
+
+ private String getVnfDetailsFromContext(String fieldKeyName) {
+
+ log.info("getVnfDetailsFromContext::" + fieldKeyName);
+ String values = "";
+ if (StringUtils.equalsIgnoreCase(fieldKeyName, "vnf-name")) {
+ String vnfName = context.getAttribute("tmp.vnfInfo.vnf.vnf-name");
+ values = vnfName;
+ }
+ if (StringUtils.equalsIgnoreCase(fieldKeyName, "ipv4-oam-ipaddress")) {
+ String ipv4OamAddress = context.getAttribute("tmp.vnfInfo.vnf.ipv4-oam-address");
+ values = ipv4OamAddress;
+ }
+ return values;
+ }
+
+ public AaiVnfInfo getVnfInfoData() {
+ return vnfInfoData;
+ }
+
+ public void setVnfInfoData(AaiVnfInfo vnfInfoData) {
+ this.vnfInfoData = vnfInfoData;
+ }
+
+ public AaiVnfInfo generateAaiVnfInfoData() {
+
+ log.info("AaiInterfaceRulesHandlerImpl:generateAaiVnfInfoData(): Printing variables in context");
+ for (Object key : context.getAttributeKeySet()) {
+ String parmName = (String) key;
+ String parmValue = context.getAttribute(parmName);
+ log.debug("generateAaiVnfInfoData():: " + parmName + "=" + parmValue);
+
+ }
+
+ String vmcount = context.getAttribute("tmp.vnfInfo.vm-count");
+ int vmCount = 0;
+ if (!StringUtils.isBlank(vmcount))
+ vmCount = Integer.parseInt(vmcount);
+ log.info("generateAaiVnfInfoData::" + "vmCount:" + vmCount);
+ AaiVnfInfo vnfInfo = new AaiVnfInfo();
+ vnfInfo.setVnfName("vnf-name");
+ ArrayList<AaiVmInfo> vmList = new ArrayList<AaiVmInfo>();
+
+ for (int i = 0; i < vmCount; i++) {
+ AaiVmInfo vm = new AaiVmInfo();
+ String vnfcCountStr = context.getAttribute("tmp.vnfInfo.vm[" + i + "].vnfc-count");
+ int vnfcCount = Integer.parseInt(vnfcCountStr);
+ ArrayList<AaiVnfcInfo> vnfcInfoList = new ArrayList<AaiVnfcInfo>();
+ for (int j = 0; j < vnfcCount; j++) {
+ AaiVnfcInfo vnfcInfo = new AaiVnfcInfo();
+ vnfcInfo.setVnfcName(context.getAttribute("tmp.vnfInfo.vm[" + i + "].vnfc-name"));
+ vnfcInfo.setVnfcFunctionCode(context.getAttribute("tmp.vnfInfo.vm[" + i + "].vnfc-function-code"));
+ vnfcInfo.setVnfcOamIpAddress(
+ context.getAttribute("tmp.vnfInfo.vm[" + i + "].vnfc-ipaddress-v4-oam-vip"));
+ vnfcInfoList.add(vnfcInfo);
+ }
+ vm.setVnfcInfo(vnfcInfoList);
+ vm.setVserverId(context.getAttribute("tmp.vnfInfo.vm[" + i + "].vserver-id"));
+ vm.setVserverName(context.getAttribute("tmp.vnfInfo.vm[" + i + "].vserver-name"));
+ vmList.add(vm);
+ }
+ vnfInfo.setVmInfo(vmList);
+ return vnfInfo;
+ }
+
+}
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/aai/utils/AaiClientConstant.java b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/aai/utils/AaiClientConstant.java
new file mode 100644
index 000000000..1f2d6ffaa
--- /dev/null
+++ b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/aai/utils/AaiClientConstant.java
@@ -0,0 +1,38 @@
+/*-
+ * ============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.onap.appc.aai.utils;
+
+public class AaiClientConstant {
+ public static String INPUT_PARAM_RESPONSE_PRIFIX = "responsePrefix";
+ public static String OUTPUT_PARAM_STATUS = "status";
+ public static String OUTPUT_PARAM_ERROR_MESSAGE = "error-message";
+ public static String OUTPUT_STATUS_SUCCESS = "success";
+ public static String OUTPUT_STATUS_FAILURE = "failure";
+
+ public static final String AAI_KEYS = "aaiKeys";
+ public static final String SOURCE_SYSTEM_AAI = "AAI";
+ public static final String AAI_KEY_VALUES = "AAI-KEY-VALUES";
+
+}
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/instar/dme2client/Dme2Client.java b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/instar/dme2client/Dme2Client.java
index fa22a751f..2e822d032 100644
--- a/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/instar/dme2client/Dme2Client.java
+++ b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/instar/dme2client/Dme2Client.java
@@ -49,136 +49,150 @@ import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
public class Dme2Client {
- private static final EELFLogger log = EELFManager.getInstance().getLogger(Dme2Client.class);
- private static final String SDNC_CONFIG_DIR_VAR = "SDNC_CONFIG_DIR";
- //DME2Client client = null;
- Properties props = new Properties();
- String operationName ;
- String appendContext;
-
- public Dme2Client(String optName, String subCtxt, HashMap<String, String> data) throws Exception{
- log.info("Setting Properties for DME2 Client for INSTAR connection");
- this.operationName=optName;
- this.appendContext = data.get(subCtxt);
- String propDir = System.getenv(SDNC_CONFIG_DIR_VAR);
- if (propDir == null)
- throw new Exception(" Cannot find Property file -" + SDNC_CONFIG_DIR_VAR);
- String propFile = propDir + InstarClientConstant.OUTBOUND_PROPERTIES;
- InputStream propStream = new FileInputStream(propFile);
- try
- {
- props.load(propStream);
- }
- catch (Exception e)
- {
- throw new Exception("Could not load properties file " + propFile, e);
- }
- finally
- {
- try
- {
- propStream.close();
- }
- catch (Exception e)
- {
- log.warn("Could not close FileInputStream", e);
- }
- }
- }
-
- public ClientResponse sendtoInstar() throws Exception {
-
- log.info("Called Send with operation Name=" + this.operationName + "and = " + props.getProperty(operationName+InstarClientConstant.BASE_URL));
- String resourceUri = props.getProperty(operationName+InstarClientConstant.BASE_URL)+
- props.getProperty(operationName + InstarClientConstant.URL_SUFFIX) +
- props.getProperty(operationName + InstarClientConstant.SUB_CONTEXT)+ appendContext ;
-
- log.info("DME Endpoint URI:" + resourceUri);
- Client client = null;
- WebResource webResource = null;
- ClientResponse clientResponse = null;
- String authorization = props.getProperty("authorization");
- String requestDataType = "application/json";
- String responseDataType= MediaType.APPLICATION_JSON;
- String methodType = props.getProperty("getIpAddressByVnf_method");
- String request = "";
- String userId=props.getProperty("MechID");
- String password=props.getProperty("MechPass");
-
- log.info("authorization = " + authorization + "methodType= " + methodType);
- try{
- DefaultClientConfig defaultClientConfig = new DefaultClientConfig();
- System.setProperty("jsse.enableSNIExtension", "false");
- SSLContext sslContext = null;
- SecureRestClientTrustManager secureRestClientTrustManager = new SecureRestClientTrustManager();
- sslContext = SSLContext.getInstance("SSL");
- sslContext.init(null, new javax.net.ssl.TrustManager[] { secureRestClientTrustManager }, null);
- defaultClientConfig.getProperties().put(
- com.sun.jersey.client.urlconnection.HTTPSProperties.PROPERTY_HTTPS_PROPERTIES,
- new com.sun.jersey.client.urlconnection.HTTPSProperties(getHostnameVerifier(), sslContext));
- client = Client.create(defaultClientConfig);
- client.addFilter(new HTTPBasicAuthFilter(userId, password));
-
- webResource = client.resource(new URI(resourceUri));
- webResource.setProperty("Content-Type", "application/json;charset=UTF-8");
-
- if(HttpMethod.GET.equalsIgnoreCase(methodType)){
- clientResponse = webResource.accept(responseDataType).get(ClientResponse.class);
- }else if(HttpMethod.POST.equalsIgnoreCase(methodType)){
- clientResponse = webResource.type(requestDataType).post(ClientResponse.class, request);
- }else if(HttpMethod.PUT.equalsIgnoreCase(methodType)){
- clientResponse = webResource.type(requestDataType).put(ClientResponse.class,request);
- }else if(HttpMethod.DELETE.equalsIgnoreCase(methodType)){
- clientResponse = webResource.delete(ClientResponse.class);
- }
-
- return clientResponse;
-
- }catch (Exception e) {
- log.info("failed in RESTCONT Action ("+methodType+") for the resource " + resourceUri + ", falut message :"+e.getMessage());
- throw new Exception("Error While gettting Data from INSTAR" + e.getMessage());
- }
- finally {
- // clean up.
- webResource = null;
- if(client != null){
- client.destroy();
- client = null;
- }
- }
-
-
- }
-
- public String send() {
- String response = null;
- try{
-
- if(props !=null &&
- props.getProperty(InstarClientConstant.MOCK_INSTAR) != null &&
- props.getProperty(InstarClientConstant.MOCK_INSTAR).equalsIgnoreCase("true"))
- return IOUtils.toString(Dme2Client.class.getClassLoader().getResourceAsStream("/tmp/sampleResponse"), Charset.defaultCharset());
-
- ClientResponse clientResponse = sendtoInstar();
- if(clientResponse != null){
- response = clientResponse.getEntity(String.class);
- log.info(clientResponse.getStatus() + " Status, Response :" + response);
-
- }
- } catch (Exception t) {
- log.error("Error in Dme2Client for send() method while sending response:" ,t);
- }
- return response;
- }
-
- private HostnameVerifier getHostnameVerifier() {
- return new HostnameVerifier() {
- @Override
- public boolean verify(String hostname, javax.net.ssl.SSLSession sslSession) {
- return true;
- }
- };
- }
+ private static final EELFLogger log = EELFManager.getInstance().getLogger(Dme2Client.class);
+ private static final String SDNC_CONFIG_DIR_VAR = "SDNC_CONFIG_DIR";
+ //DME2Client client = null;
+ Properties props = new Properties();
+ String operationName ;
+ String appendContext;
+String mask;
+ String ipAddress;
+ public Dme2Client(String optName, String subCtxt, HashMap<String, String> data) throws Exception{
+ log.info("Setting Properties for DME2 Client for INSTAR connection");
+ this.operationName=optName;
+ this.appendContext = data.get(subCtxt);
+if("getVnfbyIpadress".equals(optName)){
+ this.ipAddress = data.get("ipAddress");
+ this.mask = data.get("mask");
+ }
+ String propDir = System.getenv(SDNC_CONFIG_DIR_VAR);
+ if (propDir == null)
+ throw new Exception(" Cannot find Property file -" + SDNC_CONFIG_DIR_VAR);
+ String propFile = propDir + InstarClientConstant.OUTBOUND_PROPERTIES;
+ InputStream propStream = new FileInputStream(propFile);
+ try
+ {
+ props.load(propStream);
+ }
+ catch (Exception e)
+ {
+ throw new Exception("Could not load properties file " + propFile, e);
+ }
+ finally
+ {
+ try
+ {
+ propStream.close();
+ }
+ catch (Exception e)
+ {
+ log.warn("Could not close FileInputStream", e);
+ }
+ }
+ }
+
+ public ClientResponse sendtoInstar() throws Exception {
+
+ log.info("Called Send with operation Name=" + this.operationName + "and = " + props.getProperty(operationName+InstarClientConstant.BASE_URL));
+ String resourceUri = props.getProperty(operationName+InstarClientConstant.BASE_URL)+
+ props.getProperty(operationName + InstarClientConstant.URL_SUFFIX);
+ if(this.ipAddress!=null && this.mask == null){
+ //resourceUri = resourceUri.substring(0,resourceUri.length() - 1) + "?";
+ resourceUri = resourceUri + props.getProperty(operationName+InstarClientConstant.SUB_CONTEXT_BYIPADDRESS);
+ resourceUri = resourceUri + ipAddress;
+ }else if(mask!=null){
+ //resourceUri = resourceUri.substring(0,resourceUri.length() - 1) + "?";
+ resourceUri = resourceUri + props.getProperty(operationName+InstarClientConstant.SUB_CONTEXT_BYIPADDRESS) + ipAddress+ props.getProperty(operationName+InstarClientConstant.SUB_CONTEXT_BYMASK);
+ resourceUri = resourceUri + mask ;
+ }else{
+ resourceUri=resourceUri+ props.getProperty(operationName + InstarClientConstant.SUB_CONTEXT)+ appendContext;
+ }
+
+ log.info("DME Endpoint URI:" + resourceUri);
+ Client client = null;
+ WebResource webResource = null;
+ ClientResponse clientResponse = null;
+ String authorization = props.getProperty("authorization");
+ String requestDataType = "application/json";
+ String responseDataType= MediaType.APPLICATION_JSON;
+ String methodType = props.getProperty("getIpAddressByVnf_method");
+ String request = "";
+ String userId=props.getProperty("MechID");
+ String password=props.getProperty("MechPass");
+ log.info("authorization = " + authorization + "methodType= " + methodType);
+ try{
+ DefaultClientConfig defaultClientConfig = new DefaultClientConfig();
+ System.setProperty("jsse.enableSNIExtension", "false");
+ SSLContext sslContext = null;
+ SecureRestClientTrustManager secureRestClientTrustManager = new SecureRestClientTrustManager();
+ sslContext = SSLContext.getInstance("SSL");
+ sslContext.init(null, new javax.net.ssl.TrustManager[] { secureRestClientTrustManager }, null);
+ defaultClientConfig.getProperties().put(
+ com.sun.jersey.client.urlconnection.HTTPSProperties.PROPERTY_HTTPS_PROPERTIES,
+ new com.sun.jersey.client.urlconnection.HTTPSProperties(getHostnameVerifier(), sslContext));
+ client = Client.create(defaultClientConfig);
+ client.addFilter(new HTTPBasicAuthFilter(userId, password));
+
+ webResource = client.resource(new URI(resourceUri));
+ webResource.setProperty("Content-Type", "application/json;charset=UTF-8");
+
+ if(HttpMethod.GET.equalsIgnoreCase(methodType)){
+ clientResponse = webResource.accept(responseDataType).get(ClientResponse.class);
+ }else if(HttpMethod.POST.equalsIgnoreCase(methodType)){
+ clientResponse = webResource.type(requestDataType).post(ClientResponse.class, request);
+ }else if(HttpMethod.PUT.equalsIgnoreCase(methodType)){
+ clientResponse = webResource.type(requestDataType).put(ClientResponse.class,request);
+ }else if(HttpMethod.DELETE.equalsIgnoreCase(methodType)){
+ clientResponse = webResource.delete(ClientResponse.class);
+ }
+
+ return clientResponse;
+
+ }catch (Exception e) {
+ log.info("failed in RESTCONT Action ("+methodType+") for the resource " + resourceUri + ", falut message :"+e.getMessage());
+ throw new Exception("Error While gettting Data from INSTAR" + e.getMessage());
+ }
+ finally {
+ // clean up.
+ webResource = null;
+ if(client != null){
+ client.destroy();
+ client = null;
+ }
+ }
+
+
+ }
+
+ public String send() {
+ String response = null;
+ try{
+
+ if(props !=null &&
+ props.getProperty(InstarClientConstant.MOCK_INSTAR) != null &&
+ props.getProperty(InstarClientConstant.MOCK_INSTAR).equalsIgnoreCase("true"))
+ return IOUtils.toString(Dme2Client.class.getClassLoader().getResourceAsStream("/tmp/sampleResponse"), Charset.defaultCharset());
+
+ ClientResponse clientResponse = sendtoInstar();
+ if(clientResponse != null){
+ response = clientResponse.getEntity(String.class);
+ log.info(clientResponse.getStatus() + " Status, Response :" + response);
+
+ }
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return response;
+ }
+
+ private HostnameVerifier getHostnameVerifier() {
+ return new HostnameVerifier() {
+ @Override
+ public boolean verify(String hostname, javax.net.ssl.SSLSession sslSession) {
+ return true;
+ }
+ };
+ }
}
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/instar/interfaceImpl/InstarResponseHandlerImpl.java b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/instar/interfaceImpl/InstarResponseHandlerImpl.java
index 56b9c2847..c556e9ce9 100644
--- a/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/instar/interfaceImpl/InstarResponseHandlerImpl.java
+++ b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/instar/interfaceImpl/InstarResponseHandlerImpl.java
@@ -36,51 +36,65 @@ import com.att.eelf.configuration.EELFManager;
public class InstarResponseHandlerImpl implements ResponseHandlerInterface {
- private static final EELFLogger log = EELFManager.getInstance().getLogger(InstarResponseHandlerImpl.class);
+ private static final EELFLogger log = EELFManager.getInstance().getLogger(InstarResponseHandlerImpl.class);
- ResponseKey resKey = null;
- SvcLogicContext ctxt = null;
-
- public InstarResponseHandlerImpl(ResponseKey filterKeys, SvcLogicContext context) {
- this.resKey = filterKeys;
- this.ctxt = context;
-
- }
+ ResponseKey resKey = null;
+ SvcLogicContext ctxt = null;
- @Override
- public Object processResponse(String instarResponse, String instarKey) {
- String fn = " InstarResponseHandlerImpl.processResponse ";
- log.info(fn + " Instar Response :" + instarResponse);
-
- JSONObject instarKeyValues;
-
- log.info("Instar Data in Context : "+ ctxt.getAttribute(InstarClientConstant.INSTAR_KEY_VALUES));
- if(ctxt.getAttribute(InstarClientConstant.INSTAR_KEY_VALUES) != null){
- instarKeyValues = new JSONObject(ctxt.getAttribute(InstarClientConstant.INSTAR_KEY_VALUES));
- log.info("Instar data already exsits : " + instarKeyValues.toString());
- }
- else
- instarKeyValues = new JSONObject();
- JSONArray instarResponses = new JSONObject(instarResponse).getJSONArray(InstarClientConstant.INSTAR_RESPONSE_BLOCK_NAME);
- for (int i = 0; i < instarResponses.length(); i++){
- JSONObject res = instarResponses.getJSONObject(i);
- log.info(fn + "Instar Block :" + i + " Values :" + res.toString());
- log.info(fn + "Appc Filter Key :" + ctxt.getAttribute(InstarClientConstant.VNF_NAME) + resKey.getUniqueKeyValue());
-
- if(res.getString(InstarClientConstant.FDQN) != null &&
- res.getString(InstarClientConstant.FDQN).equalsIgnoreCase(ctxt.getAttribute(InstarClientConstant.VNF_NAME) + resKey.getUniqueKeyValue())){
- if(resKey.getFieldKeyName().equals(InstarClientConstant.V4_ADDRESS))
- instarKeyValues.put(instarKey, res.getString(InstarClientConstant.INSTAR_V4_ADDRESS));
- else if(resKey.getFieldKeyName().equals(InstarClientConstant.V6_ADDRESS))
- instarKeyValues.put(instarKey, res.getString(InstarClientConstant.INSTAR_V6_ADDRESS));
- break;
- }
- }
- log.info(fn + "Instar KeyValues :" + instarKeyValues);
- ctxt.setAttribute(InstarClientConstant.INSTAR_KEY_VALUES, instarKeyValues.toString());
-
-
- return instarKeyValues;
- }
+ public InstarResponseHandlerImpl(ResponseKey filterKeys, SvcLogicContext context) {
+ this.resKey = filterKeys;
+ this.ctxt = context;
+
+ }
+
+ @Override
+ public Object processResponse(String instarResponse, String instarKey) {
+ String fn = " InstarResponseHandlerImpl.processResponse ";
+ log.info(fn + " Instar Response :" + instarResponse);
+
+ JSONObject instarKeyValues;
+
+ log.info("Instar Data in Context : "+ ctxt.getAttribute(InstarClientConstant.INSTAR_KEY_VALUES));
+ if(ctxt.getAttribute(InstarClientConstant.INSTAR_KEY_VALUES) != null){
+ instarKeyValues = new JSONObject(ctxt.getAttribute(InstarClientConstant.INSTAR_KEY_VALUES));
+ log.info("Instar data already exsits : " + instarKeyValues.toString());
+ }
+ else
+ instarKeyValues = new JSONObject();
+ JSONArray instarResponses = new JSONObject(instarResponse).getJSONArray(InstarClientConstant.INSTAR_RESPONSE_BLOCK_NAME);
+ for (int i = 0; i < instarResponses.length(); i++){
+ JSONObject res = instarResponses.getJSONObject(i);
+ log.info(fn + "Instar Block :" + i + " Values :" + res.toString());
+ log.info(fn + "Appc Filter Key :" + ctxt.getAttribute(InstarClientConstant.VNF_NAME) + resKey.getUniqueKeyValue());
+
+ if(res.getString(InstarClientConstant.FDQN) != null &&
+ res.getString(InstarClientConstant.FDQN).equalsIgnoreCase(ctxt.getAttribute(InstarClientConstant.VNF_NAME) + resKey.getUniqueKeyValue())) {
+ if(resKey.getFieldKeyName().equals(InstarClientConstant.V4_ADDRESS)) {
+ instarKeyValues.put(instarKey, res.getString(InstarClientConstant.INSTAR_V4_ADDRESS));
+ }
+ else if (resKey.getFieldKeyName().equals(InstarClientConstant.INSTAR_V4_SUBNET)) {
+ instarKeyValues.put(instarKey, res.getString(InstarClientConstant.INSTAR_V4_SUBNET) );
+ }
+ else if (resKey.getFieldKeyName().equals(InstarClientConstant.INSTAR_V4_DEFAULT_GATEWAY)) {
+ instarKeyValues.put(instarKey, res.getString(InstarClientConstant.INSTAR_V4_DEFAULT_GATEWAY));
+ }
+ else if(resKey.getFieldKeyName().equals(InstarClientConstant.V6_ADDRESS)) {
+ instarKeyValues.put(instarKey, res.getString(InstarClientConstant.INSTAR_V6_ADDRESS));
+ }
+ else if (resKey.getFieldKeyName().equals(InstarClientConstant.INSTAR_V6_SUBNET)) {
+ instarKeyValues.put(instarKey, res.getString(InstarClientConstant.INSTAR_V6_SUBNET) );
+ }
+ else if (resKey.getFieldKeyName().equals(InstarClientConstant.INSTAR_V6_DEFAULT_GATEWAY)) {
+ instarKeyValues.put(instarKey, res.getString(InstarClientConstant.INSTAR_V6_DEFAULT_GATEWAY));
+ }
+ break;
+ }
+ }
+ log.info(fn + "Instar KeyValues :" + instarKeyValues);
+ ctxt.setAttribute(InstarClientConstant.INSTAR_KEY_VALUES, instarKeyValues.toString());
+
+
+ return instarKeyValues;
+ }
}
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/instar/node/InstarClientNode.java b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/instar/node/InstarClientNode.java
index 54cc12fd7..f9aa42d7c 100644
--- a/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/instar/node/InstarClientNode.java
+++ b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/instar/node/InstarClientNode.java
@@ -32,6 +32,8 @@ import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
+import org.onap.appc.aai.interfaceImpl.AaiInterfaceRulesHandler;
+import org.onap.appc.aai.utils.AaiClientConstant;
import org.onap.appc.instar.interfaceImpl.InstarRestClientImpl;
import org.onap.appc.instar.interfaceImpl.InterfaceIpAddressImpl;
import org.onap.appc.instar.interfaces.RestClientInterface;
@@ -44,52 +46,52 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicJavaPlugin;
public class InstarClientNode implements SvcLogicJavaPlugin
{
- private static final EELFLogger log = EELFManager.getInstance().getLogger(InstarClientNode.class);
+ private static final EELFLogger log = EELFManager.getInstance().getLogger(InstarClientNode.class);
- public void getInstarInfo(Map<String, String> inParams, SvcLogicContext ctx)
- throws SvcLogicException{
- log.info("Received getInstarInfo call with params : " + inParams);
- String responsePrefix = (String)inParams.get(InstarClientConstant.INPUT_PARAM_RESPONSE_PRIFIX);
- try
- {
- responsePrefix = StringUtils.isNotBlank(responsePrefix) ? responsePrefix + "." : "";
- String [] instarKeys = getInstarKeys(inParams.get(InstarClientConstant.INSTAR_KEYS));
- for (String instarKey : instarKeys){
- log.info("Processing Key : " + instarKey);
- log.info("Searching key for : " + "INSTAR." + instarKey);
- ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
- RuleHandlerInterface handler = null;
- log.info("Received Context : " + ctx.getAttribute("INSTAR." + instarKey));
- Parameter params = mapper.readValue(ctx.getAttribute(InstarClientConstant.SOURCE_SYSTEM_INSTAR + "." + instarKey), Parameter.class);
-
- log.info("Processing rule Type : " + params.getRuleType());
- switch(params.getRuleType()){
- case InstarClientConstant.INTERFACE_IP_ADDRESS:
- handler = new InterfaceIpAddressImpl(params, ctx);
- break;
- default:
- throw new Exception("No Rule Defined to process :" + params.getRuleType());
- }
- handler.processRule();
-
- }
- log.info("responsePrefix =" + responsePrefix);
- ctx.setAttribute(responsePrefix + InstarClientConstant.INSTAR_KEY_VALUES, ctx.getAttribute(InstarClientConstant.INSTAR_KEY_VALUES));
- ctx.setAttribute(responsePrefix + InstarClientConstant.OUTPUT_PARAM_STATUS, InstarClientConstant.OUTPUT_STATUS_SUCCESS);
- ctx.setAttribute(InstarClientConstant.INSTAR_KEY_VALUES, null);
- }
- catch (Exception e)
- {
- ctx.setAttribute(responsePrefix + InstarClientConstant.OUTPUT_PARAM_STATUS, InstarClientConstant.OUTPUT_STATUS_FAILURE);
- ctx.setAttribute(responsePrefix + InstarClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
- log.error("Failed processing Instar request" + e.getMessage());
- e.printStackTrace();
- throw new SvcLogicException(e.getMessage());
- }
- }
- private static String[] getInstarKeys(String keyString) {
- String fn = "InstarClientNode.getInstarKeys";
- System.out.println("Received instar Key String as :" + keyString);
+ public void getInstarInfo(Map<String, String> inParams, SvcLogicContext ctx)
+ throws SvcLogicException{
+ log.info("Received getInstarInfo call with params : " + inParams);
+ String responsePrefix = (String)inParams.get(InstarClientConstant.INPUT_PARAM_RESPONSE_PRIFIX);
+ try
+ {
+ responsePrefix = StringUtils.isNotBlank(responsePrefix) ? responsePrefix + "." : "";
+ String [] instarKeys = getKeys(inParams.get(InstarClientConstant.INSTAR_KEYS));
+ for (String instarKey : instarKeys){
+ log.info("Processing Key : " + instarKey);
+ log.info("Searching key for : " + "INSTAR." + instarKey);
+ ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
+ RuleHandlerInterface handler = null;
+ log.info("Received Context : " + ctx.getAttribute("INSTAR." + instarKey));
+ Parameter params = mapper.readValue(ctx.getAttribute(InstarClientConstant.SOURCE_SYSTEM_INSTAR + "." + instarKey), Parameter.class);
+
+ log.info("Processing rule Type : " + params.getRuleType());
+ switch(params.getRuleType()){
+ case InstarClientConstant.INTERFACE_IP_ADDRESS:
+ handler = new InterfaceIpAddressImpl(params, ctx);
+ break;
+ default:
+ throw new Exception("No Rule Defined to process :" + params.getRuleType());
+ }
+ handler.processRule();
+
+ }
+ log.info("responsePrefix =" + responsePrefix);
+ ctx.setAttribute(responsePrefix + InstarClientConstant.INSTAR_KEY_VALUES, ctx.getAttribute(InstarClientConstant.INSTAR_KEY_VALUES));
+ ctx.setAttribute(responsePrefix + InstarClientConstant.OUTPUT_PARAM_STATUS, InstarClientConstant.OUTPUT_STATUS_SUCCESS);
+ ctx.setAttribute(InstarClientConstant.INSTAR_KEY_VALUES, null);
+ }
+ catch (Exception e)
+ {
+ ctx.setAttribute(responsePrefix + InstarClientConstant.OUTPUT_PARAM_STATUS, InstarClientConstant.OUTPUT_STATUS_FAILURE);
+ ctx.setAttribute(responsePrefix + InstarClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
+ log.error("Failed processing Instar request" + e.getMessage());
+ e.printStackTrace();
+ throw new SvcLogicException(e.getMessage());
+ }
+ }
+ private static String[] getKeys(String keyString) {
+ String fn = "InstarClientNode.getKeys";
+ System.out.println("Received Key String as :" + keyString);
keyString = keyString.replace("[","");
keyString = keyString.replace("]", "");
@@ -103,31 +105,65 @@ public class InstarClientNode implements SvcLogicJavaPlugin
String[] keys = {keyString};
return keys;
}
- }
- public void getInstarData(Map<String, String> inParams, SvcLogicContext ctx)
- throws SvcLogicException{
- log.info("Received getInstarData call with params : " + inParams);
- String responsePrefix = (String)inParams.get(InstarClientConstant.INPUT_PARAM_RESPONSE_PRIFIX);
- try
- {
- HashMap<String, String> input = new HashMap<String, String>();
- input.putAll(inParams);
- RestClientInterface rcINterface = new InstarRestClientImpl(input);
- String response = rcINterface.sendRequest(inParams.get("operationName"));
-
- responsePrefix = StringUtils.isNotBlank(responsePrefix) ? responsePrefix + "." : "";
- ctx.setAttribute(responsePrefix + InstarClientConstant.OUTPUT_PARAM_STATUS, InstarClientConstant.OUTPUT_STATUS_SUCCESS);
- ctx.setAttribute(responsePrefix + InstarClientConstant.INSTAR_KEY_VALUES, response);
-
- }
- catch (Exception e)
- {
- ctx.setAttribute(responsePrefix + InstarClientConstant.OUTPUT_PARAM_STATUS, InstarClientConstant.OUTPUT_STATUS_FAILURE);
- ctx.setAttribute(responsePrefix + InstarClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
- log.error("Failed processing Instar request" + e.getMessage());
- e.printStackTrace();
- throw new SvcLogicException(e.getMessage());
- }
- }
+ }
+ public void getInstarData(Map<String, String> inParams, SvcLogicContext ctx)
+ throws SvcLogicException{
+ log.info("Received getInstarData call with params : " + inParams);
+ String responsePrefix = (String)inParams.get(InstarClientConstant.INPUT_PARAM_RESPONSE_PRIFIX);
+ try
+ {
+ HashMap<String, String> input = new HashMap<String, String>();
+ input.putAll(inParams);
+ RestClientInterface rcINterface = new InstarRestClientImpl(input);
+ String response = rcINterface.sendRequest(inParams.get("operationName"));
+
+ responsePrefix = StringUtils.isNotBlank(responsePrefix) ? responsePrefix + "." : "";
+ ctx.setAttribute(responsePrefix + InstarClientConstant.OUTPUT_PARAM_STATUS, InstarClientConstant.OUTPUT_STATUS_SUCCESS);
+ ctx.setAttribute(responsePrefix + InstarClientConstant.INSTAR_KEY_VALUES, response);
+
+ }
+ catch (Exception e)
+ {
+ ctx.setAttribute(responsePrefix + InstarClientConstant.OUTPUT_PARAM_STATUS, InstarClientConstant.OUTPUT_STATUS_FAILURE);
+ ctx.setAttribute(responsePrefix + InstarClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
+ log.error("Failed processing Instar request" + e.getMessage());
+ e.printStackTrace();
+ throw new SvcLogicException(e.getMessage());
+ }
+ }
+public void getAaiInfo(Map<String, String> inParams, SvcLogicContext ctx) throws SvcLogicException {
+ log.info("Received getAaiInfo call with params : " + inParams);
+ String responsePrefix = (String) inParams.get(AaiClientConstant.INPUT_PARAM_RESPONSE_PRIFIX);
+ try {
+ responsePrefix = StringUtils.isNotBlank(responsePrefix) ? responsePrefix + "." : "";
+ String[] aaiKeys = getKeys(inParams.get(AaiClientConstant.AAI_KEYS));
+ for (String aaiKey : aaiKeys) {
+ log.info("Processing Key : " + aaiKey);
+ log.info("Searching key for : " + "AAI." + aaiKey);
+ ObjectMapper mapper = new ObjectMapper(new YAMLFactory());
+ RuleHandlerInterface handler = null;
+ log.info("Received Context : " + ctx.getAttribute("AAI." + aaiKey));
+ Parameter params = mapper.readValue(
+ ctx.getAttribute(AaiClientConstant.SOURCE_SYSTEM_AAI + "." + aaiKey), Parameter.class);
+ log.info("Processing rule Type : " + params.getRuleType());
+ handler = new AaiInterfaceRulesHandler(params, ctx);
+ handler.processRule();
+
+ }
+ log.info("responsePrefix =" + responsePrefix);
+ ctx.setAttribute(responsePrefix + AaiClientConstant.AAI_KEY_VALUES,
+ ctx.getAttribute(AaiClientConstant.AAI_KEY_VALUES));
+ ctx.setAttribute(responsePrefix + AaiClientConstant.OUTPUT_PARAM_STATUS,
+ AaiClientConstant.OUTPUT_STATUS_SUCCESS);
+ ctx.setAttribute(AaiClientConstant.AAI_KEY_VALUES, null);
+ } catch (Exception e) {
+ ctx.setAttribute(responsePrefix + AaiClientConstant.OUTPUT_PARAM_STATUS,
+ InstarClientConstant.OUTPUT_STATUS_FAILURE);
+ ctx.setAttribute(responsePrefix + AaiClientConstant.OUTPUT_PARAM_ERROR_MESSAGE, e.getMessage());
+ log.error("Failed processing AAI data" + e.getMessage());
+ e.printStackTrace();
+ throw new SvcLogicException(e.getMessage());
+ }
+ }
}
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/instar/utils/InstarClientConstant.java b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/instar/utils/InstarClientConstant.java
index 30e59db22..800bbe28f 100644
--- a/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/instar/utils/InstarClientConstant.java
+++ b/appc-outbound/appc-network-inventory-client/provider/src/main/java/org/onap/appc/instar/utils/InstarClientConstant.java
@@ -9,15 +9,15 @@
* 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=========================================================
*/
@@ -26,57 +26,59 @@ package org.onap.appc.instar.utils;
public class InstarClientConstant
{
- public static String INPUT_PARAM_RESPONSE_PRIFIX = "responsePrefix";
- public static String OUTPUT_PARAM_STATUS = "status";
- public static String OUTPUT_PARAM_ERROR_MESSAGE = "error-message";
- public static String OUTPUT_STATUS_SUCCESS = "success";
- public static String OUTPUT_STATUS_FAILURE = "failure";
+ public static String INPUT_PARAM_RESPONSE_PRIFIX = "responsePrefix";
+ public static String OUTPUT_PARAM_STATUS = "status";
+ public static String OUTPUT_PARAM_ERROR_MESSAGE = "error-message";
+ public static String OUTPUT_STATUS_SUCCESS = "success";
+ public static String OUTPUT_STATUS_FAILURE = "failure";
+ public static final String INSTAR_KEYS = "instarKeys";
+ public static final String INTERFACE_IP_ADDRESS = "interface-ip-address";
+ public static final String SOURCE_SYSTEM_INSTAR = "INSTAR";
+ public static final String VNF_TYPE = "vnf-type";
+ public static final String ADDRESSFDQN = "addressfqdn";
+ public static final String VNF_NAME = "vnf-name";
+ public static final String INSTAR_KEY_VALUES = "INSTAR-KEY-VALUES";
+ public static final String INSTAR_RESPONSE_BLOCK_NAME = "vnfConfigurationParameterDetails";
+ public static final String FDQN = "fqdn";
- public static final String INSTAR_KEYS = "instarKeys";
- public static final String INTERFACE_IP_ADDRESS = "interface-ip-address";
- public static final String SOURCE_SYSTEM_INSTAR = "INSTAR";
- public static final String VNF_TYPE = "vnf-type";
- public static final String ADDRESSFDQN = "addressfqdn";
- public static final String VNF_NAME = "vnf-name";
- public static final String INSTAR_KEY_VALUES = "INSTAR-KEY-VALUES";
- public static final String INSTAR_RESPONSE_BLOCK_NAME = "vnfConfigurationParameterDetails";
- public static final String FDQN = "fqdn";
+ public static final String MOCK_INSTAR="mock_instar";
+ public static final String AFT_LATITUDE="aft_latitude";
+ public static final String AFT_LONGITUDE="aft_latitude";
+ public static final String AFT_ENVIRONMENT="aft_environment";
+ public static final String SCLD_PLATFORM="scld_platform";
+ public static final String AUTHORIZATION="authorization";
+ public static final String DME2_CLIENT_TIMEOUTMS="dme2_client_timeoutms";
+ public static final String DME2_CLIENT_SENDANDWAIT="dme2_client_sendandwait";
+ public static final String BASE_URL="_base_url";
+ public static final String HTTP_HEADERS="_http_headers";
+ public static final String V6_ADDRESS="ipaddress-v6";
+ public static final String INSTAR_V6_ADDRESS="v6IPAddress";
+ public static final String INSTAR_V6_SUBNET="v6Subnet";
+ public static final String INSTAR_V6_DEFAULT_GATEWAY="v6DefaultGateway";
- public static final String MOCK_INSTAR="mock_instar";
- public static final String AFT_LATITUDE="aft_latitude";
- public static final String AFT_LONGITUDE="aft_latitude";
- public static final String AFT_ENVIRONMENT="aft_environment";
- public static final String SCLD_PLATFORM="scld_platform";
- public static final String AUTHORIZATION="authorization";
- public static final String DME2_CLIENT_TIMEOUTMS="dme2_client_timeoutms";
- public static final String DME2_CLIENT_SENDANDWAIT="dme2_client_sendandwait";
- public static final String BASE_URL="_base_url";
- public static final String HTTP_HEADERS="_http_headers";
-
- public static final String V6_ADDRESS="ipaddress-v6";
- public static final String INSTAR_V6_ADDRESS="v6IPAddress";
-
-
- public static final String V4_ADDRESS="ipaddress-v4";
- public static final String INSTAR_V4_ADDRESS="v4IPAddress";
+ public static final String V4_ADDRESS="ipaddress-v4";
+ public static final String INSTAR_V4_ADDRESS="v4IPAddress";
+ public static final String INSTAR_V4_SUBNET="v4Subnet";
+ public static final String INSTAR_V4_DEFAULT_GATEWAY="v4DefaultGateway";
+ public static final String SUB_CONTEXT_BYIPADDRESS="_sub_context_byipaddress";
+ public static final String SUB_CONTEXT_BYMASK="_sub_context_bymask";
+ public static final String SUB_CONTEXT="_sub_context";
+ public static final String URL_SUFFIX="_suffix";
+ public static final String VERSION="_version";
+ public static final String ENV_CONTEXT="_env_context";
+ public static final String ROUTEOFFER="_routeoffer";
+ public static final String APPC_PROPERTIES = "appc.properties";
+ public static final String METHOD="_method";
+ public static final String OPERATION_GET_IPADDRESS_BY_VNF_NAME = "getIpAddressByVnf";
- public static final String SUB_CONTEXT="_sub_context";
- public static final String URL_SUFFIX="_suffix";
- public static final String VERSION="_version";
- public static final String ENV_CONTEXT="_env_context";
- public static final String ROUTEOFFER="_routeoffer";
- public static final String APPC_PROPERTIES = "appc.properties";
- public static final String METHOD="_method";
- public static final String OPERATION_GET_IPADDRESS_BY_VNF_NAME = "getIpAddressByVnf";
-
- public static final String OUTBOUND_PROPERTIES= "/outbound.properties";
+ public static final String OUTBOUND_PROPERTIES= "/outbound.properties";
- public static String CONTENT_TYPE = "application/json";
- public static String RETURNED_RESPONSE_TYPE = "application/json";
+ public static String CONTENT_TYPE = "application/json";
+ public static String RETURNED_RESPONSE_TYPE = "application/json";
}
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/interfaceImpl/TestInstarResponseHandlerImpl.java b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/interfaceImpl/TestInstarResponseHandlerImpl.java
index b0ad3c184..693ff7755 100644
--- a/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/interfaceImpl/TestInstarResponseHandlerImpl.java
+++ b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/interfaceImpl/TestInstarResponseHandlerImpl.java
@@ -9,29 +9,32 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
* ============LICENSE_END=========================================================
*/
package org.onap.appc.instar.interfaceImpl;
+import static org.junit.Assert.assertTrue;
+
import org.junit.Test;
+import org.onap.appc.instar.utils.InstarClientConstant;
import org.onap.sdnc.config.params.data.ResponseKey;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
public class TestInstarResponseHandlerImpl {
@Test
- public void testProcessResponseForIpv4(){
+ public void testProcessResponseForIpv4() {
ResponseKey resKey = new ResponseKey();
resKey.setUniqueKeyValue("x");
SvcLogicContext svc = new SvcLogicContext();
@@ -42,10 +45,10 @@ public class TestInstarResponseHandlerImpl {
+ "[{\"fqdn\":\"fqdnx\",\"v4IPAddress\":\"value2\"}]}";
InstarResponseHandlerImpl impl = new InstarResponseHandlerImpl(resKey,svc);
impl.processResponse(instarRes, instarKey);
- }
+ }
@Test
- public void testProcessResponseForIpv6(){
+ public void testProcessResponseForIpv6() {
ResponseKey resKey = new ResponseKey();
resKey.setUniqueKeyValue("x");
SvcLogicContext svc = new SvcLogicContext();
@@ -57,10 +60,9 @@ public class TestInstarResponseHandlerImpl {
InstarResponseHandlerImpl impl = new InstarResponseHandlerImpl(resKey,svc);
impl.processResponse(instarRes, instarKey);
}
-
+
@Test
- public void testProcessResponseInstarKeyValues(){
-
+ public void testProcessResponseInstarKeyValues() {
ResponseKey resKey = new ResponseKey();
resKey.setUniqueKeyValue("x");
String json ="{\"vnfConfigurationParameterDetails\":"
@@ -75,4 +77,76 @@ public class TestInstarResponseHandlerImpl {
InstarResponseHandlerImpl impl = new InstarResponseHandlerImpl(resKey,svc);
impl.processResponse(instarRes, instarKey);
}
+
+ @Test
+ public void testV4SubNet() {
+ ResponseKey resKey = new ResponseKey();
+ resKey.setUniqueKeyValue("x");
+ resKey.setFieldKeyName(InstarClientConstant.INSTAR_V4_SUBNET);
+ String json ="{\"v4IpAddress\":\"ipAddressV4\"}]}";
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("vnf-name", "fqdn");
+ ctx.setAttribute("INSTAR-KEY-VALUES", json);
+ String instarKey = "V4SubnetParameter";
+ String instarRes ="{\"vnfConfigurationParameterDetails\":"
+ + "[{\"fqdn\":\"fqdnx\",\"v4Subnet\":\"subnetv4\"}]}";
+ InstarResponseHandlerImpl impl = new InstarResponseHandlerImpl(resKey,ctx);
+ impl.processResponse(instarRes, instarKey);
+ String values = ctx.getAttribute("INSTAR-KEY-VALUES");
+ assertTrue(values.contains("subnetv4"));
+ }
+
+ @Test
+ public void testV6SubNet() {
+ ResponseKey resKey = new ResponseKey();
+ resKey.setUniqueKeyValue("x");
+ resKey.setFieldKeyName(InstarClientConstant.INSTAR_V6_SUBNET);
+ String json ="{\"v6IpAddress\":\"ipAddressV6\"}]}";
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("vnf-name", "fqdn");
+ ctx.setAttribute("INSTAR-KEY-VALUES", json);
+ String instarKey = "V6SubnetParameter";
+ String instarRes ="{\"vnfConfigurationParameterDetails\":"
+ + "[{\"fqdn\":\"fqdnx\",\"v6Subnet\":\"subnetv6\"}]}";
+ InstarResponseHandlerImpl impl = new InstarResponseHandlerImpl(resKey,ctx);
+ impl.processResponse(instarRes, instarKey);
+ String values = ctx.getAttribute("INSTAR-KEY-VALUES");
+ assertTrue(values.contains("subnetv6"));
+ }
+
+ @Test
+ public void testV6DefaultGateway() {
+ ResponseKey resKey = new ResponseKey();
+ resKey.setUniqueKeyValue("x");
+ resKey.setFieldKeyName(InstarClientConstant.INSTAR_V6_DEFAULT_GATEWAY);
+ String json ="{\"v6IpAddress\":\"ipAddressV6\"}]}";
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("vnf-name", "fqdn");
+ ctx.setAttribute("INSTAR-KEY-VALUES", json);
+ String instarKey = "V6DefaultGatewayParameter";
+ String instarRes ="{\"vnfConfigurationParameterDetails\":"
+ + "[{\"fqdn\":\"fqdnx\",\"v6DefaultGateway\":\"defaultGatewayV6\"}]}";
+ InstarResponseHandlerImpl impl = new InstarResponseHandlerImpl(resKey,ctx);
+ impl.processResponse(instarRes, instarKey);
+ String values = ctx.getAttribute("INSTAR-KEY-VALUES");
+ assertTrue(values.contains("defaultGatewayV6"));
+ }
+
+ @Test
+ public void testV4DefaultGateway() {
+ ResponseKey resKey = new ResponseKey();
+ resKey.setUniqueKeyValue("x");
+ resKey.setFieldKeyName(InstarClientConstant.INSTAR_V4_DEFAULT_GATEWAY);
+ String json ="{\"v4IpAddress\":\"ipAddressV4\"}]}";
+ SvcLogicContext ctx = new SvcLogicContext();
+ ctx.setAttribute("vnf-name", "fqdn");
+ ctx.setAttribute("INSTAR-KEY-VALUES", json);
+ String instarKey = "V4DefaultGatewayParameter";
+ String instarRes ="{\"vnfConfigurationParameterDetails\":"
+ + "[{\"fqdn\":\"fqdnx\",\"v4DefaultGateway\":\"defaultGatewayV4\"}]}";
+ InstarResponseHandlerImpl impl = new InstarResponseHandlerImpl(resKey,ctx);
+ impl.processResponse(instarRes, instarKey);
+ String values = ctx.getAttribute("INSTAR-KEY-VALUES");
+ assertTrue(values.contains("defaultGatewayV4"));
+ }
}
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/node/TestDme2Client.java b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/node/TestDme2Client.java
index 8e87ffe35..688a64af9 100644
--- a/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/node/TestDme2Client.java
+++ b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/node/TestDme2Client.java
@@ -9,21 +9,23 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
* ============LICENSE_END=========================================================
*/
package org.onap.appc.instar.node;
+import static org.junit.Assert.assertTrue;
+
import java.util.HashMap;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -33,10 +35,10 @@ import org.powermock.modules.junit4.PowerMockRunner;
@RunWith(PowerMockRunner.class)
public class TestDme2Client {
-
+
@Test(expected=Exception.class)
- public void testSendtoInstar() throws Exception{
-
+ public void testSendtoInstar() throws Exception {
+
HashMap<String,String> data = new HashMap<String,String>();
data.put("subtext","value");
PowerMockito.mockStatic(System.class);
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/node/TestInstarClientNode.java b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/node/TestInstarClientNode.java
index 285662f75..bca2087e8 100644
--- a/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/node/TestInstarClientNode.java
+++ b/appc-outbound/appc-network-inventory-client/provider/src/test/java/org/onap/appc/instar/node/TestInstarClientNode.java
@@ -9,21 +9,23 @@
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
- *
+ *
* ECOMP is a trademark and service mark of AT&T Intellectual Property.
* ============LICENSE_END=========================================================
*/
package org.onap.appc.instar.node;
+import static org.junit.Assert.assertTrue;
+
import java.net.URI;
import java.nio.charset.Charset;
import java.util.HashMap;
@@ -33,9 +35,11 @@ import javax.net.ssl.SSLContext;
import javax.ws.rs.HttpMethod;
import org.apache.commons.io.IOUtils;
+import org.apache.commons.lang3.StringUtils;
import org.json.JSONObject;
import org.junit.Assert;
import org.junit.Test;
+import org.onap.appc.aai.utils.AaiClientConstant;
import org.onap.appc.instar.dme2client.SecureRestClientTrustManager;
import org.onap.appc.instar.utils.InstarClientConstant;
import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
@@ -48,12 +52,11 @@ import com.sun.jersey.api.client.filter.HTTPBasicAuthFilter;
public class TestInstarClientNode {
-
+
//ONAP Migration
@Test(expected=Exception.class)
public void testInstarClientNode() throws Exception {
-
SvcLogicContext ctx = new SvcLogicContext();
String key_conetent = IOUtils.toString(TestInstarClientNode.class.getClassLoader().getResourceAsStream("templates/sampleKeyContents"), Charset.defaultCharset());
Map<String, String> inParams = new HashMap<String, String>();
@@ -69,15 +72,77 @@ public class TestInstarClientNode {
}
@Test(expected=Exception.class)
public void testInstarData() throws Exception {
-
InstarClientNode inNode = new InstarClientNode();
SvcLogicContext ctx = new SvcLogicContext ();
Map<String, String> inParams = new HashMap<String, String>();
inParams.put(InstarClientConstant.VNF_NAME, "basx0003v");
- inParams.put("operationName", InstarClientConstant.OPERATION_GET_IPADDRESS_BY_VNF_NAME);
+ inParams.put("operationName", InstarClientConstant.OPERATION_GET_IPADDRESS_BY_VNF_NAME);
inNode.getInstarData(inParams, ctx);
-
+ }
+
+ @Test
+ public void TestGetAaiInfo() throws Exception {
+ InstarClientNode aaiNode=new InstarClientNode();
+ Map<String, String> inParams=new HashMap<String, String> ();
+ SvcLogicContext ctx=new SvcLogicContext();
+ String keyVals=new String("[\"LOCAL_CORE_ALT_IP_ADDR\",\"REMOTE_ACCESS_IP_ADDR\",\"PARAMETER3\",\"PARAMETER4\"]");
+ inParams.put("aaiKeys",keyVals);
+ inParams.put("responsePrefix","test");
+ String yamlParameterString=IOUtils.toString(TestInstarClientNode.class.getClassLoader().getResourceAsStream("./YamlParameter.txt"), Charset.defaultCharset());
+ ctx.setAttribute(AaiClientConstant.SOURCE_SYSTEM_AAI + "." + "LOCAL_CORE_ALT_IP_ADDR",yamlParameterString);
+ String yamlParameterString2=IOUtils.toString(TestInstarClientNode.class.getClassLoader().getResourceAsStream("./YamlParameter2.txt"), Charset.defaultCharset());
+ ctx.setAttribute(AaiClientConstant.SOURCE_SYSTEM_AAI + "." + "REMOTE_ACCESS_IP_ADDR",yamlParameterString2);
+ String yamlParameterString3=IOUtils.toString(TestInstarClientNode.class.getClassLoader().getResourceAsStream("./YamlParameter3.txt"), Charset.defaultCharset());
+ ctx.setAttribute(AaiClientConstant.SOURCE_SYSTEM_AAI + "." + "PARAMETER3",yamlParameterString3);
+ String yamlParameterString4=IOUtils.toString(TestInstarClientNode.class.getClassLoader().getResourceAsStream("./YamlParameter4.txt"), Charset.defaultCharset());
+ ctx.setAttribute(AaiClientConstant.SOURCE_SYSTEM_AAI + "." + "PARAMETER4",yamlParameterString4);
+ stubAaiVnfInfoData(ctx);
+ aaiNode.getAaiInfo(inParams, ctx);
+ String [] valToCompare={"\"LOCAL_CORE_ALT_IP_ADDR\":\"testVnf\"",
+ "\"REMOTE_ACCESS_IP_ADDR\":\"testVnfc2,testVnfc3\"",
+ "\"PARAM3\":\"testVnfcIpv4Address1\"",
+ "\"PARAM4\":\"server1,server2,server3\""};
+ String value=ctx.getAttribute("test."+AaiClientConstant.AAI_KEY_VALUES);
+ boolean pass=false;
+ for (int i=0;i<valToCompare.length;i++) {
+ if (!StringUtils.contains(value,valToCompare[i] )) {
+ //System.out.println(value+"....... "+valToCompare[i].toString());
+ pass=false;
+ break;
+ }
+ else {
+ pass=true;
+ }
+ }
+ assertTrue(pass);
+ }
+
+ public void stubAaiVnfInfoData(SvcLogicContext context) {
+
+ context.setAttribute("tmp.vnfInfo.vm-count","3");
+ context.setAttribute("tmp.vnfInfo.vnf.vnf-name","testVnf");
+ context.setAttribute("tmp.vnfInfo.vnf.vnf-oam-ipv4-address","test-ipv4-address");
+ context.setAttribute("tmp.vnfInfo.vm[0].vserver-name","server1");
+ context.setAttribute("tmp.vnfInfo.vm[0].vserver-id","serverId1");
+ context.setAttribute("tmp.vnfInfo.vm[0].vnfc-count","1");
+ context.setAttribute("tmp.vnfInfo.vm[0].vnfc-name","testVnfc1");
+ context.setAttribute("tmp.vnfInfo.vm[0].vnfc-function-code","msc");
+ context.setAttribute("tmp.vnfInfo.vm[0].vnfc-ipaddress-v4-oam-vip","testVnfcIpv4Address1");
+
+ context.setAttribute("tmp.vnfInfo.vm[1].vserver-name","server2");
+ context.setAttribute("tmp.vnfInfo.vm[1].vserver-id","serverId2");
+ context.setAttribute("tmp.vnfInfo.vm[1].vnfc-count","1");
+ context.setAttribute("tmp.vnfInfo.vm[1].vnfc-name","testVnfc2");
+ context.setAttribute("tmp.vnfInfo.vm[1].vnfc-function-code","testFnCode");
+ context.setAttribute("tmp.vnfInfo.vm[1].vnfc-ipaddress-v4-oam-vip","testVnfcIpv4Address2");
+
+ context.setAttribute("tmp.vnfInfo.vm[2].vserver-name","server3");
+ context.setAttribute("tmp.vnfInfo.vm[2].vserver-id","serverId3");
+ context.setAttribute("tmp.vnfInfo.vm[2].vnfc-count","1");
+ context.setAttribute("tmp.vnfInfo.vm[2].vnfc-name","testVnfc3");
+ context.setAttribute("tmp.vnfInfo.vm[2].vnfc-function-code","testFnCode");
+ context.setAttribute("tmp.vnfInfo.vm[2].vnfc-ipaddress-v4-oam-vip","testVnfcIpv4Address3");
}
}
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter.txt b/appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter.txt
new file mode 100644
index 000000000..1e2d347fc
--- /dev/null
+++ b/appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter.txt
@@ -0,0 +1,16 @@
+name: "LOCAL_CORE_ALT_IP_ADDR"
+description: null
+type: null
+required: false
+source: "A&AI"
+rule-type: null
+default: "0:0:0:0"
+request-keys:
+- key-name: "address_fqdn"
+ key-value: "value"
+- key-name: "address_type"
+ key-value: "v4"
+response-keys:
+- unique-key-name: "parent-name"
+- unique-key-value: "vnf"
+- field-key-name: "vnf-name"
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter2.txt b/appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter2.txt
new file mode 100644
index 000000000..cebc0f9e1
--- /dev/null
+++ b/appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter2.txt
@@ -0,0 +1,18 @@
+name: "REMOTE_ACCESS_IP_ADDR"
+description: null
+type: null
+required: false
+source: "A&AI"
+rule-type: null
+default: "0:0:0:0"
+request-keys:
+- key-name: "address_fqdn"
+ key-value: "value"
+- key-name: "address_type"
+ key-value: "v4"
+response-keys:
+- unique-key-name: "parent-name"
+- unique-key-value: "vnfc"
+- field-key-name: "vnfc-name"
+- filter-by-field: "vnfc-function-code"
+- filter-by-value: "testFnCode"
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter3.txt b/appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter3.txt
new file mode 100644
index 000000000..060b55eae
--- /dev/null
+++ b/appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter3.txt
@@ -0,0 +1,18 @@
+name: "PARAM3"
+description: null
+type: null
+required: false
+source: "A&AI"
+rule-type: null
+default: "0:0:0:0"
+request-keys:
+- key-name: "address_fqdn"
+ key-value: "value"
+- key-name: "address_type"
+ key-value: "v4"
+response-keys:
+- unique-key-name: "parent-name"
+- unique-key-value: "vnfc"
+- field-key-name: "ipaddress-v4-oam-vip"
+- filter-by-field: "vnfc-function-code"
+- filter-by-value: "msc"
diff --git a/appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter4.txt b/appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter4.txt
new file mode 100644
index 000000000..e334903d1
--- /dev/null
+++ b/appc-outbound/appc-network-inventory-client/provider/src/test/resources/YamlParameter4.txt
@@ -0,0 +1,16 @@
+name: "PARAM4"
+description: null
+type: null
+required: false
+source: "A&AI"
+rule-type: null
+default: "0:0:0:0"
+request-keys:
+- key-name: "address_fqdn"
+ key-value: "value"
+- key-name: "address_type"
+ key-value: "v4"
+response-keys:
+- unique-key-name: "parent-name"
+- unique-key-value: "vserver"
+- field-key-name: "vserver-name"