From 2505a543b0e45c1c3c2fe2fb8b85664b08bf2fca Mon Sep 17 00:00:00 2001 From: "Benjamin, Max" Date: Mon, 21 Sep 2020 11:38:23 -0400 Subject: removed references to AAIObjectType removed references to AAIObjectType and AAIObjectPlurals additional corrections for removal of aai object type corrected additional java files updated groovy files to match aai fluent builder style Issue-ID: SO-3259 Signed-off-by: Benjamin, Max (mb388a) Change-Id: Ifdf12fcacb34cc648548eb18b638afd06dad67a9 --- .../so/adapters/cloudregion/CloudRestImpl.java | 23 ++++++++------ .../onap/so/adapters/tasks/audit/AuditVServer.java | 30 ++++++++++-------- .../so/adapters/tasks/audit/HeatStackAudit.java | 13 +++++--- .../org/onap/so/heatbridge/helpers/AaiHelper.java | 37 +++++++++++----------- 4 files changed, 56 insertions(+), 47 deletions(-) (limited to 'adapters/mso-openstack-adapters/src/main/java/org') diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/cloudregion/CloudRestImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/cloudregion/CloudRestImpl.java index 2849907e38..bb2c938940 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/cloudregion/CloudRestImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/cloudregion/CloudRestImpl.java @@ -5,12 +5,11 @@ import java.util.Optional; import org.onap.aai.domain.yang.CloudRegion; import org.onap.aai.domain.yang.Complex; import org.onap.aai.domain.yang.NetworkTechnologies; -import org.onap.aaiclient.client.aai.AAIObjectPlurals; -import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.aai.AAIResourcesClient; import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri; import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; import org.onap.so.db.catalog.beans.CloudSite; import org.onap.so.db.catalog.beans.NetworkTechnologyReference; import org.onap.so.db.catalog.client.CatalogDbClient; @@ -68,11 +67,12 @@ public class CloudRestImpl { if (complex.isPresent()) { cloudRegion.setComplexName(complex.get().getComplexName()); } - AAIResourceUri cloudRegionURI = AAIUriFactory.createResourceUri(AAIObjectType.CLOUD_REGION, - cloudRegion.getCloudOwner(), cloudRegion.getCloudRegionId()); + AAIResourceUri cloudRegionURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudRegion.getCloudOwner(), cloudRegion.getCloudRegionId())); getAaiClient().createIfNotExists(cloudRegionURI, Optional.of(cloudRegion)); if (complex.isPresent()) { - AAIResourceUri complexURI = AAIUriFactory.createResourceUri(AAIObjectType.COMPLEX, cloudSite.getClli()); + AAIResourceUri complexURI = AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().complex(cloudSite.getClli())); getAaiClient().connect(cloudRegionURI, complexURI); } createCloudRegionNetworkTechnologyRelationship(cloudSite, cloudRegionURI); @@ -88,18 +88,21 @@ public class CloudRestImpl { } protected Optional retrieveComplex(CloudSite cloudSite) { - AAIResourceUri complexURI = AAIUriFactory.createResourceUri(AAIObjectType.COMPLEX, cloudSite.getClli()); + AAIResourceUri complexURI = AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().complex(cloudSite.getClli())); return getAaiClient().get(Complex.class, complexURI); } protected void linkCloudAndTechnology(String networkTechnologyName, AAIResourceUri cloudRegionURI) { - AAIPluralResourceUri technologyPluralUri = AAIUriFactory.createResourceUri(AAIObjectPlurals.NETWORK_TECHNOLOGY) - .queryParam("network-technology-name", networkTechnologyName); + AAIPluralResourceUri technologyPluralUri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().networkTechnologies()) + .queryParam("network-technology-name", networkTechnologyName); Optional networkTechnology = getAaiClient().get(NetworkTechnologies.class, technologyPluralUri); if (networkTechnology.isPresent()) { - AAIResourceUri networkTechnologyURI = AAIUriFactory.createResourceUri(AAIObjectType.NETWORK_TECHNOLOGY, - networkTechnology.get().getNetworkTechnology().get(0).getNetworkTechnologyId()); + AAIResourceUri networkTechnologyURI = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().networkTechnology( + networkTechnology.get().getNetworkTechnology().get(0).getNetworkTechnologyId())); getAaiClient().connect(cloudRegionURI, networkTechnologyURI); } } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditVServer.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditVServer.java index 1445622357..6f87b6b309 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditVServer.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/AuditVServer.java @@ -27,12 +27,13 @@ import org.onap.aai.domain.yang.LInterface; import org.onap.aai.domain.yang.VfModule; import org.onap.aai.domain.yang.VfModules; import org.onap.aai.domain.yang.Vserver; -import org.onap.aaiclient.client.aai.AAIObjectPlurals; import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; import org.onap.aaiclient.client.aai.entities.uri.AAIPluralResourceUri; import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider; import org.onap.so.objects.audit.AAIObjectAudit; import org.onap.so.objects.audit.AAIObjectAuditList; @@ -49,20 +50,20 @@ public class AuditVServer extends AbstractAudit { public void auditVservers(AAIObjectAuditList aaiObjectAuditList) { aaiObjectAuditList.getAuditList().forEach(aaiObjectAudit -> { - boolean vserverExist = getAaiClient().exists(AAIUriFactory - .createResourceFromExistingURI(AAIObjectType.VSERVER, aaiObjectAudit.getResourceURI())); + boolean vserverExist = getAaiClient().exists( + AAIUriFactory.createResourceFromExistingURI(Types.VSERVER, aaiObjectAudit.getResourceURI())); aaiObjectAudit.setDoesObjectExist(vserverExist); }); } public Optional auditVserversThroughRelationships(String genericVnfId, String vfModuleName) { AAIObjectAuditList auditList = new AAIObjectAuditList(); - AAIPluralResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectPlurals.VF_MODULE, genericVnfId) - .queryParam("vf-module-name", vfModuleName); + AAIPluralResourceUri uri = + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(genericVnfId).vfModules()) + .queryParam("vf-module-name", vfModuleName); Optional wrapper = getAaiClient().getFirstWrapper(VfModules.class, VfModule.class, uri); if (wrapper.isPresent() && wrapper.get().getRelationships().isPresent()) { - List relatedVservers = - wrapper.get().getRelationships().get().getRelatedUris(AAIObjectType.VSERVER); + List relatedVservers = wrapper.get().getRelationships().get().getRelatedUris(Types.VSERVER); if (!relatedVservers.isEmpty()) { relatedVservers.forEach(vserverUri -> { Optional vserver = getAaiClient().get(vserverUri).asBean(Vserver.class); @@ -70,7 +71,7 @@ public class AuditVServer extends AbstractAudit { BeanUtils.copyProperties(vserver, vServerShallow); AAIObjectAudit vServerAudit = new AAIObjectAudit(); vServerAudit.setAaiObject(vServerShallow); - vServerAudit.setAaiObjectType(AAIObjectType.VSERVER.typeName()); + vServerAudit.setAaiObjectType(Types.VSERVER.typeName()); vServerAudit.setDoesObjectExist(true); auditList.getAuditList().add(vServerAudit); }); @@ -103,8 +104,8 @@ public class AuditVServer extends AbstractAudit { String cloudRegion) { AAIObjectAuditList auditList = new AAIObjectAuditList(); AAIObjectAudit vServerAudit = new AAIObjectAudit(); - AAIResourceUri vserverURI = AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, cloudOwner, cloudRegion, - tenantId, vServer.getVserverId()); + AAIResourceUri vserverURI = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudOwner, cloudRegion).tenant(tenantId).vserver(vServer.getVserverId())); Vserver vServerShallow = new Vserver(); BeanUtils.copyProperties(vServer, vServerShallow, "LInterfaces"); boolean vServerExists = getAaiClient().exists(vserverURI); @@ -112,7 +113,7 @@ public class AuditVServer extends AbstractAudit { vServerAudit.setAaiObject(vServerShallow); vServerAudit.setDoesObjectExist(vServerExists); vServerAudit.setResourceURI(vserverURI.build()); - vServerAudit.setAaiObjectType(AAIObjectType.VSERVER.typeName()); + vServerAudit.setAaiObjectType(Types.VSERVER.typeName()); auditList.getAuditList().add(vServerAudit); if (vServer.getLInterfaces() != null) { vServer.getLInterfaces().getLInterface().stream().forEach(lInterface -> auditList.getAuditList().addAll( @@ -126,8 +127,9 @@ public class AuditVServer extends AbstractAudit { String cloudOwner, String cloudRegion) { AAIObjectAuditList auditList = new AAIObjectAuditList(); AAIObjectAudit lInterfaceAudit = new AAIObjectAudit(); - AAIResourceUri linterfaceURI = AAIUriFactory.createResourceUri(AAIObjectType.L_INTERFACE, cloudOwner, - cloudRegion, tenantId, vServerId, lInterface.getInterfaceName()); + AAIResourceUri linterfaceURI = AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegion) + .tenant(tenantId).vserver(vServerId).lInterface(lInterface.getInterfaceName())); Optional queriedLInterface = getAaiClient().get(LInterface.class, linterfaceURI); if (queriedLInterface.isPresent()) { lInterfaceAudit.setDoesObjectExist(true); @@ -135,7 +137,7 @@ public class AuditVServer extends AbstractAudit { } lInterfaceAudit.setAaiObject(lInterface); lInterfaceAudit.setResourceURI(linterfaceURI.build()); - lInterfaceAudit.setAaiObjectType(AAIObjectType.L_INTERFACE.typeName()); + lInterfaceAudit.setAaiObjectType(Types.L_INTERFACE.typeName()); auditList.getAuditList().add(lInterfaceAudit); logger.info("l-interface id:{} name: {} exists: {} ", lInterface.getInterfaceId(), lInterface.getInterfaceName(), lInterfaceAudit.isDoesObjectExist()); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/HeatStackAudit.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/HeatStackAudit.java index 3ff15ffe2f..c58e568ea4 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/HeatStackAudit.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/audit/HeatStackAudit.java @@ -37,8 +37,9 @@ import org.onap.aai.domain.yang.LInterfaces; import org.onap.aai.domain.yang.Vlan; import org.onap.aai.domain.yang.Vlans; import org.onap.aai.domain.yang.Vserver; -import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder.Types; import org.onap.so.objects.audit.AAIObjectAudit; import org.onap.so.objects.audit.AAIObjectAuditList; import org.onap.so.openstack.utils.MsoHeatUtils; @@ -260,10 +261,12 @@ public class HeatStackAudit { Vserver vServerShallow = new Vserver(); BeanUtils.copyProperties(vServer, vServerShallow); aaiObjectAudit.setAaiObject(vServerShallow); - aaiObjectAudit.setAaiObjectType(AAIObjectType.VSERVER.typeName()); - aaiObjectAudit.setResourceURI(AAIUriFactory - .createResourceUri(AAIObjectType.VSERVER, cloudOwner, cloudRegion, tenantId, vServer.getVserverId()) - .build()); + aaiObjectAudit.setAaiObjectType(Types.VSERVER.typeName()); + aaiObjectAudit + .setResourceURI(AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudOwner, cloudRegion).tenant(tenantId).vserver(vServer.getVserverId())) + .build()); return aaiObjectAudit; } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java index 1fa757f547..c1a97cefc4 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/helpers/AaiHelper.java @@ -50,9 +50,9 @@ import org.onap.aai.domain.yang.RelationshipData; import org.onap.aai.domain.yang.RelationshipList; import org.onap.aai.domain.yang.SriovVf; import org.onap.aai.domain.yang.Vserver; -import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.aai.entities.uri.AAIResourceUri; import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; +import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; import org.onap.so.heatbridge.constants.HeatBridgeConstants; import org.openstack4j.model.compute.Server; import org.openstack4j.model.network.Network; @@ -82,39 +82,39 @@ public class AaiHelper { // vserver to pserver relationship if (!StringUtils.isEmpty(server.getHypervisorHostname())) { - Relationship pserverRelationship = buildRelationship( - AAIUriFactory.createResourceUri(AAIObjectType.PSERVER, server.getHypervisorHostname())); + Relationship pserverRelationship = buildRelationship(AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.cloudInfrastructure().pserver(server.getHypervisorHostname()))); relationships.add(pserverRelationship); } // vserver to generic-vnf relationship - Relationship genericVnfRelationship = - buildRelationship(AAIUriFactory.createResourceUri(AAIObjectType.GENERIC_VNF, genericVnfId)); + Relationship genericVnfRelationship = buildRelationship( + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(genericVnfId))); relationships.add(genericVnfRelationship); // vserver to vnfc relationship if (!StringUtils.isEmpty(server.getName())) { - Relationship vnfcRelationship = - buildRelationship(AAIUriFactory.createResourceUri(AAIObjectType.VNFC, server.getName())); + Relationship vnfcRelationship = buildRelationship( + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().vnfc(server.getName()))); relationships.add(vnfcRelationship); } // vserver to vf-module relationship - Relationship vfModuleRelationship = - buildRelationship(AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, genericVnfId, vfModuleId)); + Relationship vfModuleRelationship = buildRelationship(AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.network().genericVnf(genericVnfId).vfModule(vfModuleId))); relationships.add(vfModuleRelationship); // vserver to image relationship if (server.getImage() != null) { - Relationship imageRel = buildRelationship(AAIUriFactory.createResourceUri(AAIObjectType.IMAGE, cloudOwner, - cloudRegionId, server.getImage().getId())); + Relationship imageRel = buildRelationship(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder + .cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId).image(server.getImage().getId()))); relationships.add(imageRel); } // vserver to flavor relationship if (server.getFlavor() != null) { - Relationship flavorRel = buildRelationship(AAIUriFactory.createResourceUri(AAIObjectType.FLAVOR, cloudOwner, - cloudRegionId, server.getFlavor().getId())); + Relationship flavorRel = buildRelationship(AAIUriFactory.createResourceUri(AAIFluentTypeBuilder + .cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId).flavor(server.getFlavor().getId()))); relationships.add(flavorRel); } @@ -127,20 +127,21 @@ public class AaiHelper { List relationships = relationshipList.getRelationship(); // sriov-vf to sriov-pf relationship - Relationship sriovPfRelationship = buildRelationship( - AAIUriFactory.createResourceUri(AAIObjectType.SRIOV_PF, pserverName, pIfName, pfPciId)); + Relationship sriovPfRelationship = buildRelationship(AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.cloudInfrastructure().pserver(pserverName).pInterface(pIfName).sriovPf(pfPciId))); relationships.add(sriovPfRelationship); return relationshipList; } public Relationship getRelationshipToVfModule(String vnfId, String vfModuleId) { - return buildRelationship(AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId)); + return buildRelationship( + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId).vfModule(vfModuleId))); } public Relationship getRelationshipToTenant(String cloudOwner, String cloudRegionId, String tenantId) { - return buildRelationship( - AAIUriFactory.createResourceUri(AAIObjectType.TENANT, cloudOwner, cloudRegionId, tenantId)); + return buildRelationship(AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId))); } public org.onap.aai.domain.yang.Subnet buildSubnet(Subnet subnet) { -- cgit 1.2.3-korg