From 774b738e809b3888c92573dc18961496bfb8b3eb Mon Sep 17 00:00:00 2001 From: "Leigh, Phillip (pl876u)" Date: Fri, 18 Jan 2019 17:56:41 -0500 Subject: Enhance aaiCtxBuider to handle PServer &Pinterface Issue-ID: LOG-762 Issue-ID: LOG-765 Change-Id: If47ef66324c4b5d746b92c596c2e00444708c890 Signed-off-by: Leigh, Phillip (pl876u) --- .../aai/datatype/PInterfaceInstance.java | 237 +++++++++ .../aai/datatype/PInterfaceInstanceList.java | 81 +++ .../contextbuilder/aai/datatype/PnfInstance.java | 22 +- .../aai/datatype/PserverInstance.java | 328 ++++++++++++ .../pomba/contextbuilder/aai/datatype/Vserver.java | 13 + .../pomba/contextbuilder/aai/util/RestUtil.java | 567 ++++++++++++++++++--- .../pomba_aai_context_builder/RestUtilTest.java | 131 ++++- .../resources/junit/aai-service-instance_set2.json | 27 + src/test/resources/junit/aai-vserver.json | 94 ++++ src/test/resources/junit/genericVnfInput_set2.json | 118 +++++ .../resources/junit/pnfInput_w_pInterface.json | 86 ++++ src/test/resources/junit/pserverInput_set2.json | 46 ++ .../junit/pserverInput_with_pInterface.json | 65 +++ src/test/resources/junit/queryNodeData-1.json | 2 +- 14 files changed, 1750 insertions(+), 67 deletions(-) create mode 100644 src/main/java/org/onap/pomba/contextbuilder/aai/datatype/PInterfaceInstance.java create mode 100644 src/main/java/org/onap/pomba/contextbuilder/aai/datatype/PInterfaceInstanceList.java create mode 100644 src/main/java/org/onap/pomba/contextbuilder/aai/datatype/PserverInstance.java create mode 100644 src/test/resources/junit/aai-service-instance_set2.json create mode 100644 src/test/resources/junit/aai-vserver.json create mode 100644 src/test/resources/junit/genericVnfInput_set2.json create mode 100644 src/test/resources/junit/pnfInput_w_pInterface.json create mode 100644 src/test/resources/junit/pserverInput_set2.json create mode 100644 src/test/resources/junit/pserverInput_with_pInterface.json diff --git a/src/main/java/org/onap/pomba/contextbuilder/aai/datatype/PInterfaceInstance.java b/src/main/java/org/onap/pomba/contextbuilder/aai/datatype/PInterfaceInstance.java new file mode 100644 index 0000000..a8c5004 --- /dev/null +++ b/src/main/java/org/onap/pomba/contextbuilder/aai/datatype/PInterfaceInstance.java @@ -0,0 +1,237 @@ +/* + * ============LICENSE_START=================================================== + * Copyright (c) 2018 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. + * ============LICENSE_END===================================================== + */ +package org.onap.pomba.contextbuilder.aai.datatype; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.onap.pomba.contextbuilder.aai.exception.AuditError; +import org.onap.pomba.contextbuilder.aai.exception.AuditException; + +public class PInterfaceInstance { + + @SerializedName("interface-name") + @Expose + private String interfaceName; + @SerializedName("speed-value") + @Expose + private String speedValue; + @SerializedName("speed-units") + @Expose + private String speedUnits; + @SerializedName("port-description") + @Expose + private String portDescription; + @SerializedName("equipment-identifier") + @Expose + private String equipmentIdentifier; + @SerializedName("interface-role") + @Expose + private String interfaceRole; + @SerializedName("interface-type") + @Expose + private String interfaceType; + @SerializedName("prov-status") + @Expose + private String provStatus; + @SerializedName("resource-version") + @Expose + private String resourceVersion; + @SerializedName("in-maint") + @Expose + private String inMaint; + @SerializedName("inv-status") + @Expose + private String invStatus; + + public String getInterfaceName() { + return interfaceName; + } + + public void setInterfaceName(String interfaceName) { + this.interfaceName = interfaceName; + } + + public String getSpeedValue() { + return speedValue; + } + + public void setSpeedValue(String speedValue) { + this.speedValue = speedValue; + } + + public String getSpeedUnits() { + return speedUnits; + } + + public void setSpeedUnits(String speedUnits) { + this.speedUnits = speedUnits; + } + + public String getPortDescription() { + return portDescription; + } + + public void setPortDescription(String portDescription) { + this.portDescription = portDescription; + } + + public String getEquipmentIdentifier() { + return equipmentIdentifier; + } + + public void setEquipmentIdentifier(String equipmentIdentifier) { + this.equipmentIdentifier = equipmentIdentifier; + } + + public String getInterfaceRole() { + return interfaceRole; + } + + public void setInterfaceRole(String interfaceRole) { + this.interfaceRole = interfaceRole; + } + + public String getInterfaceType() { + return interfaceType; + } + + public void setInterfaceType(String interfaceType) { + this.interfaceType = interfaceType; + } + + public String getProvStatus() { + return provStatus; + } + + public void setProvStatus(String provStatus) { + this.provStatus = provStatus; + } + + public String getResourceVersion() { + return resourceVersion; + } + + public void setResourceVersion(String resourceVersion) { + this.resourceVersion = resourceVersion; + } + + public String getInMaint() { + return inMaint; + } + + public void setInMaint(String inMaint) { + this.inMaint = inMaint; + } + + public String getInvStatus() { + return invStatus; + } + + public void setInvStatus(String invStatus) { + this.invStatus = invStatus; + } + + /** + * No args constructor for use in serialization + * + */ + public PInterfaceInstance() { + } + + /** + * + * @param interfaceName + * @param speedValue + * @param speedUnits + * @param portDescription + * @param equipmentIdentifier + * @param interfaceRole + * @param interfaceType + * @param provStatus + * @param resourceVersion + * @param inMaint + * @param invStatus + */ + public PInterfaceInstance(String interfaceName,String speedValue,String speedUnits, + String portDescription,String equipmentIdentifier,String interfaceRole,String interfaceType, + String provStatus,String resourceVersion,String inMaint, String invStatus ) { + super(); + this.interfaceName = interfaceName; + this.speedValue = speedValue; + this.speedUnits = speedUnits; + this.portDescription = portDescription; + this.equipmentIdentifier = equipmentIdentifier; + this.provStatus = provStatus; + this.resourceVersion = resourceVersion; + this.inMaint = inMaint; + this.invStatus = invStatus; + } + + private static final Gson gson = new GsonBuilder().disableHtmlEscaping().create(); + + public String toJson() { + return gson.toJson(this); + } + + public static PInterfaceInstance fromJson(String payload) throws AuditException { + try { + if (payload == null || payload.isEmpty()) { + throw new AuditException("Empty Json response"); + } + return gson.fromJson(payload, PInterfaceInstance.class); + } catch (Exception ex) { + throw new AuditException(AuditError.JSON_READER_PARSE_ERROR, ex); + } + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("interfaceName", interfaceName).append("speedValue", speedValue).append("speedUnits", speedUnits) + .append("portDescription", portDescription).append("equipmentIdentifier", equipmentIdentifier).append("interfaceRole", interfaceRole) + .append("interfaceType", interfaceType).append("provStatus", provStatus).append("resourceVersion", resourceVersion) + .append("inMaint", inMaint).append("invStatus", invStatus) + .toString(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(speedValue).append(equipmentIdentifier).toHashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if (!(other instanceof PInterfaceInstance)) { + return false; + } + PInterfaceInstance rhs = ((PInterfaceInstance) other); + return new EqualsBuilder().append(interfaceName, rhs.interfaceName).append(speedValue, rhs.speedValue) + .append(speedUnits, rhs.speedUnits).append(equipmentIdentifier, rhs.equipmentIdentifier) + .append(interfaceRole, rhs.interfaceRole).append(interfaceType, rhs.interfaceType) + .append(inMaint, rhs.inMaint) + .isEquals(); + } + +} diff --git a/src/main/java/org/onap/pomba/contextbuilder/aai/datatype/PInterfaceInstanceList.java b/src/main/java/org/onap/pomba/contextbuilder/aai/datatype/PInterfaceInstanceList.java new file mode 100644 index 0000000..0a14726 --- /dev/null +++ b/src/main/java/org/onap/pomba/contextbuilder/aai/datatype/PInterfaceInstanceList.java @@ -0,0 +1,81 @@ +/* + * ============LICENSE_START=================================================== + * Copyright (c) 2018 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. + * ============LICENSE_END===================================================== + */ +package org.onap.pomba.contextbuilder.aai.datatype; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; +import java.util.List; +import javax.validation.Valid; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; + +public class PInterfaceInstanceList { + + @SerializedName("p-interface") + @Expose + @Valid + private List pInterfaceList = null; + + /** + * No args constructor for use in serialization + * + */ + public PInterfaceInstanceList() { + } + + /** + * + * @param pInterfaceList + */ + public PInterfaceInstanceList(List pInterfaceList) { + super(); + this.pInterfaceList = pInterfaceList; + } + + public List getPInterfaceList() { + return pInterfaceList; + } + + public void setPInterfaceList(List pInterfaceList) { + this.pInterfaceList = pInterfaceList; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("pInterfaceList", pInterfaceList).toString(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(pInterfaceList).toHashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if (!(other instanceof PInterfaceInstanceList)) { + return false; + } + PInterfaceInstanceList rhs = ((PInterfaceInstanceList) other); + return new EqualsBuilder().append(pInterfaceList, rhs.pInterfaceList).isEquals(); + } + +} diff --git a/src/main/java/org/onap/pomba/contextbuilder/aai/datatype/PnfInstance.java b/src/main/java/org/onap/pomba/contextbuilder/aai/datatype/PnfInstance.java index f470b78..35f9d60 100644 --- a/src/main/java/org/onap/pomba/contextbuilder/aai/datatype/PnfInstance.java +++ b/src/main/java/org/onap/pomba/contextbuilder/aai/datatype/PnfInstance.java @@ -23,6 +23,9 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; + +import javax.validation.Valid; + import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; @@ -80,6 +83,11 @@ public class PnfInstance { @Expose private String modelVersionId; + @SerializedName("p-interfaces") + @Expose + @Valid + private PInterfaceInstanceList pInterfaceInstanceList; + public String getModelInvariantId() { return modelInvariantId; } @@ -205,6 +213,13 @@ public class PnfInstance { this.modelVersionId = modelVersionId; } + public PInterfaceInstanceList getPInterfaceInstanceList() { + return pInterfaceInstanceList; + } + + public void setPInterfaceInstanceList(PInterfaceInstanceList pInterfaceInstanceList) { + this.pInterfaceInstanceList = pInterfaceInstanceList; + } private static final Gson gson = new GsonBuilder().disableHtmlEscaping().create(); @@ -247,9 +262,10 @@ public class PnfInstance { * @param serialNumber * @param modelInvariantId * @param modelVersionId + * @param pInterfaceInstanceList * */ - public PnfInstance(String uuid, String name, String networkRole, String name2, String name2Source,String equipmentType,String equipmentVendor,String equipmentModel,String managementOptions,String swVersion, String frameId, String serialNumber, String modelInvariantId, String modelVersionId) { + public PnfInstance(String uuid, String name, String networkRole, String name2, String name2Source,String equipmentType,String equipmentVendor,String equipmentModel,String managementOptions,String swVersion, String frameId, String serialNumber, String modelInvariantId, String modelVersionId, PInterfaceInstanceList pInterfaceInstanceList) { super(); this.pnfId = uuid; this.pnfName = name; @@ -265,6 +281,7 @@ public class PnfInstance { this.serialNumber = serialNumber; this.modelInvariantId = modelInvariantId; this.modelVersionId = modelVersionId; + this.pInterfaceInstanceList = pInterfaceInstanceList; } @@ -287,12 +304,13 @@ public class PnfInstance { .append("serialNumber", serialNumber) .append("modelInvariantId", modelInvariantId) .append("modelVersionId", modelVersionId) + .append("pInterfaceInstanceList", pInterfaceInstanceList) .toString(); } @Override public int hashCode() { - return new HashCodeBuilder().append(pnfId).append(frameId).append(serialNumber).append(modelInvariantId).append(modelVersionId).toHashCode(); + return new HashCodeBuilder().append(pnfId).append(frameId).append(serialNumber).append(modelInvariantId).append(modelVersionId).append(pInterfaceInstanceList).toHashCode(); } @Override diff --git a/src/main/java/org/onap/pomba/contextbuilder/aai/datatype/PserverInstance.java b/src/main/java/org/onap/pomba/contextbuilder/aai/datatype/PserverInstance.java new file mode 100644 index 0000000..63b3f70 --- /dev/null +++ b/src/main/java/org/onap/pomba/contextbuilder/aai/datatype/PserverInstance.java @@ -0,0 +1,328 @@ +/* + * ============LICENSE_START=================================================== + * Copyright (c) 2018 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. + * ============LICENSE_END===================================================== + */ + +package org.onap.pomba.contextbuilder.aai.datatype; + + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + +import javax.validation.Valid; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.onap.pomba.contextbuilder.aai.exception.AuditError; +import org.onap.pomba.contextbuilder.aai.exception.AuditException; + +public class PserverInstance { + + @SerializedName("pserver-id") + @Expose + private String pserverId; + @SerializedName("hostname") + @Expose + private String hostname; + @SerializedName("pserver-name2") + @Expose + private String pserverName2; + @SerializedName("ptnii-equip-name") + @Expose + private String ptniiEquipName; + @SerializedName("equip-type") + @Expose + private String equipType; + @SerializedName("equip-vendor") + @Expose + private String equipVendor; + @SerializedName("equip-model") + @Expose + private String equipModel; + @SerializedName("fqdn") + @Expose + private String fqdn; + @SerializedName("serial-number") + @Expose + private String serialNumber; + @SerializedName("internet-topology") + @Expose + private String internetTopology; + @SerializedName("in-maint") + @Expose + private String inMaint; + @SerializedName("resource-version") + @Expose + private String resourceVersion; + @SerializedName("purpose") + @Expose + private String purpose; + @SerializedName("p-interfaces") + @Expose + @Valid + private PInterfaceInstanceList pInterfaceInstanceList; + + public String getPserverId() { + return pserverId; + } + + public void setPserverId(String pserverId) { + this.pserverId = pserverId; + } + + + public String getHostname() { + return hostname; + } + + + public void setHostname(String hostname) { + this.hostname = hostname; + } + + + public String getPserverName2() { + return pserverName2; + } + + + public void setPserverName2(String pserverName2) { + this.pserverName2 = pserverName2; + } + + + public String getPtniiEquipName() { + return ptniiEquipName; + } + + + public void setPtniiEquipName(String ptniiEquipName) { + this.ptniiEquipName = ptniiEquipName; + } + + + public String getEquipType() { + return equipType; + } + + + public void setEquipType(String equipType) { + this.equipType = equipType; + } + + + public String getEquipVendor() { + return equipVendor; + } + + + public void setEquipVendor(String equipVendor) { + this.equipVendor = equipVendor; + } + + + public String getEquipModel() { + return equipModel; + } + + + public void setEquipModel(String equipModel) { + this.equipModel = equipModel; + } + + + public String getFqdn() { + return fqdn; + } + + + public void setFqdn(String fqdn) { + this.fqdn = fqdn; + } + + + public String getSerialNumber() { + return serialNumber; + } + + + public void setSerialNumber(String serialNumber) { + this.serialNumber = serialNumber; + } + + + public String getInternetTopology() { + return internetTopology; + } + + + public void setInternetTopology(String internetTopology) { + this.internetTopology = internetTopology; + } + + + public String getInMaint() { + return inMaint; + } + + + public void setInMaint(String inMaint) { + this.inMaint = inMaint; + } + + + public String getResourceVersion() { + return resourceVersion; + } + + + public void setResourceVersion(String resourceVersion) { + this.resourceVersion = resourceVersion; + } + + + public String getPurpose() { + return purpose; + } + + + public void setPurpose(String purpose) { + this.purpose = purpose; + } + + public PInterfaceInstanceList getPInterfaceInstanceList() { + return pInterfaceInstanceList; + } + + public void setPInterfaceInstanceList(PInterfaceInstanceList pInterfaceInstanceList) { + this.pInterfaceInstanceList = pInterfaceInstanceList; + } + + private static final Gson gson = new GsonBuilder().disableHtmlEscaping().create(); + + public String toJson() { + return gson.toJson(this); + } + + + public static PserverInstance fromJson(String payload) throws AuditException { + try { + if (payload == null || payload.isEmpty()) { + throw new AuditException("Empty Json response"); + } + return gson.fromJson(payload, PserverInstance.class); + } catch (Exception ex) { + throw new AuditException(AuditError.JSON_READER_PARSE_ERROR, ex); + } + } + + /** + * No args constructor for use in serialization + * + */ + public PserverInstance() { + } + + /** + * + * @param pserverId + * @param hostname + * @param pserverName2 + * @param ptniiEquipName + * @param equipType + * @param equipVendor + * @param equipModel + * @param fqdn + * @param internetTopology + * @param inMaint + * @param resourceVersion + * @param serialNumber + * @param purpose + * + */ + public PserverInstance(String pserverId, String hostname, String pserverName2, + String ptniiEquipName, String equipType,String equipVendor, + String equipModel,String fqdn,String internetTopology, + String inMaint, String resourceVersion, String serialNumber, + String purpose, String relationshipList, PInterfaceInstanceList pInterfaceInstanceList) { + super(); + this.pserverId = pserverId; + this.hostname = hostname; + this.pserverName2 = pserverName2; + this.ptniiEquipName = ptniiEquipName; + this.equipType = equipType; + this.equipVendor = equipVendor; + this.equipModel = equipModel; + this.fqdn = fqdn; + this.internetTopology = internetTopology; + this.inMaint = inMaint; + this.resourceVersion = resourceVersion; + this.serialNumber = serialNumber; + this.purpose = purpose; + this.pInterfaceInstanceList = pInterfaceInstanceList; + } + + + + /////////// common functions ////////////////////// + @Override + public String toString() { + return new ToStringBuilder(this) + .append("pserver-id", pserverId) + .append("hostname", hostname) + .append("ptnii-equip-name", ptniiEquipName) + .append("pserver-name2", pserverName2) + .append("equip-type", equipType) + .append("equip-vendor", equipVendor) + .append("equip-model", equipModel) + .append("fqdn", fqdn) + .append("serial-number", serialNumber) + .append("internet-topology", internetTopology) + .append("in-maint", inMaint) + .append("resource-version", resourceVersion) + .append("purpose", purpose) + .append("pInterfaceInstanceList", pInterfaceInstanceList) + .toString(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(pserverId).append(serialNumber).append(fqdn).append(equipModel).append(pInterfaceInstanceList).toHashCode(); + } + + @Override + public boolean equals(Object other) { + if (other == this) { + return true; + } + if (!(other instanceof PserverInstance)) { + return false; + } + PserverInstance rhs = ((PserverInstance) other); + return new EqualsBuilder() + .append(pserverId, rhs.pserverId) + .append(hostname, rhs.hostname) + .append(fqdn, rhs.fqdn) + .append(serialNumber, rhs.serialNumber) + .append(equipType, rhs.equipType) + .append(equipModel, rhs.equipModel) + .append(ptniiEquipName, rhs.ptniiEquipName) + .isEquals(); + } +} diff --git a/src/main/java/org/onap/pomba/contextbuilder/aai/datatype/Vserver.java b/src/main/java/org/onap/pomba/contextbuilder/aai/datatype/Vserver.java index 368dd90..d7b8896 100644 --- a/src/main/java/org/onap/pomba/contextbuilder/aai/datatype/Vserver.java +++ b/src/main/java/org/onap/pomba/contextbuilder/aai/datatype/Vserver.java @@ -21,6 +21,9 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.annotations.Expose; import com.google.gson.annotations.SerializedName; + +import java.util.List; + import org.apache.commons.lang3.builder.EqualsBuilder; import org.apache.commons.lang3.builder.HashCodeBuilder; import org.apache.commons.lang3.builder.ToStringBuilder; @@ -53,10 +56,20 @@ public class Vserver { @SerializedName("resource-version") @Expose private String resourceVersion; + @SerializedName("relationship-list") @Expose private RelationshipList relationshipList; + private List pserverInstanceList; + public List getPserverInstanceList() { + return pserverInstanceList; + } + + public void setPserverInstanceList(List pserverInstanceList) { + this.pserverInstanceList = pserverInstanceList; + } + private static final Gson gson = new GsonBuilder().disableHtmlEscaping().create(); public String toJson() { diff --git a/src/main/java/org/onap/pomba/contextbuilder/aai/util/RestUtil.java b/src/main/java/org/onap/pomba/contextbuilder/aai/util/RestUtil.java index 21a8d10..4cd4bbe 100644 --- a/src/main/java/org/onap/pomba/contextbuilder/aai/util/RestUtil.java +++ b/src/main/java/org/onap/pomba/contextbuilder/aai/util/RestUtil.java @@ -49,13 +49,18 @@ import org.onap.pomba.contextbuilder.aai.datatype.VfModule; import org.onap.pomba.contextbuilder.aai.datatype.VnfInstance; import org.onap.pomba.contextbuilder.aai.datatype.VnfcInstance; import org.onap.pomba.contextbuilder.aai.datatype.Vserver; +import org.onap.pomba.contextbuilder.aai.datatype.PserverInstance; +import org.onap.pomba.contextbuilder.aai.datatype.PInterfaceInstance; import org.onap.pomba.contextbuilder.aai.exception.AuditError; import org.onap.pomba.contextbuilder.aai.exception.AuditException; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.onap.pomba.contextbuilder.aai.datatype.PnfInstance; +import org.onap.pomba.contextbuilder.aai.datatype.PInterfaceInstanceList; import org.onap.pomba.common.datatypes.PNF; +import org.onap.pomba.common.datatypes.PInterface; import com.bazaarvoice.jolt.JsonUtils; +import org.onap.pomba.common.datatypes.Pserver; public class RestUtil { @@ -79,6 +84,7 @@ public class RestUtil { private static final String CATALOG_VSERVER = "vserver"; private static final String CATALOG_IMAGE = "image"; private static final String CATALOG_PSERVER = "pserver"; + private static final String CATALOG_P_INTERFACE = "p-interface"; private static final String VF_MODULES = "vf-modules"; private static final String VF_MODULE = "vf-module"; @@ -99,23 +105,31 @@ public class RestUtil { private static final String DEPTH = "?depth=2"; //Attribute Name - private static final String LOCKEDBOOLEAN = "lockedBoolean"; - private static final String HOSTNAME = "hostName"; - private static final String IMAGEID = "imageId"; - - //Attribute Names for PNF - private static final String PNF_NETWORK_FUNCTION = "networkFunction"; - private static final String PNF_NETWORK_ROLE = "networkRole"; - private static final String PNF_RESOURCE_VERSION = "resourceVersion"; - private static final String PNF_NAME2 = "name2"; - private static final String PNF_NAME2_SOURCE = "name2Source"; - private static final String PNF_EQUIPMENT_TYPE = "equipType"; - private static final String PNF_EQUIPMENT_VENDOR = "equipVendor"; - private static final String PNF_EQUIPMENT_MODEL = "equipModel"; - private static final String PNF_MANAGEMENT_OPTIONS = "managementOptions"; - private static final String PNF_SW_VERSION = "swVersion"; - private static final String PNF_FRAME_ID = "frameId"; - private static final String PNF_SERIAL_NUMBER = "serialNumber"; + private static final String ATTRIBUTE_LOCKEDBOOLEAN = "lockedBoolean"; + private static final String ATTRIBUTE_HOSTNAME = "hostName"; + private static final String ATTRIBUTE_IMAGEID = "imageId"; + private static final String ATTRIBUTE_NETWORK_FUNCTION = "networkFunction"; + private static final String ATTRIBUTE_NETWORK_ROLE = "networkRole"; + private static final String ATTRIBUTE_RESOURCE_VERSION = "resourceVersion"; + private static final String ATTRIBUTE_NAME2 = "name2"; + private static final String ATTRIBUTE_NAME2_SOURCE = "name2Source"; + private static final String ATTRIBUTE_EQUIPMENT_TYPE = "equipType"; + private static final String ATTRIBUTE_EQUIPMENT_VENDOR = "equipVendor"; + private static final String ATTRIBUTE_EQUIPMENT_MODEL = "equipModel"; + private static final String ATTRIBUTE_MANAGEMENT_OPTIONS = "managementOptions"; + private static final String ATTRIBUTE_SW_VERSION = "swVersion"; + private static final String ATTRIBUTE_FRAME_ID = "frameId"; + private static final String ATTRIBUTE_SERIAL_NUMBER = "serialNumber"; + private static final String ATTRIBUTE_PTNII_NAME = "ptniiName"; + private static final String ATTRIBUTE_FQDN = "fqdn"; + private static final String ATTRIBUTE_TOPOLOGY = "topology"; + private static final String ATTRIBUTE_PURPOSE = "purpose"; + private static final String ATTRIBUTE_SPEED_VALUE = "speedValue"; + private static final String ATTRIBUTE_SPEED_UNITS = "speedUnits"; + private static final String ATTRIBUTE_PORT_DESCRIPTION = "portDescription"; + private static final String ATTRIBUTE_EQUIPTMENT_ID = "equipmentID"; + private static final String ATTRIBUTE_INTERFACE_ROLE = "interfaceRole"; + private static final String ATTRIBUTE_INTERFACE_TYPE = "interfaceType"; /** * Validates the URL parameter. @@ -239,25 +253,39 @@ public class RestUtil { vnfLst.add(vnfInstance); // Build the vnf_vnfc relationship map - vnfcMap = buildVnfcMap(genericVNFPayload, aaiClient, baseURL, transactionId, aaiBasicAuthorization ); + vnfcMap = buildVnfcMap(vnfcMap, genericVNFPayload, aaiClient, baseURL, transactionId, aaiBasicAuthorization ); // Build vnf_vfmodule_vserver relationship map - vnf_vfmodule_vserver_Map= buildVfmoduleVserverMap(genericVNFPayload, aaiClient, baseURL, transactionId, aaiBasicAuthorization); + vnf_vfmodule_vserver_Map= buildVfmoduleVserverMap(vnf_vfmodule_vserver_Map, genericVNFPayload, aaiClient, baseURL, transactionId, aaiBasicAuthorization); } } //Obtain PNF (Physical Network Function) + List pnfLst = retrieveAAIModelData_PNF (aaiClient, baseURL, transactionId, serviceInstanceId, aaiBasicAuthorization, serviceInstancePayload) ; + + + // Transform to common model and return + return transform(ServiceInstance.fromJson(serviceInstancePayload), vnfLst, vnfcMap, vnf_vfmodule_vserver_Map, pnfLst); + } + + private static List retrieveAAIModelData_PNF(RestClient aaiClient, String baseURL, + String transactionId, String serviceInstanceId, String aaiBasicAuthorization, String serviceInstancePayload) throws AuditException { + List genericPNFLinkLst = extractRelatedLink(serviceInstancePayload, CATALOG_PNF); log.info(LogMessages.NUMBER_OF_API_CALLS, "PNF", genericPNFLinkLst.size()); log.info(LogMessages.API_CALL_LIST, "PNF", printOutAPIList(genericPNFLinkLst)); + if ( genericPNFLinkLst.size() == 0) { + return null; + } + String genericPNFPayload = null; List pnfLst = new ArrayList(); // List of the PNF POJO object for (String genericPNFLink : genericPNFLinkLst) { // With latest AAI development, in order to retrieve the both generic PNF - String genericPNFURL = baseURL + genericPNFLink; + String genericPNFURL = baseURL + genericPNFLink + DEPTH; // Response from generic PNF API call genericPNFPayload = getResource(aaiClient, genericPNFURL, aaiBasicAuthorization, transactionId, MediaType.valueOf(MediaType.APPLICATION_JSON)); @@ -273,18 +301,16 @@ public class RestUtil { } } - // Transform to common model and return - return transform(ServiceInstance.fromJson(serviceInstancePayload), vnfLst, vnfcMap, vnf_vfmodule_vserver_Map, pnfLst); + return pnfLst; } /* * The map is to track the relationship of vnf-id with multiple vnfc relationship */ - private static Map> buildVnfcMap(String genericVNFPayload, RestClient aaiClient, String baseURL, + private static Map> buildVnfcMap(Map> vnfcMap, String genericVNFPayload, RestClient aaiClient, String baseURL, String transactionId, String aaiBasicAuthorization) throws AuditException { String vnfcPayload = null; - Map> vnfcMap = new HashMap>(); List vnfcLinkLst = extractRelatedLink(genericVNFPayload, CATALOG_VNFC); log.info(LogMessages.NUMBER_OF_API_CALLS, "vnfc", vnfcLinkLst.size()); @@ -305,8 +331,11 @@ public class RestUtil { vnfcLst.add(vnfcInstance); } } - // Assume the vnf-id is unique as a key - vnfcMap.put(getVnfId(genericVNFPayload), vnfcLst); + + if (vnfcLst.size() > 0) { + // Assume the vnf-id is unique as a key + vnfcMap.put(getVnfId(genericVNFPayload), vnfcLst); + } return vnfcMap; } @@ -320,9 +349,7 @@ public class RestUtil { * * The Map>> key: vnf-id */ - private static Map>> buildVfmoduleVserverMap(String genericVNFPayload, RestClient aaiClient, String baseURL, String transactionId, String aaiBasicAuthorization) throws AuditException { - - Map>> vnf_vfmodule_vserver_Map = new HashMap>>(); + private static Map>> buildVfmoduleVserverMap(Map>> vnf_vfmodule_vserver_Map, String genericVNFPayload, RestClient aaiClient, String baseURL, String transactionId, String aaiBasicAuthorization) throws AuditException { Map> vServerMap = new HashMap>(); @@ -349,18 +376,57 @@ public class RestUtil { } else { // Logic to Create the Vserver POJO object Vserver vserver = Vserver.fromJson(vserverPayload); + vserver.setPserverInstanceList(getPserverInfo_from_aai(vserverPayload, aaiClient, baseURL, transactionId, aaiBasicAuthorization)); vserverLst.add(vserver); } } - vServerMap.put(entry.getKey(), vserverLst); + if (vserverLst.size() > 0) { + vServerMap.put(entry.getKey(), vserverLst); + } + } + if (vServerMap.size()> 0) { + vnf_vfmodule_vserver_Map.put(vnfId, vServerMap); } } - vnf_vfmodule_vserver_Map.put(vnfId, vServerMap); return vnf_vfmodule_vserver_Map; } + private static List getPserverInfo_from_aai (String vserverPayload, RestClient aaiClient, String baseURL, String transactionId, String aaiBasicAuthorization) throws AuditException { + if (vserverPayload == null) { + //already reported. + return null; + } + + //Obtain related Pserver info + List pserverRelatedLinkList = handleRelationship_general (vserverPayload,CATALOG_PSERVER ); + List pserverLst = null; + if ((pserverRelatedLinkList == null) || (pserverRelatedLinkList.isEmpty())){ + // already reported + return null; + } + pserverLst = new ArrayList(); + for (String pserverRelatedLink : pserverRelatedLinkList) { + String pserverURL = baseURL + pserverRelatedLink + DEPTH;; + String pserverPayload = getResource(aaiClient, pserverURL, aaiBasicAuthorization, transactionId, + MediaType.valueOf(MediaType.APPLICATION_XML)); + + if (isEmptyJson(pserverPayload)) { + log.info(LogMessages.NOT_FOUND, "PSERVER with url", pserverURL); + } else { + log.info("Message from AAI for pserver " + pserverURL + ",message body:" + pserverPayload) ; + + // Logic to Create the Pserver POJO object + PserverInstance pserver = PserverInstance.fromJson(pserverPayload); + + //update P-Interface if any. + pserverLst.add(pserver); + } + } + return pserverLst; + } + private static String getVnfId(String genericVNFPayload) throws AuditException { @@ -377,6 +443,7 @@ public class RestUtil { Service service = new Service(); service.setModelInvariantUUID(svcInstance.getModelInvariantId()); service.setName(svcInstance.getServiceInstanceName()); + service.setModelVersionID(svcInstance.getModelVersionId()); service.setUuid(svcInstance.getServiceInstanceId()); service.setDataQuality(DataQuality.ok()); List vfLst = new ArrayList(); @@ -385,8 +452,9 @@ public class RestUtil { VNF vf = new VNF(); vf.setModelInvariantUUID(vnf.getModelInvariantId()); vf.setName(vnf.getVnfName()); - vf.setUuid(vnf.getModelVersionId()); + vf.setUuid(vnf.getVnfId()); vf.setType(vnf.getVnfType()); + vf.setModelVersionID(vnf.getModelVersionId()); vf.setDataQuality(DataQuality.ok()); String key = vnf.getVnfId(); // generic vnf-id (top level of the key) @@ -426,12 +494,18 @@ public class RestUtil { for ( Map.Entry> vfmoduleEntry: vfmodule_vserver_map.entrySet() ){ // The key is modelversionId$modelInvariantid String[] s = vfmoduleEntry.getKey().split("\\" + DELIMITER); - String modelVersionId = s[0]; + String vfModuleId = s[0]; String modelInvariantId = s[1]; + String vfModuleName = s[2]; + String modelVersionId = s[3]; + String modelCustomizationId = s[4]; VFModule vfModule = new VFModule(); - vfModule.setUuid(modelVersionId); + vfModule.setUuid(vfModuleId); vfModule.setModelInvariantUUID(modelInvariantId); + vfModule.setName(vfModuleName); + vfModule.setModelVersionID(modelVersionId); + vfModule.setModelCustomizationUUID(modelCustomizationId); vfModule.setMaxInstances(getMaxInstance(vfmoduleEntry.getKey(), maxInstanceMap)); vfModule.setDataQuality(DataQuality.ok()); @@ -445,7 +519,7 @@ public class RestUtil { // Iterate through the ENUM Attribute list for (Attribute.Name name: Attribute.Name.values()) { - if (name.toString().equals(LOCKEDBOOLEAN)) { + if (name.toString().equals(ATTRIBUTE_LOCKEDBOOLEAN)) { Attribute att = new Attribute(); att.setDataQuality(DataQuality.ok()); att.setName(Attribute.Name.lockedBoolean); @@ -453,7 +527,7 @@ public class RestUtil { attributeList.add(att); } - if (name.toString().equals(HOSTNAME)) { + if (name.toString().equals(ATTRIBUTE_HOSTNAME)) { Attribute att = new Attribute(); att.setDataQuality(DataQuality.ok()); att.setName(Attribute.Name.hostName); @@ -461,7 +535,7 @@ public class RestUtil { attributeList.add(att); } - if (name.toString().equals(IMAGEID)) { + if (name.toString().equals(ATTRIBUTE_IMAGEID)) { Attribute att = new Attribute(); att.setDataQuality(DataQuality.ok()); att.setName(Attribute.Name.imageId); @@ -474,11 +548,18 @@ public class RestUtil { vm.setName(vserver.getVserverName()); vm.setAttributes(attributeList); vmList.add(vm); + + //Update pserver here + List pserverInstanceList = vserver.getPserverInstanceList(); + Pserver pServer = null; + if (pserverInstanceList != null) { + pServer = getPserverInfo (pserverInstanceList); + } + vm.setPServer(pServer); } vfModule.setVms(vmList); vfModuleLst.add(vfModule); } - } } } // done the vfmodule @@ -486,24 +567,247 @@ public class RestUtil { vf.setVfModules(vfModuleLst); vfLst.add(vf); - } // done the vnfInstance context.setService(service); context.setVnfs(vfLst); //Add PNF info context.setPnfs(transformPNF(pnfLst_fromAAi)); + //Add Pserver info log.info("ModelContext body: {}", JsonUtils.toPrettyJsonString(context)); return context; } + private static Pserver getPserverInfo (List pserverInstanceList) { + if (pserverInstanceList == null) { + return null; + } + + Pserver pserver = null; + + for (PserverInstance pserverInstance: pserverInstanceList) { + pserver = new Pserver(); + pserver.setUuid(pserverInstance.getPserverId()); + pserver.setName(pserverInstance.getHostname()); + + List attributeList = new ArrayList(); + // Iterate through the ENUM Attribute list + for (Attribute.Name name: Attribute.Name.values()) { + if ((name.toString().equals(ATTRIBUTE_NAME2 )) + && (pserverInstance.getPserverName2() != null)){ + Attribute att = new Attribute(); + att.setDataQuality(DataQuality.ok()); + att.setName(Attribute.Name.name2); + att.setValue(String.valueOf(pserverInstance.getPserverName2())); + attributeList.add(att); + } + if ((name.toString().equals(ATTRIBUTE_PTNII_NAME )) + && (pserverInstance.getPtniiEquipName() != null)){ + Attribute att = new Attribute(); + att.setDataQuality(DataQuality.ok()); + att.setName(Attribute.Name.ptniiName); + att.setValue(String.valueOf(pserverInstance.getPtniiEquipName())); + attributeList.add(att); + } + if ((name.toString().equals( ATTRIBUTE_EQUIPMENT_TYPE )) + &&(pserverInstance.getEquipType() != null)){ + Attribute att = new Attribute(); + att.setDataQuality(DataQuality.ok()); + att.setName(Attribute.Name.equipType); + att.setValue(String.valueOf(pserverInstance.getEquipType())); + attributeList.add(att); + } + if ((name.toString().equals( ATTRIBUTE_EQUIPMENT_VENDOR )) + &&(pserverInstance.getEquipVendor() != null)){ + Attribute att = new Attribute(); + att.setDataQuality(DataQuality.ok()); + att.setName(Attribute.Name.equipVendor); + att.setValue(String.valueOf(pserverInstance.getEquipVendor())); + attributeList.add(att); + } + if ((name.toString().equals( ATTRIBUTE_EQUIPMENT_MODEL )) + &&(pserverInstance.getEquipVendor() != null)){ + Attribute att = new Attribute(); + att.setDataQuality(DataQuality.ok()); + att.setName(Attribute.Name.equipModel); + att.setValue(String.valueOf(pserverInstance.getEquipVendor())); + attributeList.add(att); + } + if ((name.toString().equals( ATTRIBUTE_FQDN )) + &&(pserverInstance.getFqdn() != null)){ + Attribute att = new Attribute(); + att.setDataQuality(DataQuality.ok()); + att.setName(Attribute.Name.fqdn); + att.setValue(String.valueOf(pserverInstance.getFqdn())); + attributeList.add(att); + } + if ((name.toString().equals( ATTRIBUTE_SERIAL_NUMBER )) + &&(pserverInstance.getSerialNumber() != null)){ + Attribute att = new Attribute(); + att.setDataQuality(DataQuality.ok()); + att.setName(Attribute.Name.serialNumber); + att.setValue(String.valueOf(pserverInstance.getSerialNumber())); + attributeList.add(att); + } + if ((name.toString().equals( ATTRIBUTE_TOPOLOGY )) + &&(pserverInstance.getInternetTopology() != null)){ + Attribute att = new Attribute(); + att.setDataQuality(DataQuality.ok()); + att.setName(Attribute.Name.topology); + att.setValue(String.valueOf(pserverInstance.getInternetTopology())); + attributeList.add(att); + } + if ((name.toString().equals(ATTRIBUTE_LOCKEDBOOLEAN)) + &&(pserverInstance.getInMaint() != null)){ + Attribute att = new Attribute(); + att.setDataQuality(DataQuality.ok()); + att.setName(Attribute.Name.lockedBoolean); + att.setValue(String.valueOf(pserverInstance.getInMaint())); + attributeList.add(att); + } + if ((name.toString().equals(ATTRIBUTE_RESOURCE_VERSION)) + &&(pserverInstance.getResourceVersion() != null)){ + Attribute att = new Attribute(); + att.setDataQuality(DataQuality.ok()); + att.setName(Attribute.Name.resourceVersion); + att.setValue(String.valueOf(pserverInstance.getResourceVersion())); + attributeList.add(att); + } + if ((name.toString().equals(ATTRIBUTE_PURPOSE)) + &&(pserverInstance.getPurpose() != null)){ + Attribute att = new Attribute(); + att.setDataQuality(DataQuality.ok()); + att.setName(Attribute.Name.purpose); + att.setValue(String.valueOf(pserverInstance.getPurpose())); + attributeList.add(att); + } + } + + if (attributeList.size() > 0) { + pserver.setAttributes(attributeList); + } + + // Update P-Interface if any, + PInterfaceInstanceList pInterfaceInstanceList = pserverInstance.getPInterfaceInstanceList(); + if ((pInterfaceInstanceList != null) && (pInterfaceInstanceList.getPInterfaceList().size() > 0)) { + pserver = UpdatePserverInfoWithPInterface (pserver, pInterfaceInstanceList.getPInterfaceList()); + } + + // NOTE: we only support one pserver per vserver hence we only add + // the first pserver if there are multiple pservers are provided for the given vserver. + return pserver; + } + + return pserver; + } + + private static Pserver UpdatePserverInfoWithPInterface (Pserver pserver, List pInterfaceInstanceList) { + + List pInterfaceList = new ArrayList(); + for (PInterfaceInstance pInterfaceInst_aai: pInterfaceInstanceList) { + PInterface pInterface = new PInterface(); + pInterface.setUuid(pInterfaceInst_aai.getEquipmentIdentifier() ); + pInterface.setName(pInterfaceInst_aai.getInterfaceName()); + pInterface.setDataQuality(DataQuality.ok()); + + List pInterface_attributeList = new ArrayList(); + pInterface.setAttributes(pInterface_attributeList); + + // Iterate through the ENUM Attribute list + for (Attribute.Name name: Attribute.Name.values()) { + if ((name.toString().equals(ATTRIBUTE_SPEED_VALUE )) + &&(pInterfaceInst_aai.getSpeedValue() != null)){ + Attribute att = new Attribute(); + att.setDataQuality(DataQuality.ok()); + att.setName(Attribute.Name.speedValue); + att.setValue(String.valueOf( pInterfaceInst_aai.getSpeedValue())); + pInterface_attributeList.add(att); + } + + if ((name.toString().equals(ATTRIBUTE_SPEED_UNITS )) + &&(pInterfaceInst_aai.getSpeedUnits() != null)){ + Attribute att = new Attribute(); + att.setDataQuality(DataQuality.ok()); + att.setName(Attribute.Name.speedUnits); + att.setValue(String.valueOf( pInterfaceInst_aai.getSpeedUnits())); + pInterface_attributeList.add(att); + } + + if ((name.toString().equals(ATTRIBUTE_PORT_DESCRIPTION )) + &&(pInterfaceInst_aai.getPortDescription() != null)){ + Attribute att = new Attribute(); + att.setDataQuality(DataQuality.ok()); + att.setName(Attribute.Name.description); + att.setValue(String.valueOf( pInterfaceInst_aai.getPortDescription())); + pInterface_attributeList.add(att); + } + + if ((name.toString().equals(ATTRIBUTE_EQUIPTMENT_ID )) + &&(pInterfaceInst_aai.getEquipmentIdentifier() != null)){ + Attribute att = new Attribute(); + att.setDataQuality(DataQuality.ok()); + att.setName(Attribute.Name.equipmentID); + att.setValue(String.valueOf( pInterfaceInst_aai.getEquipmentIdentifier())); + pInterface_attributeList.add(att); + } + + if ((name.toString().equals(ATTRIBUTE_INTERFACE_ROLE )) + &&(pInterfaceInst_aai.getInterfaceRole() != null)){ + Attribute att = new Attribute(); + att.setDataQuality(DataQuality.ok()); + att.setName(Attribute.Name.interfaceRole); + att.setValue(String.valueOf( pInterfaceInst_aai.getInterfaceRole())); + pInterface_attributeList.add(att); + } + + if ((name.toString().equals(ATTRIBUTE_INTERFACE_TYPE )) + &&(pInterfaceInst_aai.getInterfaceType() != null)){ + Attribute att = new Attribute(); + att.setDataQuality(DataQuality.ok()); + att.setName(Attribute.Name.interfaceType); + att.setValue(String.valueOf( pInterfaceInst_aai.getInterfaceType())); + pInterface_attributeList.add(att); + } + + if ((name.toString().equals( ATTRIBUTE_RESOURCE_VERSION )) + &&(pInterfaceInst_aai.getResourceVersion() != null)){ + Attribute att = new Attribute(); + att.setDataQuality(DataQuality.ok()); + att.setName(Attribute.Name.resourceVersion); + att.setValue(String.valueOf( pInterfaceInst_aai.getResourceVersion())); + pInterface_attributeList.add(att); + } + + if ((name.toString().equals( ATTRIBUTE_LOCKEDBOOLEAN )) + &&(pInterfaceInst_aai.getInMaint() != null)){ + Attribute att = new Attribute(); + att.setDataQuality(DataQuality.ok()); + att.setName(Attribute.Name.lockedBoolean); + att.setValue(String.valueOf( pInterfaceInst_aai.getInMaint())); + pInterface_attributeList.add(att); + } + } + + if (pInterface_attributeList.size() > 0) { + pInterface.setAttributes(pInterface_attributeList); + } + pInterfaceList.add(pInterface); + } + + if (pInterfaceList.size() > 0) { + pserver.setPInterfaceList(pInterfaceList);; + } + + return pserver; + } + /* * Transform AAI Representation to Common Model */ public static List transformPNF(List pnfLst_from_AAI) { - if (pnfLst_from_AAI.isEmpty()) { + if ((pnfLst_from_AAI == null ) || (pnfLst_from_AAI.isEmpty())) { log.info(LogMessages.API_CALL_LIST, "Nill PNF list"); return null; } @@ -521,7 +825,7 @@ public class RestUtil { // Iterate through the ENUM Attribute list for (Attribute.Name name: Attribute.Name.values()) { - if ((name.toString().equals(PNF_NETWORK_FUNCTION )) + if ((name.toString().equals(ATTRIBUTE_NETWORK_FUNCTION )) &&(pnf_from_aai.getNfFunction() != null)){ Attribute att = new Attribute(); att.setDataQuality(DataQuality.ok()); @@ -530,7 +834,7 @@ public class RestUtil { attributeList.add(att); } - if ((name.toString().equals(PNF_NETWORK_ROLE )) + if ((name.toString().equals(ATTRIBUTE_NETWORK_ROLE )) && (pnf_from_aai.getNfRole() != null )){ Attribute att = new Attribute(); att.setDataQuality(DataQuality.ok()); @@ -539,7 +843,7 @@ public class RestUtil { attributeList.add(att); } - if ((name.toString().equals(PNF_RESOURCE_VERSION)) + if ((name.toString().equals(ATTRIBUTE_RESOURCE_VERSION)) && (pnf_from_aai.getResourceVersion() != null)){ Attribute att = new Attribute(); att.setDataQuality(DataQuality.ok()); @@ -548,7 +852,7 @@ public class RestUtil { attributeList.add(att); } - if ((name.toString().equals(PNF_NAME2)) + if ((name.toString().equals(ATTRIBUTE_NAME2)) && (pnf_from_aai.getPnfName2() != null )){ Attribute att = new Attribute(); att.setDataQuality(DataQuality.ok()); @@ -557,7 +861,7 @@ public class RestUtil { attributeList.add(att); } - if ((name.toString().equals(PNF_NAME2_SOURCE )) + if ((name.toString().equals(ATTRIBUTE_NAME2_SOURCE )) && (pnf_from_aai.getPnfName2Source() != null)){ Attribute att = new Attribute(); att.setDataQuality(DataQuality.ok()); @@ -566,7 +870,7 @@ public class RestUtil { attributeList.add(att); } - if ((name.toString().equals(PNF_EQUIPMENT_TYPE )) + if ((name.toString().equals(ATTRIBUTE_EQUIPMENT_TYPE )) && (pnf_from_aai.getEquipmentType() != null)){ Attribute att = new Attribute(); att.setDataQuality(DataQuality.ok()); @@ -575,7 +879,7 @@ public class RestUtil { attributeList.add(att); } - if ((name.toString().equals(PNF_EQUIPMENT_VENDOR )) + if ((name.toString().equals(ATTRIBUTE_EQUIPMENT_VENDOR )) && (pnf_from_aai.getEquipmentVendor() != null)){ Attribute att = new Attribute(); att.setDataQuality(DataQuality.ok()); @@ -584,7 +888,7 @@ public class RestUtil { attributeList.add(att); } - if ((name.toString().equals(PNF_EQUIPMENT_MODEL)) + if ((name.toString().equals(ATTRIBUTE_EQUIPMENT_MODEL)) && (pnf_from_aai.getEquipmentModel() != null)){ Attribute att = new Attribute(); att.setDataQuality(DataQuality.ok()); @@ -593,7 +897,7 @@ public class RestUtil { attributeList.add(att); } - if ((name.toString().equals(PNF_MANAGEMENT_OPTIONS)) + if ((name.toString().equals(ATTRIBUTE_MANAGEMENT_OPTIONS)) &&(pnf_from_aai.getManagementOptions() != null)){ Attribute att = new Attribute(); att.setDataQuality(DataQuality.ok()); @@ -602,7 +906,7 @@ public class RestUtil { attributeList.add(att); } - if ((name.toString().equals(PNF_SW_VERSION)) + if ((name.toString().equals(ATTRIBUTE_SW_VERSION)) &&(pnf_from_aai.getSwVersion()!= null)){ Attribute att = new Attribute(); att.setDataQuality(DataQuality.ok()); @@ -611,7 +915,7 @@ public class RestUtil { attributeList.add(att); } - if ((name.toString().equals(PNF_FRAME_ID)) + if ((name.toString().equals(ATTRIBUTE_FRAME_ID)) &&(pnf_from_aai.getFrameId() != null)){ Attribute att = new Attribute(); att.setDataQuality(DataQuality.ok()); @@ -620,7 +924,7 @@ public class RestUtil { attributeList.add(att); } - if ((name.toString().equals(PNF_SERIAL_NUMBER)) + if ((name.toString().equals(ATTRIBUTE_SERIAL_NUMBER)) &&(pnf_from_aai.getSerialNumber() != null)){ Attribute att = new Attribute(); att.setDataQuality(DataQuality.ok()); @@ -632,11 +936,108 @@ public class RestUtil { } pnf.setAttributes(attributeList); + + // Update P-Interface + if ((pnf_from_aai.getPInterfaceInstanceList() != null) + &&(pnf_from_aai.getPInterfaceInstanceList().getPInterfaceList().size()> 0)) { + + List pInterfaceList = new ArrayList(); + List pInterfaceInstList_aai = pnf_from_aai.getPInterfaceInstanceList().getPInterfaceList(); + for (PInterfaceInstance pInterfaceInst_aai : pInterfaceInstList_aai) { + PInterface pInterface = new PInterface(); + pInterface.setUuid(pInterfaceInst_aai.getEquipmentIdentifier() ); + pInterface.setName(pInterfaceInst_aai.getInterfaceName()); + pInterface.setDataQuality(DataQuality.ok()); + + List pInterface_attributeList = new ArrayList(); + pInterface.setAttributes(pInterface_attributeList); + + // Iterate through the ENUM Attribute list + for (Attribute.Name name: Attribute.Name.values()) { + if ((name.toString().equals(ATTRIBUTE_SPEED_VALUE )) + &&(pInterfaceInst_aai.getSpeedValue() != null)){ + Attribute att = new Attribute(); + att.setDataQuality(DataQuality.ok()); + att.setName(Attribute.Name.speedValue); + att.setValue(String.valueOf( pInterfaceInst_aai.getSpeedValue())); + pInterface_attributeList.add(att); + } + + if ((name.toString().equals(ATTRIBUTE_SPEED_UNITS )) + &&(pInterfaceInst_aai.getSpeedUnits() != null)){ + Attribute att = new Attribute(); + att.setDataQuality(DataQuality.ok()); + att.setName(Attribute.Name.speedUnits); + att.setValue(String.valueOf( pInterfaceInst_aai.getSpeedUnits())); + pInterface_attributeList.add(att); + } + + if ((name.toString().equals(ATTRIBUTE_PORT_DESCRIPTION )) + &&(pInterfaceInst_aai.getPortDescription() != null)){ + Attribute att = new Attribute(); + att.setDataQuality(DataQuality.ok()); + att.setName(Attribute.Name.description); + att.setValue(String.valueOf( pInterfaceInst_aai.getPortDescription())); + pInterface_attributeList.add(att); + } + + if ((name.toString().equals(ATTRIBUTE_EQUIPTMENT_ID )) + &&(pInterfaceInst_aai.getEquipmentIdentifier() != null)){ + Attribute att = new Attribute(); + att.setDataQuality(DataQuality.ok()); + att.setName(Attribute.Name.equipmentID); + att.setValue(String.valueOf( pInterfaceInst_aai.getEquipmentIdentifier())); + pInterface_attributeList.add(att); + } + + if ((name.toString().equals(ATTRIBUTE_INTERFACE_ROLE )) + &&(pInterfaceInst_aai.getInterfaceRole() != null)){ + Attribute att = new Attribute(); + att.setDataQuality(DataQuality.ok()); + att.setName(Attribute.Name.interfaceRole); + att.setValue(String.valueOf( pInterfaceInst_aai.getInterfaceRole())); + pInterface_attributeList.add(att); + } + + if ((name.toString().equals(ATTRIBUTE_INTERFACE_TYPE )) + &&(pInterfaceInst_aai.getInterfaceType() != null)){ + Attribute att = new Attribute(); + att.setDataQuality(DataQuality.ok()); + att.setName(Attribute.Name.interfaceType); + att.setValue(String.valueOf( pInterfaceInst_aai.getInterfaceType())); + pInterface_attributeList.add(att); + } + + if ((name.toString().equals( ATTRIBUTE_RESOURCE_VERSION )) + &&(pInterfaceInst_aai.getResourceVersion() != null)){ + Attribute att = new Attribute(); + att.setDataQuality(DataQuality.ok()); + att.setName(Attribute.Name.resourceVersion); + att.setValue(String.valueOf( pInterfaceInst_aai.getResourceVersion())); + pInterface_attributeList.add(att); + } + + if ((name.toString().equals( ATTRIBUTE_LOCKEDBOOLEAN )) + &&(pInterfaceInst_aai.getInMaint() != null)){ + Attribute att = new Attribute(); + att.setDataQuality(DataQuality.ok()); + att.setName(Attribute.Name.lockedBoolean); + att.setValue(String.valueOf( pInterfaceInst_aai.getInMaint())); + pInterface_attributeList.add(att); + } + } + pInterfaceList.add(pInterface); + } + + if (pInterfaceList.size() > 0) { + pnf.setPInterfaceList(pInterfaceList); + } + } + pnfLst.add(pnf); } // done the vnfInstance - return pnfLst; } @@ -690,9 +1091,13 @@ public class RestUtil { ConcurrentMap map = new ConcurrentHashMap<>(); for (VfModule vfModule : vfModuleList) { - // group the key by model_version_id and model_invariant_id - String key = new StringBuilder().append(vfModule.getModelVersionId()).append(DELIMITER) - .append(vfModule.getModelInvariantId()).toString(); + // group the key by vf-module-id, model-invariant-id,vf-module-name, model-version-id and model-customization-id + String key = new StringBuilder().append(vfModule.getVfModuleId()).append(DELIMITER) + .append(vfModule.getModelInvariantId()).append(DELIMITER) + .append(vfModule.getVfMduleName()).append(DELIMITER) + .append(vfModule.getModelVersionId()).append(DELIMITER) + .append(vfModule.getModelCustomizationId() + ).toString(); if (key.length() > 0) { map.putIfAbsent(key, new AtomicInteger(0)); @@ -817,26 +1222,68 @@ public class RestUtil { } if (vfmoduleArray != null && vfmoduleArray.length() > 0) { - vServerRelatedLinkMap = handleRelationship(vfmoduleArray, catalog); + vServerRelatedLinkMap = handleRelationship_vserver(vfmoduleArray, jsonPayload, catalog); } return vServerRelatedLinkMap; } + private static List handleRelationship_general(String payload_str, String catalog) { + + if (payload_str == null) { + return null; + } + JSONObject jsonPayload = new JSONObject(payload_str); + + JSONArray relationships = null; + List relatedLinkList = null; + + try { + JSONObject relationshipList = jsonPayload.getJSONObject(RELATIONSHIP_LIST); + if (relationshipList != null) { + relatedLinkList = new ArrayList(); + relationships = relationshipList.getJSONArray(RELATIONSHIP); + } + } catch (JSONException e) { + log.error(e.getMessage()); + } + + if (relationships != null && relationships.length() > 0) { + for (int j = 0; j < relationships.length(); j++) { + Object relatedToObj = null; + Object relatedLinkObj = null; + + JSONObject obj2 = relationships.optJSONObject(j); + relatedToObj = obj2.get(JSON_ATT_RELATED_TO); + + if (relatedToObj.toString().equals(catalog)) { + relatedLinkObj = obj2.get(JSON_ATT_RELATED_LINK); + if (relatedLinkObj != null) { + relatedLinkList.add(relatedLinkObj.toString()); + } + } + } //relationship + } + return relatedLinkList; + } - private static Map> handleRelationship(JSONArray vfmoduleArray, String catalog) { + private static Map> handleRelationship_vserver(JSONArray vfmoduleArray, JSONObject vnf_jsonPayload, String catalog) { Map> vServerRelatedLinkMap = new HashMap>(); JSONArray relationships = null; // If there are multiple vf-module, but one of vf-module missing relationship, we should log the exception and keep loop for (int i = 0; i < vfmoduleArray.length(); i++) { List relatedLinkList = new ArrayList(); JSONObject obj = vfmoduleArray.optJSONObject(i); - String key = (String)obj.get("model-version-id") + DELIMITER + (String)obj.get("model-invariant-id"); + String key = (String)obj.get("vf-module-id") + DELIMITER + + (String)obj.get("model-invariant-id")+ DELIMITER + + (String)obj.get("vf-module-name")+ DELIMITER + + (String)obj.get("model-version-id")+ DELIMITER + + (String)obj.get("model-customization-id"); log.debug("Fetching the relationship"); try { - JSONObject relationshipList = obj.getJSONObject(RELATIONSHIP_LIST); + JSONObject relationshipList = vnf_jsonPayload.getJSONObject(RELATIONSHIP_LIST); if (relationshipList != null) { relationships = relationshipList.getJSONArray(RELATIONSHIP); } diff --git a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RestUtilTest.java b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RestUtilTest.java index 3753ea6..f808ebe 100644 --- a/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RestUtilTest.java +++ b/src/test/java/org/onap/logging_analytics/pomba/pomba_aai_context_builder/RestUtilTest.java @@ -25,6 +25,7 @@ import static org.junit.Assert.assertTrue; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; +import java.util.List; import java.util.UUID; import org.junit.Rule; import org.junit.Test; @@ -43,6 +44,9 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.context.web.WebAppConfiguration; import com.github.tomakehurst.wiremock.junit.WireMockRule; import org.onap.pomba.common.datatypes.ModelContext; +import org.onap.pomba.common.datatypes.VNF; +import org.onap.pomba.common.datatypes.VFModule; +import org.onap.pomba.common.datatypes.VM; @RunWith(SpringJUnit4ClassRunner.class) @EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class, HibernateJpaAutoConfiguration.class }) @@ -59,6 +63,8 @@ public class RestUtilTest { @Autowired private String aaiBasicAuthorization; + private static final String DEPTH = "?depth=2"; + @Rule public WireMockRule aaiEnricherRule = new WireMockRule(wireMockConfig().port(9808)); @@ -132,7 +138,7 @@ public class RestUtilTest { //// @Test - public void testretrieveAAIModelDataFromAAI() throws Exception { + public void testretrieveAAIModelDataFromAAI_PNF() throws Exception { String transactionId = UUID.randomUUID().toString(); String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json @@ -140,16 +146,16 @@ public class RestUtilTest { // 1. simulate the response to obtainResourceLink based on ServiceInstanceId addResponse(queryNodeUrl, "junit/queryNodeData-1.json", aaiEnricherRule); // 2. simulate the response of AAI (1 vnf and 1 pnf) - addResponse( "/aai/v11/business/customers/customer/DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2/service-subscriptions/service-subscription/vFW/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb", + addResponse( "/aai/v13/business/customers/customer/DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2/service-subscriptions/service-subscription/vFW/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb", "junit/aai-service-instance.json", aaiEnricherRule); // 3. simulate the rsp of VNF - addResponse( "/aai/v13/network/generic-vnfs/generic-vnf/8a9ddb25-2e79-449c-a40d-5011bac0da39?depth=2", + addResponse( "/aai/v13/network/generic-vnfs/generic-vnf/8a9ddb25-2e79-449c-a40d-5011bac0da39" + DEPTH, "junit/genericVnfInput.json", aaiEnricherRule); // 4. simulate the response of PNF based on the resourceLink in (2) //note: match pnf_id in junit/aai-service-instance.json - addResponse( "/aai/v13/network/pnfs/pnf/amdocsPnfName", + addResponse( "/aai/v13/network/pnfs/pnf/amdocsPnfName" + DEPTH, "junit/pnfSampleInput.json", aaiEnricherRule); ModelContext modelCtx = RestUtil.retrieveAAIModelData(aaiClient, aaiBaseUrl, aaiPathToSearchNodeQuery, transactionId , serviceInstanceId, aaiBasicAuthorization); @@ -158,5 +164,122 @@ public class RestUtilTest { assertEquals(modelCtx.getPnfs().size(), 1); } + ///Verify the relationship serviceInstanceId -> vnf -> vserver + @Test + public void testretrieveAAIModelDataFromAAI_VSERVER_PSERVER() throws Exception { + + String transactionId = UUID.randomUUID().toString(); + String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json + String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceId; + // 1. simulate the response to obtainResourceLink based on ServiceInstanceId + addResponse(queryNodeUrl, "junit/queryNodeData-1.json", aaiEnricherRule); + // 2. simulate the response of AAI (1 vnf) + // note: match serviceInstanceId in (1) + addResponse( "/aai/v13/business/customers/customer/DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2/service-subscriptions/service-subscription/vFW/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb", + "junit/aai-service-instance_set2.json", aaiEnricherRule); + + // 3. simulate the rsp of VNF (with 1 vserver) + // note: match vnf_id in (2) + addResponse( "/aai/v13/network/generic-vnfs/generic-vnf/8a9ddb25-2e79-449c-a40d-5011bac0da39" + DEPTH, + "junit/genericVnfInput_set2.json", aaiEnricherRule); + + // 4. simulate the rsp of vserer + // note: match to vserver-id to the path of "vserver" in (3) + addResponse( + "/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant" + + "/b49b830686654191bb1e952a74b014ad/vservers/vserver/b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a", + "junit/aai-vserver.json", aaiEnricherRule); + + // 5. simulate the rsp of pserver + // note: match pserver hostname to the path of "pserver" in (4) + addResponse( + "/aai/v13/cloud-infrastructure/pservers/pserver/mtn96compute.cci.att.com" + DEPTH, + "junit/pserverInput_set2.json", aaiEnricherRule); + + ModelContext modelCtx = RestUtil.retrieveAAIModelData(aaiClient, aaiBaseUrl, aaiPathToSearchNodeQuery, transactionId , serviceInstanceId, aaiBasicAuthorization); + + // verify results + List vnfList = modelCtx.getVnfs(); + assertEquals(vnfList.size(), 1); + List vfModuleList = vnfList.get(0).getVfModules(); + assertEquals(vfModuleList.size(), 1); + List vmList = vfModuleList.get(0).getVms(); + assertEquals(vmList.size(), 1); + assertEquals(vmList.get(0).getUuid(), "b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a"); //vserver-id + assertEquals(vmList.get(0).getPServer().getName(), "mtn96compute.cci.att.com"); //pserver-name + } + + //// + @Test + public void testretrieveAAIModelDataFromAAI_PInterface_with_PNF() throws Exception { + + String transactionId = UUID.randomUUID().toString(); + String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json + String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceId; + // 1. simulate the response to obtainResourceLink based on ServiceInstanceId + addResponse(queryNodeUrl, "junit/queryNodeData-1.json", aaiEnricherRule); + // 2. simulate the response of AAI (1 vnf and 1 pnf) + addResponse( "/aai/v13/business/customers/customer/DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2/service-subscriptions/service-subscription/vFW/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb", + "junit/aai-service-instance.json", aaiEnricherRule); + + // 3. simulate the rsp of VNF + addResponse( "/aai/v13/network/generic-vnfs/generic-vnf/8a9ddb25-2e79-449c-a40d-5011bac0da39" + DEPTH, + "junit/genericVnfInput.json", aaiEnricherRule); + + // 4. simulate the response of PNF based on the resourceLink in (2) + //note: match pnf_id in junit/aai-service-instance.json + addResponse( "/aai/v13/network/pnfs/pnf/amdocsPnfName" + DEPTH, + "junit/pnfInput_w_pInterface.json", aaiEnricherRule); + + ModelContext modelCtx = RestUtil.retrieveAAIModelData(aaiClient, aaiBaseUrl, aaiPathToSearchNodeQuery, transactionId , serviceInstanceId, aaiBasicAuthorization); + + assertEquals(modelCtx.getVnfs().size(), 1); + assertEquals(modelCtx.getPnfs().size(), 1); + + } + + @Test + public void testretrieveAAIModelDataFromAAI_P_Interface_with_PSERVER() throws Exception { + + String transactionId = UUID.randomUUID().toString(); + String serviceInstanceId = "adc3cc2a-c73e-414f-8ddb-367de81300cb"; //match to the test data in junit/queryNodeData-1.json + String queryNodeUrl = aaiPathToSearchNodeQuery + serviceInstanceId; + // 1. simulate the response to obtainResourceLink based on ServiceInstanceId + addResponse(queryNodeUrl, "junit/queryNodeData-1.json", aaiEnricherRule); + // 2. simulate the response of AAI (1 vnf) + // note: match serviceInstanceId in (1) + addResponse( "/aai/v13/business/customers/customer/DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2/service-subscriptions/service-subscription/vFW/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb", + "junit/aai-service-instance_set2.json", aaiEnricherRule); + + // 3. simulate the rsp of VNF (with 1 vserver) + // note: match vnf_id in (2) + addResponse( "/aai/v13/network/generic-vnfs/generic-vnf/8a9ddb25-2e79-449c-a40d-5011bac0da39" + DEPTH, + "junit/genericVnfInput_set2.json", aaiEnricherRule); + + // 4. simulate the rsp of vserer + // note: match to vserver-id to the path of "vserver" in (3) + addResponse( + "/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant" + + "/b49b830686654191bb1e952a74b014ad/vservers/vserver/b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a", + "junit/aai-vserver.json", aaiEnricherRule); + + // 5. simulate the rsp of pserver + // note: match pserver hostname to the path of "pserver" in (4) + addResponse( + "/aai/v13/cloud-infrastructure/pservers/pserver/mtn96compute.cci.att.com" + DEPTH, + "junit/pserverInput_with_pInterface.json", aaiEnricherRule); + + ModelContext modelCtx = RestUtil.retrieveAAIModelData(aaiClient, aaiBaseUrl, aaiPathToSearchNodeQuery, transactionId , serviceInstanceId, aaiBasicAuthorization); + + // verify results + List vnfList = modelCtx.getVnfs(); + assertEquals(vnfList.size(), 1); + List vfModuleList = vnfList.get(0).getVfModules(); + assertEquals(vfModuleList.size(), 1); + List vmList = vfModuleList.get(0).getVms(); + assertEquals(vmList.size(), 1); + assertEquals(vmList.get(0).getPServer().getPInterfaceList().size(), 1); + assertEquals(vmList.get(0).getPServer().getPInterfaceList().get(0).getName(), "bdc3cc2a-c73e-414f-7ddb-367de92801cb"); //interface-name + } } diff --git a/src/test/resources/junit/aai-service-instance_set2.json b/src/test/resources/junit/aai-service-instance_set2.json new file mode 100644 index 0000000..8491eb7 --- /dev/null +++ b/src/test/resources/junit/aai-service-instance_set2.json @@ -0,0 +1,27 @@ +{ + "service-instance-id": "adc3cc2a-c73e-414f-8ddb-367de81300cb", + "service-instance-name": "Firewall1", + "model-invariant-id": "0c5a20de-87ad-442c-9190-f38ab0a6bb7f", + "model-version-id": "d3d6cf83-d03a-43cc-99ff-206d40bb9a72", + "resource-version": "1527637758480", + "relationship-list": { + "relationship": [ + { + "related-to": "generic-vnf", + "related-link": "/aai/v13/network/generic-vnfs/generic-vnf/8a9ddb25-2e79-449c-a40d-5011bac0da39", + "relationship-data": [ + { + "relationship-key": "generic-vnf.vnf-id", + "relationship-value": "8a9ddb25-2e79-449c-a40d-5011bac0da39" + } + ], + "related-to-property": [ + { + "property-key": "generic-vnf.vnf-name", + "property-value": "Firewall-1" + } + ] + } + ] + } +} diff --git a/src/test/resources/junit/aai-vserver.json b/src/test/resources/junit/aai-vserver.json new file mode 100644 index 0000000..66f7639 --- /dev/null +++ b/src/test/resources/junit/aai-vserver.json @@ -0,0 +1,94 @@ +{ + "vserver-id": "b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a", + "vserver-name": "Firewall-0", + "vserver-name2": "Firewall-0", + "prov-status": "ACTIVE", + "vserver-selflink": "http://10.12.25.2:8774/v2.1/b49b830686654191bb1e952a74b014ad/servers/b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1528481820321", + "relationship-list": { + "relationship": [ + { + "related-to": "pserver", + "relationship-label": "tosca.relationships.HostedOn", + "related-link": "/aai/v13/cloud-infrastructure/pservers/pserver/mtn96compute.cci.att.com", + "relationship-data": [ + { + "relationship-key": "pserver.hostname", + "relationship-value": "mtn96compute.cci.att.com" + } + ], + "related-to-property": [ + { "property-key": "pserver.fqdn", + "property-value": "mtn96compute.cci.att.com" + } + ] + }, + { + "related-to": "generic-vnf", + "related-link": "/aai/v11/network/generic-vnfs/generic-vnf/8a9ddb25-2e79-449c-a40d-5011bac0da39", + "relationship-data": [ + { + "relationship-key": "generic-vnf.vnf-id", + "relationship-value": "8a9ddb25-2e79-449c-a40d-5011bac0da39" + } + ], + "related-to-property": [ + { + "property-key": "generic-vnf.vnf-name", + "property-value": "Firewall-1" + } + ] + }, + { + "related-to": "flavor", + "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/flavors/flavor/764efb04-5a46-4806-a766-2bdd24559f39", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "CloudOwner" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "RegionOne" + }, + { + "relationship-key": "flavor.flavor-id", + "relationship-value": "764efb04-5a46-4806-a766-2bdd24559f39" + } + ], + "related-to-property": [ + { + "property-key": "flavor.flavor-name", + "property-value": "m1.medium" + } + ] + }, + { + "related-to": "image", + "related-link": "/aai/v11/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/images/image/42fd42f8-cf81-4f4c-a552-d4b124f83b0b", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "CloudOwner" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "RegionOne" + }, + { + "relationship-key": "image.image-id", + "relationship-value": "42fd42f8-cf81-4f4c-a552-d4b124f83b0b" + } + ], + "related-to-property": [ + { + "property-key": "image.image-name", + "property-value": "unknown" + } + ] + } + ] + } +} diff --git a/src/test/resources/junit/genericVnfInput_set2.json b/src/test/resources/junit/genericVnfInput_set2.json new file mode 100644 index 0000000..dfdc0cc --- /dev/null +++ b/src/test/resources/junit/genericVnfInput_set2.json @@ -0,0 +1,118 @@ +{ + "vnf-id": "8a9ddb25-2e79-449c-a40d-5011bac0da39", + "vnf-name": "Firewall-1", + "vnf-type": "vFW-vSINK-service/vFWvSINK 0", + "service-id": "8ea56b0d-459d-4668-b363-c9567432d8b7", + "prov-status": "PREPROV", + "orchestration-status": "Created", + "in-maint": false, + "is-closed-loop-disabled": false, + "resource-version": "1527637940029", + "model-invariant-id": "59dd4d63-8f21-406c-98c0-3b057bb86820", + "model-version-id": "e2d52f32-a952-46f5-800c-c250903625d6", + "model-customization-id": "3b822416-475d-4e1c-aac3-2544b0a0fdfc", + "nf-type": "", + "nf-function": "", + "nf-role": "", + "nf-naming-code": "", + "relationship-list": { + "relationship": [ + { + "related-to": "vserver", + "related-link": "/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/b49b830686654191bb1e952a74b014ad/vservers/vserver/b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "CloudOwner" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "RegionOne" + }, + { + "relationship-key": "tenant.tenant-id", + "relationship-value": "b49b830686654191bb1e952a74b014ad" + }, + { + "relationship-key": "vserver.vserver-id", + "relationship-value": "b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a" + } + ] + }, + { + "related-to": "service-instance", + "related-link": "/aai/v11/business/customers/customer/Demonstration/service-subscriptions/service-subscription/vFWCL/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb", + "relationship-data": [ + { + "relationship-key": "customer.global-customer-id", + "relationship-value": "Demonstration" + }, + { + "relationship-key": "service-subscription.service-type", + "relationship-value": "vFWCL" + }, + { + "relationship-key": "service-instance.service-instance-id", + "relationship-value": "adc3cc2a-c73e-414f-8ddb-367de81300cb" + } + ], + "related-to-property": [ + { + "property-key": "service-instance.service-instance-name", + "property-value": "Firewall1" + } + ] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v13/network/l3-networks/l3-network/HNP1d77c-1094-41ec-b7f3-94bb30951870", + "relationship-data": [ + { + "relationship-key": "l3-network.network-id", + "relationship-value": "HNP1d77c-1094-41ec-b7f3-94bb30951870" + } + ], + "related-to-property": [ + { + "property-key": "l3-network.network-name", + "property-value": "HNPORTALOAM.OAM" + } + ] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v13/network/l3-networks/l3-network/HNP1d77c-1094-41ec-b7f3-94bb30951872", + "relationship-data": [ + { + "relationship-key": "l3-network.network-id", + "relationship-value": "HNP1d77c-1094-41ec-b7f3-94bb30951872" + } + ], + "related-to-property": [ + { + "property-key": "l3-network.network-name", + "property-value": "HNPORTAL_SRIOV_2" + } + ] + } + ] + }, + "vf-modules": { + "vf-module": [ + { + "vf-module-id": "1563b649-9e05-4288-b7d9-e3639a54ace6", + "vf-module-name": "vFW_SINC_Module-2", + "heat-stack-id": "vFW_SINC_Module-2/41c4533a-748d-4cf4-a8d3-eccdd0aeb0d4", + "orchestration-status": "active", + "is-base-vf-module": true, + "resource-version": "1527638439198", + "model-invariant-id": "74bc1518-282d-4148-860f-8892b6369456", + "model-version-id": "4e3d28cf-d654-41af-a47b-04b4bd0ac58e", + "model-customization-id": "cc51ab7d-9b03-4bd6-9104-09df0c7c7907", + "module-index": 0 + } + ] + } +} diff --git a/src/test/resources/junit/pnfInput_w_pInterface.json b/src/test/resources/junit/pnfInput_w_pInterface.json new file mode 100644 index 0000000..c534dfc --- /dev/null +++ b/src/test/resources/junit/pnfInput_w_pInterface.json @@ -0,0 +1,86 @@ +{ + "pnf-name": "amdocsPnfName", + "pnf-name2": "amdocsPnfName2", + "pnf-name2-source": "pombaName2Source", + "pnf-id": "11112222pnf88889999", + "equip-type": "software", + "equip-vendor": "8df84f0a-737a-4628-be9c-c3c78454f9d9", + "equip-model": "123134236", + "management-option": "TBD", + "sw-version": "2", + "in-maint": "true", + "frame-id": "99888", + "serial-number": "c44b872f6830498b88c4989d67b2a6b7", + "status": "ACTIVE", + "nf-function": "nf-Function-123", + "nf-role": "22222", + "model-invariant-id": "12345", + "model-version-id": "2123", + "admin_state_up": true, + "resource-version": "28", + "tenant_id": "c44b872f6830498b88c4989d67b2a6b7", + "created_at": "2018-03-20T16:49:01Z", + "provider:network_type": "vlan", + "p-interfaces":{ + "p-interface": [ + { + "interface-name": "bdc3cc2a-c73e-414f-7ddb-367de92801cb", + "speed-value": "1225", + "speed-units": "mbs", + "port-description": "port-used-for-junit", + "equipment-identifier": "8df84f0a-737a-4628-be9c-c3c78454f9d9", + "interface-role": "123134236", + "interface-type": "Software", + "prov-status": "2", + "in-maint": "true", + "resource-version": "99888", + "serial-number": "c44b872f6830498b88c4989d67b2a6b7", + "status": "ACTIVE", + "inv-status": "TBD" + } + ] + }, + "relationship-list": { + "relationship": [ + { + "related-to": "vserver", + "related-link": "/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/b49b830686654191bb1e952a74b014ad/vservers/vserver/b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "CloudOwner" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "RegionOne" + }, + { + "relationship-key": "tenant.tenant-id", + "relationship-value": "b49b830686654191bb1e952a74b014ad" + }, + { + "relationship-key": "vserver.vserver-id", + "relationship-value": "b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a" + } + ] + }, + { + "related-to": "l3-network", + "relationship-label": "org.onap.relationships.inventory.Uses", + "related-link": "/aai/v13/network/l3-networks/l3-network/HNP1d77c-1094-41ec-b7f3-94bb30951870", + "relationship-data": [ + { + "relationship-key": "l3-network.network-id", + "relationship-value": "HNP1d77c-1094-41ec-b7f3-94bb30951870" + } + ], + "related-to-property": [ + { + "property-key": "l3-network.network-name", + "property-value": "HNPORTALOAM.OAM" + } + ] + } + ] + } +} \ No newline at end of file diff --git a/src/test/resources/junit/pserverInput_set2.json b/src/test/resources/junit/pserverInput_set2.json new file mode 100644 index 0000000..e2b632a --- /dev/null +++ b/src/test/resources/junit/pserverInput_set2.json @@ -0,0 +1,46 @@ +{ + "hostname": "mtn96compute.cci.att.com", + "fqdn": "mtn96compute.cci.att.com", + "pserver-id": "auto-generated-skeleton", + "pserver-name2": "pserverName2-hello", + "ptnii-equip-name": "ptnii-equip-name-hello", + "equip-type": "Firewall", + "equip-vendor": "equip-vendor-hello", + "equip-model": "equip-model-hello", + "internet-topology": "internet-topology-hello", + "purpose": "purpose-something-for-fun", + "serial-number": "1223128888", + "in-maint": false, + "resource-version": "1544034123458", + "relationship-list": { + "relationship": [ + { + "related-to": "vserver", + "relationship-label": "tosca.relationships.HostedOn", + "related-link": "/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/b49b830686654191bb1e952a74b014ad/vservers/vserver/b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "CloudOwner" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "RegionOne" + }, + { + "relationship-key": "tenant.tenant-id", + "relationship-value": "b49b830686654191bb1e952a74b014ad" + }, + { + "relationship-key": "vserver.vserver-id", + "relationship-value": "b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a" + } + ], + "related-to-property": [ { + "property-key": "vserver.vserver-name", + "property-value": "Firewall-0" + }] + } + ] + } +} \ No newline at end of file diff --git a/src/test/resources/junit/pserverInput_with_pInterface.json b/src/test/resources/junit/pserverInput_with_pInterface.json new file mode 100644 index 0000000..e33026b --- /dev/null +++ b/src/test/resources/junit/pserverInput_with_pInterface.json @@ -0,0 +1,65 @@ +{ + "hostname": "mtn96compute.cci.att.com", + "fqdn": "mtn96compute.cci.att.com", + "pserver-id": "auto-generated-skeleton", + "pserver-name2": "pserverName2-hello", + "ptnii-equip-name": "ptnii-equip-name-hello", + "equip-type": "Firewall", + "equip-vendor": "equip-vendor-hello", + "equip-model": "equip-model-hello", + "internet-topology": "internet-topology-hello", + "purpose": "purpose-something-for-fun", + "serial-number": "1223128888", + "in-maint": false, + "resource-version": "1544034123458", + "p-interfaces":{ + "p-interface": [ + { + "interface-name": "bdc3cc2a-c73e-414f-7ddb-367de92801cb", + "speed-value": "1225", + "speed-units": "mbs", + "port-description": "port-used-for-junit", + "equipment-identifier": "8df84f0a-737a-4628-be9c-c3c78454f9d9", + "interface-role": "123134236", + "interface-type": "Software", + "prov-status": "2", + "in-maint": "true", + "resource-version": "99888", + "serial-number": "c44b872f6830498b88c4989d67b2a6b7", + "status": "ACTIVE", + "inv-status": "TBD" + } + ] + }, + "relationship-list": { + "relationship": [ + { + "related-to": "vserver", + "relationship-label": "tosca.relationships.HostedOn", + "related-link": "/aai/v13/cloud-infrastructure/cloud-regions/cloud-region/CloudOwner/RegionOne/tenants/tenant/b49b830686654191bb1e952a74b014ad/vservers/vserver/b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a", + "relationship-data": [ + { + "relationship-key": "cloud-region.cloud-owner", + "relationship-value": "CloudOwner" + }, + { + "relationship-key": "cloud-region.cloud-region-id", + "relationship-value": "RegionOne" + }, + { + "relationship-key": "tenant.tenant-id", + "relationship-value": "b49b830686654191bb1e952a74b014ad" + }, + { + "relationship-key": "vserver.vserver-id", + "relationship-value": "b494cd6e-b9f3-45e0-afe7-e1d1a5f5d74a" + } + ], + "related-to-property": [ { + "property-key": "vserver.vserver-name", + "property-value": "Firewall-0" + }] + } + ] + } +} \ No newline at end of file diff --git a/src/test/resources/junit/queryNodeData-1.json b/src/test/resources/junit/queryNodeData-1.json index 501830b..ea4bd89 100644 --- a/src/test/resources/junit/queryNodeData-1.json +++ b/src/test/resources/junit/queryNodeData-1.json @@ -2,7 +2,7 @@ "result-data": [ { "resource-type": "service-instance", - "resource-link": "/aai/v11/business/customers/customer/DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2/service-subscriptions/service-subscription/vFW/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb" + "resource-link": "/aai/v13/business/customers/customer/DemoCust_651800ed-2a3c-45f5-b920-85c1ed155fc2/service-subscriptions/service-subscription/vFW/service-instances/service-instance/adc3cc2a-c73e-414f-8ddb-367de81300cb" } ] } -- cgit 1.2.3-korg