diff options
Diffstat (limited to 'vid-app-common/src/main/java/org/onap/vid/model/aaiTree')
16 files changed, 500 insertions, 132 deletions
diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/AAITreeNode.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/AAITreeNode.java index 4b16b3122..f092c9ae6 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/AAITreeNode.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/AAITreeNode.java @@ -7,9 +7,9 @@ * 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. @@ -20,17 +20,19 @@ package org.onap.vid.model.aaiTree; +import com.fasterxml.jackson.annotation.JsonIgnore; import org.apache.commons.lang3.StringUtils; +import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.RelationshipList; +import org.onap.vid.mso.model.CloudConfiguration; import java.util.*; public class AAITreeNode { - private String type; - private int uniqueNumber; + private NodeType type; private String orchestrationStatus; private String provStatus; - private Boolean inMaint = null; + private boolean inMaint; private String modelVersionId; private String modelCustomizationId; private String modelInvariantId; @@ -41,25 +43,19 @@ public class AAITreeNode { private String modelCustomizationName; private final List<AAITreeNode> children = Collections.synchronizedList(new LinkedList<>()); private Map<String, Object> additionalProperties = new HashMap<>(); + private CloudConfiguration cloudConfiguration; + private RelationshipList relationshipList; private String keyInModel; private AAITreeNode parent; - public String getType() { + public NodeType getType() { return type; } - public void setType(String type) { + public void setType(NodeType type) { this.type = type; } - public int getUniqueNumber() { - return uniqueNumber; - } - - public void setUniqueNumber(int uniqueNumber) { - this.uniqueNumber = uniqueNumber; - } - public String getOrchestrationStatus() { return orchestrationStatus; } @@ -76,11 +72,11 @@ public class AAITreeNode { this.provStatus = provStatus; } - public Boolean getInMaint() { + public boolean getInMaint() { return inMaint; } - public void setInMaint(Boolean inMaint) { + public void setInMaint(boolean inMaint) { this.inMaint = inMaint; } @@ -169,7 +165,7 @@ public class AAITreeNode { } public String getUniqueNodeKey() { - return getNodeKey() + ":" + String.format("%03d", this.uniqueNumber); + return this.id; } public void setKeyInModel(String keyInModel) { @@ -180,6 +176,8 @@ public class AAITreeNode { return keyInModel; } + //prevent cyclic serialization of parent and children + @JsonIgnore public AAITreeNode getParent() { return parent; } @@ -188,6 +186,22 @@ public class AAITreeNode { this.parent = parent; } + public CloudConfiguration getCloudConfiguration() { + return cloudConfiguration; + } + + public void setCloudConfiguration(CloudConfiguration cloudConfiguration) { + this.cloudConfiguration = cloudConfiguration; + } + + public RelationshipList getRelationshipList() { + return relationshipList; + } + + public void setRelationshipList(RelationshipList relationshipList) { + this.relationshipList = relationshipList; + } + public void addChildren(List<AAITreeNode> children) { for (AAITreeNode child : children) { child.setParent(this); diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/AbstractNode.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/AbstractNode.java index 64e953e17..a0fa60e97 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/AbstractNode.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/AbstractNode.java @@ -7,9 +7,9 @@ * 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. @@ -32,6 +32,7 @@ public abstract class AbstractNode { protected String productFamilyId; protected String lcpCloudRegionId; protected String tenantId; + protected String cloudOwner; protected ModelInfo modelInfo; public AbstractNode() { @@ -70,4 +71,7 @@ public abstract class AbstractNode { return modelInfo; } + public String getCloudOwner() { + return cloudOwner; + } } diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/CollectionResource.kt b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/CollectionResource.kt new file mode 100644 index 000000000..054618dd5 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/CollectionResource.kt @@ -0,0 +1,15 @@ +package org.onap.vid.model.aaiTree + +import org.apache.commons.lang.StringUtils + +fun isNfc(node: AAITreeNode): Boolean { + return node.type == NodeType.INSTANCE_GROUP && + node.additionalProperties["instance-group-type"] != null && + StringUtils.equalsIgnoreCase(node.additionalProperties["instance-group-type"].toString(), "L3-NETWORK") +} + +class CollectionResource(node: AAITreeNode) : Node(node) { + + val ncfs: Map<String, NCF> = node.children.filter { isNfc(it) }.map { it.uniqueNodeKey to NCF(it) }.toMap() + +}
\ No newline at end of file diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/InstanceGroup.kt b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/InstanceGroup.kt new file mode 100644 index 000000000..490853aa1 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/InstanceGroup.kt @@ -0,0 +1,23 @@ +package org.onap.vid.model.aaiTree + +open class InstanceGroup(aaiNode: AAITreeNode) : Node(aaiNode) { + var instanceGroupRole: String? = null + var instanceGroupFunction: String? = null + + init { + val INSTANCE_GROUP_TYPE = "instance-group-type" + val INSTANCE_GROUP_ROLE = "instance-group-role" + val INSTANCE_GROUP_FUNCTION = "instance-group-function" + + if (aaiNode.additionalProperties[INSTANCE_GROUP_TYPE] != null) { + instanceType = aaiNode.additionalProperties[INSTANCE_GROUP_TYPE].toString() + } + if (aaiNode.additionalProperties[INSTANCE_GROUP_FUNCTION] != null) { + instanceGroupFunction = aaiNode.additionalProperties[INSTANCE_GROUP_FUNCTION].toString() + } + if (aaiNode.additionalProperties[INSTANCE_GROUP_ROLE] != null) { + instanceGroupRole = aaiNode.additionalProperties[INSTANCE_GROUP_ROLE].toString() + } + } + +} diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/NCF.kt b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/NCF.kt new file mode 100644 index 000000000..6d407da4c --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/NCF.kt @@ -0,0 +1,12 @@ +package org.onap.vid.model.aaiTree + +import org.apache.commons.lang.StringUtils + +class NCF(node: AAITreeNode) : InstanceGroup(node) { + val numberOfNetworks: Int = if (node.relationshipList != null && node.relationshipList.relationship != null) { + node.relationshipList.relationship + .filter { StringUtils.equalsIgnoreCase(it.relatedTo, "L3-NETWORK") } + .count() + } else 0 +} + diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Network.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Network.java index e80e57520..6b3023332 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Network.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Network.java @@ -7,9 +7,9 @@ * 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. @@ -20,21 +20,121 @@ package org.onap.vid.model.aaiTree; -import org.onap.vid.aai.util.AAITreeConverter; - +import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL; +import static org.onap.vid.aai.util.AAITreeConverter.NETWORK_ROLE; import static org.onap.vid.aai.util.AAITreeConverter.NETWORK_TYPE; +import static org.onap.vid.aai.util.AAITreeConverter.PHYSICAL_NETWORK_NAME; +import static org.onap.vid.aai.util.AAITreeConverter.SERVICE_INSTANCE; +import static org.onap.vid.aai.util.AAITreeConverter.SERVICE_INSTANCE_SERVICE_INSTANCE_ID; +import static org.onap.vid.aai.util.AAITreeConverter.SERVICE_INSTANCE_SERVICE_INSTANCE_NAME; +import static org.onap.vid.aai.util.AAITreeConverter.TENANT; +import static org.onap.vid.aai.util.AAITreeConverter.TENANT_TENANT_NAME; +import static org.onap.vid.aai.util.AAITreeConverter.VPN_BINDING; + +import com.fasterxml.jackson.annotation.JsonInclude; +import org.apache.commons.collections.CollectionUtils; +import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.Relationship; +import org.onap.vid.aai.model.AaiGetNetworkCollectionDetails.RelationshipList; +import org.onap.vid.aai.util.AAITreeNodeUtils; +@JsonInclude(NON_NULL) public class Network extends Node { - public Network(AAITreeNode node) { - super(node, AAITreeConverter.ModelType.network); + private String role; + private String physicalName; + private String serviceName; + private String serviceUUID; + private String tenantName; + private Boolean isBoundToVpn; + private RouteTarget routeTarget; + + public Network(){} + + private Network(AAITreeNode node) { + super(node); + fillCloudConfigurationProperties(this, node.getCloudConfiguration()); } public static Network from(AAITreeNode node) { Network network = new Network(node); - if (node.getAdditionalProperties().get(NETWORK_TYPE) != null) { - network.setInstanceType(node.getAdditionalProperties().get(NETWORK_TYPE).toString()); + network.setInstanceType(readValueAsStringFromAdditionalProperties(node, NETWORK_TYPE)); + network.setRole(readValueAsStringFromAdditionalProperties(node, NETWORK_ROLE)); + network.setPhysicalName(readValueAsStringFromAdditionalProperties(node, PHYSICAL_NETWORK_NAME)); + RelationshipList relationshipList = node.getRelationshipList(); + Relationship serviceInstanceRelationship = AAITreeNodeUtils.findFirstRelationshipByRelatedTo(relationshipList, SERVICE_INSTANCE).orElse(null); + if (serviceInstanceRelationship != null) { + network.setServiceName(AAITreeNodeUtils.findFirstValue(serviceInstanceRelationship.getRelatedToPropertyList(), SERVICE_INSTANCE_SERVICE_INSTANCE_NAME).orElse(null)); + network.setServiceUUID(AAITreeNodeUtils.findFirstValue(serviceInstanceRelationship.getRelationDataList(), SERVICE_INSTANCE_SERVICE_INSTANCE_ID).orElse(null)); } + AAITreeNodeUtils.findFirstRelationshipByRelatedTo(relationshipList, TENANT).ifPresent( + tenantRelationship -> network.setTenantName(AAITreeNodeUtils.findFirstValue(tenantRelationship.getRelatedToPropertyList(), TENANT_TENANT_NAME).orElse(null)) + ); + // We are ignoring "is-bound-to-vpn" parameter from additionalProperties because there is a requirement to define vpn binding presence from by related-to: vpn-binding + network.setBoundToVpn(AAITreeNodeUtils.findFirstRelationshipByRelatedTo(relationshipList, VPN_BINDING).isPresent()); + + //get the route target + node.getChildren().stream() + .filter(x->x.getType()== NodeType.VPN_BINDING) // get all VPN_BINDING related to the network + .map(x->VpnBindingKt.from(x)) // create VPN_BINDING nodes + .filter(x-> CollectionUtils.isNotEmpty(x.getRouteTargets())) // get the RouteTargets that are not empty + .findFirst() // get the first one + .ifPresent(x->network.setRouteTarget(x.getRouteTargets().get(0))); // If there is a route target - add it to the network return network; } + + public String getRole() { + return role; + } + + public void setRole(String role) { + this.role = role; + } + + public String getPhysicalName() { + return physicalName; + } + + public void setPhysicalName(String physicalName) { + this.physicalName = physicalName; + } + + public String getServiceName() { + return serviceName; + } + + public void setServiceName(String serviceName) { + this.serviceName = serviceName; + } + + public String getServiceUUID() { + return serviceUUID; + } + + public void setServiceUUID(String serviceUUID) { + this.serviceUUID = serviceUUID; + } + + public String getTenantName() { + return tenantName; + } + + public void setTenantName(String tenantName) { + this.tenantName = tenantName; + } + + public Boolean isBoundToVpn() { + return isBoundToVpn; + } + + public void setBoundToVpn(Boolean boundToVpn) { + isBoundToVpn = boundToVpn; + } + + public RouteTarget getRouteTarget() { + return routeTarget; + } + + public void setRouteTarget(RouteTarget routeTarget) { + this.routeTarget = routeTarget; + } } diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Node.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Node.java index 5ce5eec43..435f70f1a 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Node.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Node.java @@ -7,9 +7,9 @@ * 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. @@ -20,9 +20,12 @@ package org.onap.vid.model.aaiTree; -import org.onap.vid.aai.util.AAITreeConverter; +import org.onap.vid.mso.model.CloudConfiguration; import org.onap.vid.mso.model.ModelInfo; +import java.util.Objects; +import java.util.UUID; + public class Node extends AbstractNode { private String instanceType; @@ -38,7 +41,11 @@ public class Node extends AbstractNode { private final String trackById; - public Node(AAITreeNode aaiNode, AAITreeConverter.ModelType modelType) { + public Node() { + trackById = UUID.randomUUID().toString(); + } + + public Node(AAITreeNode aaiNode) { super(); this.instanceId = aaiNode.getId(); this.instanceName = aaiNode.getName(); @@ -46,11 +53,13 @@ public class Node extends AbstractNode { this.provStatus = aaiNode.getProvStatus(); this.inMaint = aaiNode.getInMaint(); this.uuid = aaiNode.getModelVersionId(); - this.originalName = aaiNode.getModelCustomizationName(); + this.originalName = aaiNode.getKeyInModel(); this.trackById = aaiNode.getUniqueNodeKey(); ModelInfo nodeModelInfo = new ModelInfo(); - nodeModelInfo.setModelType(modelType.name()); + if (aaiNode.getType() != null) { + nodeModelInfo.setModelType(aaiNode.getType().getModelType()); + } nodeModelInfo.setModelName(aaiNode.getModelName()); nodeModelInfo.setModelVersion(aaiNode.getModelVersion()); nodeModelInfo.setModelVersionId(aaiNode.getModelVersionId()); @@ -156,4 +165,16 @@ public class Node extends AbstractNode { public String getTrackById() { return trackById; } + + public static void fillCloudConfigurationProperties(AbstractNode that, CloudConfiguration cloudConfiguration) { + if (cloudConfiguration !=null) { + that.lcpCloudRegionId = cloudConfiguration.getLcpCloudRegionId(); + that.tenantId = cloudConfiguration.getTenantId(); + that.cloudOwner = cloudConfiguration.getCloudOwner(); + } + } + + public static String readValueAsStringFromAdditionalProperties(AAITreeNode node, String key) { + return Objects.toString(node.getAdditionalProperties().get(key), null); + } } diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/NodeType.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/NodeType.java new file mode 100644 index 000000000..5e1228f9f --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/NodeType.java @@ -0,0 +1,82 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.vid.model.aaiTree; + +public enum NodeType { + SERVICE_INSTANCE("service-instance", "service-instance-id", "service-instance-name", "service"), + GENERIC_VNF ("generic-vnf", "vnf-id", "vnf-name", "vnf"), + NETWORK ("l3-network", "network-id", "network-name", "network"), + FAILURE ("failure_node", NodeType.NONE, NodeType.NONE, NodeType.NONE), + COLLECTION_RESOURCE ("collection", "collection-id", "collection-name", "collection"), + CONFIGURATION ("configuration", "configuration-id", "configuration-name", "configuration"), + PNF ("pnf", "pnf-id", "pnf-name", "pnf"), + VF_MODULE ("vf-module", "vf-module-id", "vf-module-name", "vfModule"), + INSTANCE_GROUP ("instance-group", "id", "instance-group-name", "instanceGroup"), + PORT ("l-interface", "interface-id", "interface-name", "connectionPoint"), + VOLUME_GROUP ("volume-group", "volume-group-id", "volume-group-name", "volumeGroup"), + VLAN_TAG("vlan-tag", "vlan-tag-id", NodeType.NONE, NodeType.NONE), + VPN_BINDING("vpn-binding", "vpn-id", "vpn-name", "vpnBinding"), + ; + + private String type; + private String id; + private String name; + private String modelType; + + public static final String NONE = ""; + + NodeType(String type, String id, String name, String modelType) { + this.type = type; + this.id = id; + this.name = name; + this.modelType = modelType; + } + + public String getType() { + return type; + } + + public String getId() { + return id; + } + + public String getName() { + return name; + } + + public String getModelType() { + return modelType; + } + + public static NodeType fromString(String type) { + for (NodeType nodeType : NodeType.values()) { + if (nodeType.type.equalsIgnoreCase(type)) { + return nodeType; + } + } + return null; + } + + @Override + public String toString() { + return this.type; + } +}
\ No newline at end of file diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/RelatedVnf.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/RelatedVnf.java index 37dc45afd..febd8e0fd 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/RelatedVnf.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/RelatedVnf.java @@ -7,9 +7,9 @@ * 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. @@ -20,10 +20,10 @@ package org.onap.vid.model.aaiTree; -import org.onap.vid.aai.util.AAITreeConverter; - import static org.onap.vid.aai.util.AAITreeConverter.VNF_TYPE; +import org.apache.commons.lang3.builder.ToStringBuilder; + public class RelatedVnf extends Node { private String serviceInstanceId; @@ -55,13 +55,15 @@ public class RelatedVnf extends Node { } public RelatedVnf(AAITreeNode node) { - super(node, AAITreeConverter.ModelType.vnf); + super(node); } public static RelatedVnf from(AAITreeNode node) { RelatedVnf vnf = new RelatedVnf(node); - vnf.setServiceInstanceId(node.getParent().getId()); - vnf.setServiceInstanceName(node.getParent().getName()); + if (node.getParent() != null && node.getParent().getType() == NodeType.SERVICE_INSTANCE) { + vnf.setServiceInstanceId(node.getParent().getId()); + vnf.setServiceInstanceName(node.getParent().getName()); + } if (node.getAdditionalProperties().get(VNF_TYPE) != null) { vnf.setInstanceType(node.getAdditionalProperties().get(VNF_TYPE).toString()); @@ -69,4 +71,22 @@ public class RelatedVnf extends Node { return vnf; } + + @Override + public String toString() { + return new ToStringBuilder(this) + .append("serviceInstanceId", serviceInstanceId) + .append("serviceInstanceName", serviceInstanceName) + .append("tenantName", tenantName) + .append("action", action) + .append("instanceName", instanceName) + .append("instanceId", instanceId) + .append("orchStatus", orchStatus) + .append("productFamilyId", productFamilyId) + .append("lcpCloudRegionId", lcpCloudRegionId) + .append("tenantId", tenantId) + .append("cloudOwner", cloudOwner) + .append("modelInfo", modelInfo) + .toString(); + } } diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/ServiceInstance.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/ServiceInstance.java index 111e98b25..923be132f 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/ServiceInstance.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/ServiceInstance.java @@ -7,9 +7,9 @@ * 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. @@ -20,10 +20,9 @@ package org.onap.vid.model.aaiTree; -import org.onap.vid.mso.model.ModelInfo; - import java.util.HashMap; import java.util.Map; +import org.onap.vid.mso.model.ModelInfo; public class ServiceInstance extends AbstractNode { @@ -43,13 +42,17 @@ public class ServiceInstance extends AbstractNode { private Map<String, Vnf> vnfs = new HashMap<>(); private Map<String, Network> networks = new HashMap<>(); + private Map<String, Vrf> vrfs = new HashMap<>(); + private Map<String, VnfGroup> vnfGroups = new HashMap<>(); + private Map<String, CollectionResource> collectionResources = new HashMap<>(); private int validationCounter; private Map<String, Long> existingVNFCounterMap; private Map<String, Long> existingNetworksCounterMap; private Map<String, Long> existingVnfGroupCounterMap; + private Map<String, Long> existingVRFCounterMap; public void setInstanceName(String instanceName) { this.instanceName = instanceName; @@ -175,6 +178,14 @@ public class ServiceInstance extends AbstractNode { this.networks = networks; } + public Map<String, CollectionResource> getCollectionResources() { + return collectionResources; + } + + public void setCollectionResources(Map<String, CollectionResource> collectionResources) { + this.collectionResources = collectionResources; + } + public Map<String, VnfGroup> getVnfGroups() { return vnfGroups; } public void setVnfGroups(Map<String, VnfGroup> vnfGroups) { this.vnfGroups = vnfGroups; } @@ -210,4 +221,20 @@ public class ServiceInstance extends AbstractNode { public void setExistingVnfGroupCounterMap(Map<String, Long> existingVnfGroupCounterMap) { this.existingVnfGroupCounterMap = existingVnfGroupCounterMap; } + + public Map<String, Vrf> getVrfs() { + return vrfs; + } + + public void setVrfs(Map<String, Vrf> vrfs) { + this.vrfs = vrfs; + } + + public Map<String, Long> getExistingVRFCounterMap() { + return existingVRFCounterMap; + } + + public void setExistingVRFCounterMap(Map<String, Long> existingVRFCounterMap) { + this.existingVRFCounterMap = existingVRFCounterMap; + } } diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VfModule.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VfModule.java index 2a4c83b2a..0db27eaa4 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VfModule.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VfModule.java @@ -7,9 +7,9 @@ * 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. @@ -20,8 +20,6 @@ package org.onap.vid.model.aaiTree; -import org.onap.vid.aai.util.AAITreeConverter; - import static org.onap.vid.aai.util.AAITreeConverter.IS_BASE_VF_MODULE; public class VfModule extends Node { @@ -30,7 +28,8 @@ public class VfModule extends Node { private String volumeGroupName; public VfModule(AAITreeNode node) { - super(node, AAITreeConverter.ModelType.vfModule); + super(node); + fillCloudConfigurationProperties(this, node.getCloudConfiguration()); } public boolean getIsBase() { diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Vnf.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Vnf.java index 03c1508f9..2df5bdcf6 100644 --- a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Vnf.java +++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Vnf.java @@ -7,9 +7,9 @@ * 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. @@ -20,21 +20,19 @@ package org.onap.vid.model.aaiTree; -import org.onap.vid.aai.util.AAITreeConverter; -import org.onap.vid.services.AAITreeNodeBuilder; +import static org.onap.vid.aai.util.AAITreeConverter.VNF_TYPE; import java.util.HashMap; import java.util.Map; -import static org.onap.vid.aai.util.AAITreeConverter.VNF_TYPE; - public class Vnf extends Node { private Map<String, Map<String, VfModule>> vfModules = new HashMap<>(); private Map<String, Network> networks = new HashMap<>(); public Vnf(AAITreeNode node) { - super(node, AAITreeConverter.ModelType.vnf); + super(node); + fillCloudConfigurationProperties(this, node.getCloudConfiguration()); } public Map<String, Map<String, VfModule>> getVfModules() { @@ -60,11 +58,11 @@ public class Vnf extends Node { } node.getChildren().forEach(child -> { - if (child.getType().equals(AAITreeNodeBuilder.VF_MODULE)) { + if (child.getType() == NodeType.VF_MODULE) { vnf.getVfModules().putIfAbsent(child.getNodeKey(), new HashMap<>()); vnf.getVfModules().get(child.getNodeKey()) - .put(child.getUniqueNodeKey(), VfModule.from(child)); - } else if (child.getType().equals(AAITreeNodeBuilder.NETWORK)) { + .put(child.getUniqueNodeKey(), VfModule.from(child)); + } else if (child.getType() == NodeType.NETWORK) { vnf.getNetworks().put(child.getUniqueNodeKey(), Network.from(child)); } }); diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VnfGroup.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VnfGroup.java deleted file mode 100644 index 21e5ca45e..000000000 --- a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VnfGroup.java +++ /dev/null @@ -1,72 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * VID - * ================================================================================ - * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.onap.vid.model.aaiTree; - -import org.onap.vid.aai.util.AAITreeConverter; - - -public class VnfGroup extends Node { - - public static final String INSTANCE_GROUP_TYPE = "instance-group-type"; - public static final String INSTANCE_GROUP_ROLE = "instance-group-role"; - public static final String INSTANCE_GROUP_FUNCTION = "instance-group-function"; - - private String instanceGroupRole; - private String instanceGroupFunction; - - - public VnfGroup(AAITreeNode node) { - super(node, AAITreeConverter.ModelType.instanceGroup); - } - - public static VnfGroup from(AAITreeNode node) { - VnfGroup vnfGroup = new VnfGroup(node); - if (node.getAdditionalProperties().get(INSTANCE_GROUP_TYPE) != null) { - vnfGroup.setInstanceType(node.getAdditionalProperties().get(INSTANCE_GROUP_TYPE).toString()); - } - if (node.getAdditionalProperties().get(INSTANCE_GROUP_FUNCTION) != null) { - vnfGroup.setInstanceGroupFunction(node.getAdditionalProperties().get(INSTANCE_GROUP_FUNCTION).toString()); - } - if (node.getAdditionalProperties().get(INSTANCE_GROUP_ROLE) != null) { - vnfGroup.setInstanceGroupRole(node.getAdditionalProperties().get(INSTANCE_GROUP_ROLE).toString()); - } - - return vnfGroup; - } - - public String getInstanceGroupRole() { - return instanceGroupRole; - } - - public void setInstanceGroupRole(String instanceGroupRole) { - this.instanceGroupRole = instanceGroupRole; - } - - public String getInstanceGroupFunction() { - return instanceGroupFunction; - } - - public void setInstanceGroupFunction(String instanceGroupFunction) { - this.instanceGroupFunction = instanceGroupFunction; - } - - -} diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VnfGroup.kt b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VnfGroup.kt new file mode 100644 index 000000000..47a6c98be --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VnfGroup.kt @@ -0,0 +1,10 @@ +package org.onap.vid.model.aaiTree + +class VnfGroup(node: AAITreeNode) : InstanceGroup(node) { + + val vnfs: Map<String, RelatedVnf> = node.children + .filter { it.type == NodeType.GENERIC_VNF } + .map { it.uniqueNodeKey to RelatedVnf.from(it) } + .toMap() + +}
\ No newline at end of file diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VpnBinding.kt b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VpnBinding.kt new file mode 100644 index 000000000..d43bf26f0 --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/VpnBinding.kt @@ -0,0 +1,50 @@ +package org.onap.vid.model.aaiTree + +import com.fasterxml.jackson.annotation.JsonAlias +import com.fasterxml.jackson.annotation.JsonCreator +import com.fasterxml.jackson.annotation.JsonIgnoreProperties +import com.fasterxml.jackson.annotation.JsonInclude +import com.fasterxml.jackson.core.type.TypeReference +import org.onap.portalsdk.core.logging.logic.EELFLoggerDelegate +import org.onap.vid.utils.JACKSON_OBJECT_MAPPER + +@JsonIgnoreProperties(ignoreUnknown = true) +@JsonInclude(JsonInclude.Include.NON_NULL) +class VpnBinding(aaiNode: AAITreeNode) : Node(aaiNode) { + @JsonCreator + constructor() : this(AAITreeNode()) + var region: String? = null + var customerId: String? = null + var routeTargets: List<RouteTarget>? = null +} + +val LOGGER: EELFLoggerDelegate = EELFLoggerDelegate.getLogger(VpnBinding::class.java) + +fun from(node: AAITreeNode): VpnBinding { + val vpnBinding = VpnBinding(node) + vpnBinding.platformName = Node.readValueAsStringFromAdditionalProperties(node, "vpn-platform") + vpnBinding.instanceType = Node.readValueAsStringFromAdditionalProperties(node, "vpn-type") + vpnBinding.region = Node.readValueAsStringFromAdditionalProperties(node, "vpn-region") + vpnBinding.customerId = Node.readValueAsStringFromAdditionalProperties(node, "customer-vpn-id") + + vpnBinding.routeTargets = try { + JACKSON_OBJECT_MAPPER.convertValue( + node.additionalProperties.getOrDefault("route-targets", emptyList<RouteTarget>()), + object : TypeReference<List<RouteTarget>>() {}) + } catch (exception: Exception) { + LOGGER.error("Failed to parse route-targets of vpn with id:${vpnBinding.instanceId}", exception) + listOf(RouteTarget("ParsingFailure", "ParsingFailure")) + } + + return vpnBinding +} + +@JsonIgnoreProperties(ignoreUnknown = true) +data class RouteTarget( + + @JsonAlias("global-route-target") + val globalRouteTarget: String? = null, + + @JsonAlias("route-target-role") + val routeTargetRole: String? = null +) diff --git a/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Vrf.java b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Vrf.java new file mode 100644 index 000000000..d6ef7ab0e --- /dev/null +++ b/vid-app-common/src/main/java/org/onap/vid/model/aaiTree/Vrf.java @@ -0,0 +1,65 @@ +/*- + * ============LICENSE_START======================================================= + * VID + * ================================================================================ + * Copyright (C) 2017 - 2019 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.onap.vid.model.aaiTree; + +import java.util.HashMap; +import java.util.Map; + +public class Vrf extends Node { + + private Map<String, Network> networks = new HashMap<>(); + private Map<String, VpnBinding> vpns = new HashMap<>(); + + + public Vrf(AAITreeNode node){ + super(node); + } + + public static Vrf from(AAITreeNode node) { + Vrf vrf = new Vrf(node); + + node.getChildren().forEach(child -> { + if (child.getType() == NodeType.NETWORK) { + vrf.getNetworks().put(child.getUniqueNodeKey(), Network.from(child)); + } + if (child.getType() == NodeType.VPN_BINDING) { + vrf.getVpns().put(child.getUniqueNodeKey(), VpnBindingKt.from(child)); + } + }); + return vrf; + } + + public Map<String, Network> getNetworks() { + return networks; + } + + public void setNetworks(Map<String, Network> networks) { + this.networks = networks; + } + + public Map<String, VpnBinding> getVpns() { + return vpns; + } + + public void setVpns(Map<String, VpnBinding> vpns) { + this.vpns = vpns; + } +} |