From e78a5e3bae36e084e630bd9c238a9ef238953ac5 Mon Sep 17 00:00:00 2001 From: "Smokowski, Steven" Date: Sat, 19 Sep 2020 11:02:19 -0400 Subject: Heatbridge Updates Updated heatbridge to work with upcoming A&AI changes Issue-ID: SO-3257 Signed-off-by: Benjamin, Max (mb388a) Change-Id: I6b58c8e2a920e715d303aeda5137952f667c3133 --- .../inventory/delete/DeleteAAIInventory.java | 6 +- .../tasks/inventory/CreateAAIInventory.java | 10 +- .../java/org/onap/so/heatbridge/HeatBridgeApi.java | 2 +- .../org/onap/so/heatbridge/HeatBridgeImpl.java | 272 ++++++++++++++++----- .../org/onap/so/heatbridge/helpers/AaiHelper.java | 3 + .../org/onap/so/heatbridge/HeatBridgeImplTest.java | 100 ++------ .../tasks/BBInputSetupMapperLayerTest.java | 6 +- .../tasks/BBInputSetupUtilsTest.java | 19 +- .../aaiL3NetworkInputWithSubnets.json | 5 +- .../l3NetworkExpectedWithSubnet.json | 3 +- .../onap/so/utils/ExternalTaskServiceUtils.java | 4 - .../aaiclient/client/aai/AAIObjectPlurals.java | 2 + .../onap/aaiclient/client/aai/AAIObjectType.java | 23 +- .../org/onap/aaiclient/client/aai/AAIVersion.java | 4 +- .../onap/so/simulator/actions/aai/ProcessVnfc.java | 43 +--- .../openstack/gr_api/GetNeutronNetwork2.json | 3 +- 16 files changed, 296 insertions(+), 209 deletions(-) diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteAAIInventory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteAAIInventory.java index 1f0422b0b2..22e6b1fc22 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteAAIInventory.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/inventory/delete/DeleteAAIInventory.java @@ -54,9 +54,9 @@ public class DeleteAAIInventory { CloudSite cloudSite = cloudConfig.getCloudSite(cloudInformation.getRegionId()) .orElseThrow(() -> new MsoCloudSiteNotFound(cloudInformation.getRegionId())); CloudIdentity cloudIdentity = cloudSite.getIdentityService(); - HeatBridgeApi heatBridgeClient = - new HeatBridgeImpl(new AAIResourcesClient(), cloudIdentity, cloudInformation.getOwner(), - cloudInformation.getRegionId(), cloudSite.getRegionId(), cloudInformation.getTenantId()); + HeatBridgeApi heatBridgeClient = new HeatBridgeImpl(new AAIResourcesClient(), cloudIdentity, + cloudInformation.getOwner(), cloudInformation.getRegionId(), cloudSite.getRegionId(), + cloudInformation.getTenantId(), cloudInformation.getNodeType()); heatBridgeClient.authenticate(); heatBridgeClient.deleteVfModuleData(cloudInformation.getVnfId(), cloudInformation.getVfModuleId()); diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java index 12751f8c27..3f79c43bf8 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/tasks/inventory/CreateAAIInventory.java @@ -64,9 +64,9 @@ public class CreateAAIInventory { List oobMgtNetNames = new ArrayList<>(); - HeatBridgeApi heatBridgeClient = - new HeatBridgeImpl(new AAIResourcesClient(), cloudIdentity, cloudInformation.getOwner(), - cloudInformation.getRegionId(), cloudSite.getRegionId(), cloudInformation.getTenantId()); + HeatBridgeApi heatBridgeClient = new HeatBridgeImpl(new AAIResourcesClient(), cloudIdentity, + cloudInformation.getOwner(), cloudInformation.getRegionId(), cloudSite.getRegionId(), + cloudInformation.getTenantId(), cloudInformation.getNodeType()); heatBridgeClient.authenticate(); @@ -119,8 +119,8 @@ public class CreateAAIInventory { "Successfully queried neutron resources and built AAI actions to add l-interfaces to vservers."); // Update AAI - logger.debug("Current Dry Run Value: {}", env.getProperty("heatBridgeDryrun", Boolean.class, true)); - heatBridgeClient.submitToAai(env.getProperty("heatBridgeDryrun", Boolean.class, true)); + logger.debug("Current Dry Run Value: {}", env.getProperty("heatBridgeDryrun", Boolean.class, false)); + heatBridgeClient.submitToAai(env.getProperty("heatBridgeDryrun", Boolean.class, false)); } catch (Exception ex) { logger.debug("Heatbrige failed for stackId: " + cloudInformation.getTemplateInstanceId(), ex); } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java index a4e6cccc06..bafba3e901 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeApi.java @@ -155,7 +155,7 @@ public interface HeatBridgeApi { * @param cloudOwner */ void buildAddVserverLInterfacesToAaiAction(List stackResources, List oobMgtNetIds, - String cloudOwner); + String cloudOwner) throws HeatBridgeException; /** * Query and build AAI actions for Openstack Compute resources to AAI's pserver and pinterface objects diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java index 7e25ed600f..90a578d3b4 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/heatbridge/HeatBridgeImpl.java @@ -32,6 +32,8 @@ */ package org.onap.so.heatbridge; +import java.io.IOException; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -60,22 +62,31 @@ import org.onap.aai.domain.yang.SriovPf; import org.onap.aai.domain.yang.SriovPfs; import org.onap.aai.domain.yang.Subnets; import org.onap.aai.domain.yang.SriovVf; -import org.onap.aai.domain.yang.SriovVfs; import org.onap.aai.domain.yang.VfModule; 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.AAIDSLQueryClient; import org.onap.aaiclient.client.aai.AAIResourcesClient; import org.onap.aaiclient.client.aai.AAISingleTransactionClient; import org.onap.aaiclient.client.aai.entities.AAIResultWrapper; import org.onap.aaiclient.client.aai.entities.Relationships; +import org.onap.aaiclient.client.aai.entities.Results; 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.Format; +import org.onap.aaiclient.client.graphinventory.entities.DSLQuery; +import org.onap.aaiclient.client.graphinventory.entities.DSLQueryBuilder; +import org.onap.aaiclient.client.graphinventory.entities.DSLStartNode; +import org.onap.aaiclient.client.graphinventory.entities.Node; +import org.onap.aaiclient.client.graphinventory.entities.Start; +import org.onap.aaiclient.client.graphinventory.entities.TraversalBuilder; +import org.onap.aaiclient.client.graphinventory.entities.__; import org.onap.aaiclient.client.graphinventory.entities.uri.Depth; import org.onap.aaiclient.client.graphinventory.exceptions.BulkProcessFailed; import org.onap.logging.filter.base.ErrorCode; +import org.onap.so.cloud.resource.beans.NodeType; import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.db.catalog.beans.ServerType; import org.onap.so.heatbridge.constants.HeatBridgeConstants; @@ -97,6 +108,8 @@ import org.openstack4j.model.network.Subnet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.core.env.Environment; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.common.base.Preconditions; import com.google.common.base.Strings; import com.google.common.collect.ImmutableMap; @@ -111,21 +124,34 @@ public class HeatBridgeImpl implements HeatBridgeApi { private static final String ERR_MSG_NULL_OS_CLIENT = "Initialization error: Null openstack client. Authenticate with Keystone first."; private static final String OOB_MGT_NETWORK_IDENTIFIER = "Management"; + + protected static final String DIRECT = "direct"; + protected static final String PCI_SLOT = "pci_slot"; + protected static final String OVSNET = "ovsnet"; + protected static final String SRIOV = "SRIOV"; + protected static final String RESOURCE_LINK = "resource-link"; + + protected static final Object PRIVATE_VLANS = "private_vlans"; + protected static final Object PUBLIC_VLANS = "public_vlans"; + + protected ObjectMapper mapper = new ObjectMapper(); + private OpenstackClient osClient; private AAIResourcesClient resourcesClient; + private AAIDSLQueryClient aaiDSLClient; private AAISingleTransactionClient transaction; private String cloudOwner; private String cloudRegionId; private String regionId; private String tenantId; + private NodeType nodeType; private AaiHelper aaiHelper = new AaiHelper(); private CloudIdentity cloudIdentity; private Environment env; - public HeatBridgeImpl(AAIResourcesClient resourcesClient, final CloudIdentity cloudIdentity, @Nonnull final String cloudOwner, @Nonnull final String cloudRegionId, @Nonnull final String regionId, - @Nonnull final String tenantId) { + @Nonnull final String tenantId, @Nonnull final NodeType nodeType) { Objects.requireNonNull(cloudOwner, "Null cloud-owner value!"); Objects.requireNonNull(cloudRegionId, "Null cloud-region identifier!"); Objects.requireNonNull(tenantId, "Null tenant identifier!"); @@ -137,6 +163,7 @@ public class HeatBridgeImpl implements HeatBridgeApi { this.regionId = regionId; this.tenantId = tenantId; this.resourcesClient = resourcesClient; + this.nodeType = nodeType; if (resourcesClient != null) this.transaction = resourcesClient.beginSingleTransaction(); if (SpringContextHelper.getAppContext() != null) @@ -202,6 +229,11 @@ public class HeatBridgeImpl implements HeatBridgeApi { return serverIds.stream().map(serverId -> osClient.getServerById(serverId)).collect(Collectors.toList()); } + + protected Server getOpenstackServerById(String deviceId) { + return osClient.getServerById(deviceId); + } + @Override public List getAllOpenstackProviderNetworks(final List stackResources) { Objects.requireNonNull(osClient, ERR_MSG_NULL_OS_CLIENT); @@ -241,7 +273,8 @@ public class HeatBridgeImpl implements HeatBridgeApi { l3Network.setRelationshipList(relationshipList); transaction.createIfNotExists( - AAIUriFactory.createResourceUri(AAIObjectType.L3_NETWORK, l3Network.getNetworkId()), + AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.network().l3Network(l3Network.getNetworkId())), Optional.of(l3Network)); } }); @@ -253,8 +286,8 @@ public class HeatBridgeImpl implements HeatBridgeApi { for (org.openstack4j.model.compute.Image image : images) { Image aaiImage = aaiHelper.buildImage(image); try { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.IMAGE, cloudOwner, cloudRegionId, - aaiImage.getImageId()); + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudOwner, cloudRegionId).image(aaiImage.getImageId())); if (!resourcesClient.exists(uri)) { transaction.create(uri, aaiImage); logger.debug("Queuing AAI command to add image: " + aaiImage.getImageId()); @@ -274,8 +307,8 @@ public class HeatBridgeImpl implements HeatBridgeApi { for (org.openstack4j.model.compute.Flavor flavor : flavors) { Flavor aaiFlavor = aaiHelper.buildFlavor(flavor); try { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.FLAVOR, cloudOwner, cloudRegionId, - aaiFlavor.getFlavorId()); + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudOwner, cloudRegionId).flavor(aaiFlavor.getFlavorId())); transaction.createIfNotExists(uri, Optional.of(aaiFlavor)); } catch (WebApplicationException e) { throw new HeatBridgeException( @@ -293,20 +326,24 @@ public class HeatBridgeImpl implements HeatBridgeApi { // Build vserver relationships to: image, flavor, pserver, vf-module vserver.setRelationshipList( aaiHelper.getVserverRelationshipList(cloudOwner, cloudRegionId, genericVnfId, vfModuleId, server)); - transaction.createIfNotExists(AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, cloudOwner, - cloudRegionId, tenantId, vserver.getVserverId()), Optional.of(vserver)); + transaction.createIfNotExists( + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId).vserver(vserver.getVserverId())), + Optional.of(vserver)); }); } @Override public void buildAddVserverLInterfacesToAaiAction(final List stackResources, - final List oobMgtNetIds, String cloudOwner) { + final List oobMgtNetIds, String cloudOwner) throws HeatBridgeException { Objects.requireNonNull(osClient, ERR_MSG_NULL_OS_CLIENT); List portIds = extractStackResourceIdsByResourceType(stackResources, HeatBridgeConstants.OS_PORT_RESOURCE_TYPE); + if (portIds == null) return; for (String portId : portIds) { + boolean isL2Multicast = false; Port port = osClient.getPortById(portId); Network network = osClient.getNetworkById(port.getNetworkId()); LInterface lIf = new LInterface(); @@ -317,12 +354,7 @@ public class HeatBridgeImpl implements HeatBridgeApi { lIf.setIsPortMirrored(false); lIf.setIsIpUnnumbered(false); lIf.setInMaint(false); - if (oobMgtNetIds != null && oobMgtNetIds.contains(port.getNetworkId())) { - lIf.setInterfaceRole(OOB_MGT_NETWORK_IDENTIFIER); - } else { - lIf.setInterfaceRole(port.getvNicType()); - } - boolean isL2Multicast = false; + if (port.getProfile() != null && port.getProfile().get("trusted") != null) { String trusted = port.getProfile().get("trusted").toString(); if (Boolean.parseBoolean(trusted)) { @@ -330,19 +362,46 @@ public class HeatBridgeImpl implements HeatBridgeApi { } } lIf.setL2Multicasting(isL2Multicast); + lIf.setInterfaceType(getInterfaceType(nodeType, port.getvNicType())); + lIf.setRelationshipList(new RelationshipList()); - transaction.createIfNotExists(AAIUriFactory.createResourceUri(AAIObjectType.L_INTERFACE, cloudOwner, - cloudRegionId, tenantId, port.getDeviceId(), lIf.getInterfaceName()), Optional.of(lIf)); + if (oobMgtNetIds != null && oobMgtNetIds.contains(port.getNetworkId())) { + lIf.setInterfaceRole(OOB_MGT_NETWORK_IDENTIFIER); + } else { + lIf.setInterfaceRole(port.getvNicType()); + } + + // Update l-interface to the vserver + transaction.createIfNotExists( + AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId) + .tenant(tenantId).vserver(port.getDeviceId()).lInterface(lIf.getInterfaceName())), + Optional.of(lIf)); updateLInterfaceIps(port, lIf); + if (cloudOwner.equals(env.getProperty("mso.cloudOwner.included", ""))) { - updateLInterfaceVlan(port, lIf); + Server server = getOpenstackServerById(port.getDeviceId()); + updateLInterfaceVlan(port, lIf, server.getHypervisorHostname()); } updateSriovPfToPserver(port, lIf); } } + protected String getInterfaceType(NodeType nodeType, String nicType) { + logger.debug("nicType: " + nicType + "nodeType: " + nodeType); + if (DIRECT.equalsIgnoreCase(nicType)) { + return SRIOV; + } else { + if (nodeType == NodeType.GREENFIELD) { + return NodeType.GREENFIELD.getNetworkTechnologyName(); + } else { + return NodeType.BROWNFIELD.getNetworkTechnologyName(); + } + } + } + @Override public void createPserversAndPinterfacesIfNotPresentInAai(final List stackResources) throws HeatBridgeException { @@ -356,8 +415,10 @@ public class HeatBridgeImpl implements HeatBridgeApi { for (String portId : portIds) { Port port = osClient.getPortById(portId); if (port.getvNicType().equalsIgnoreCase(HeatBridgeConstants.OS_SRIOV_PORT_TYPE)) { - createPServerPInterfaceIfNotExists(serverHostnames.get(port.getHostId()).getHostname(), - aaiHelper.buildPInterface(port)); + Pserver foundServer = serverHostnames.get(port.getHostId()); + if (foundServer != null) { + createPServerPInterfaceIfNotExists(foundServer.getHostname(), aaiHelper.buildPInterface(port)); + } } } } @@ -369,6 +430,7 @@ public class HeatBridgeImpl implements HeatBridgeApi { for (Server server : osServers) { Pserver pserver = aaiHelper.buildPserver(server); if (pserver != null) { + logger.debug("Adding Pserver: " + server.getHost()); pserverMap.put(server.getHost(), pserver); } } @@ -392,18 +454,21 @@ public class HeatBridgeImpl implements HeatBridgeApi { private void createPServerIfNotExists(Map serverHostnames) { for (Pserver pserver : serverHostnames.values()) { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.PSERVER, pserver.getHostname()); + AAIResourceUri uri = AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().pserver(pserver.getHostname())); resourcesClient.createIfNotExists(uri, Optional.of(pserver)); } } private void createPServerPInterfaceIfNotExists(String pserverHostname, PInterface pInterface) { - AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIObjectType.P_INTERFACE, pserverHostname, - pInterface.getInterfaceName()); + AAIResourceUri uri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .pserver(pserverHostname).pInterface(pInterface.getInterfaceName())); resourcesClient.createIfNotExists(uri, Optional.of(pInterface)); } - private void updateLInterfaceVlan(final Port port, final LInterface lIf) { + private void updateLInterfaceVlan(final Port port, final LInterface lIf, final String hostName) + throws HeatBridgeException { + // add back all vlan logic Vlan vlan = new Vlan(); Network network = osClient.getNetworkById(port.getNetworkId()); if (network.getNetworkType() != null && network.getNetworkType().equals(NetworkType.VLAN)) { @@ -413,7 +478,6 @@ public class HeatBridgeImpl implements HeatBridgeApi { vlan.setInMaint(false); vlan.setIsIpUnnumbered(false); vlan.setIsPrivate(false); - transaction .createIfNotExists( AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() @@ -422,6 +486,32 @@ public class HeatBridgeImpl implements HeatBridgeApi { Optional.of(vlan)); } + if (nodeType == NodeType.GREENFIELD) { + validatePhysicalNetwork(port, network); + processOVS(lIf, hostName, NodeType.GREENFIELD.getInterfaceName()); + } else { + processOVS(lIf, hostName, NodeType.BROWNFIELD.getInterfaceName()); + } + + List privateVlans = (ArrayList) port.getProfile().get(PRIVATE_VLANS); + List publicVlans = (ArrayList) port.getProfile().get(PUBLIC_VLANS); + List vlans = null; + if (publicVlans != null && !publicVlans.isEmpty()) { + vlans = publicVlans.stream().filter(publicVlan -> !Strings.isNullOrEmpty(publicVlan)) + .collect(Collectors.toList()); + } else { + vlans = new ArrayList<>(); + } + + if (privateVlans != null && !privateVlans.isEmpty()) { + List temp = privateVlans.stream().filter(privateVlan -> !Strings.isNullOrEmpty(privateVlan)) + .collect(Collectors.toList()); + vlans.addAll(temp); + } + vlans.stream().forEach(vlanLocal -> logger.debug("Vlan Id: {}", vlanLocal)); + + processVlanTag(lIf, vlans); + if (port.getvNicType() != null && port.getvNicType().equalsIgnoreCase(HeatBridgeConstants.OS_SRIOV_PORT_TYPE)) { SriovVf sriovVf = new SriovVf(); sriovVf.setPciId(port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString()); @@ -439,6 +529,49 @@ public class HeatBridgeImpl implements HeatBridgeApi { } } + protected String createVlanTagUri(String vlanIdOuter) throws HeatBridgeException { + int vlanOuterInt = Integer.parseInt(vlanIdOuter); + DSLQueryBuilder builder = TraversalBuilder + .fragment(new DSLStartNode(Types.CLOUD_REGION, __.key("cloud-owner", cloudOwner), + __.key("cloud-region-id", cloudRegionId))) + .to(__.node(Types.VLAN_RANGE)) + .to(__.node(Types.VLAN_TAG, __.key("vlan-id-outer", vlanOuterInt)).output()); + String results = getAAIDSLClient().query(Format.PATHED, new DSLQuery(builder.build())); + Optional vlanTagURI = findLinkedURI(results); + if (vlanTagURI.isPresent()) + return vlanTagURI.get(); + else + throw new HeatBridgeException("Cannot find VlanTag Related Link " + vlanIdOuter); + } + + + protected void processVlanTag(LInterface lInterface, List vlanTags) throws HeatBridgeException { + for (String vlanTag : vlanTags) { + Relationship vlanTagRelationship = new Relationship(); + vlanTagRelationship.setRelatedLink(createVlanTagUri(vlanTag)); + lInterface.getRelationshipList().getRelationship().add(vlanTagRelationship); + } + } + + protected void validatePhysicalNetwork(Port neutronPort, Network network) throws HeatBridgeException { + String physicalNetworkType = network.getProviderPhyNet(); + if (!OVSNET.equalsIgnoreCase(physicalNetworkType)) { + String exceptionMessage = String.format( + "The OVS-DPDK port is expected to have a physical network of type ovsnet but was found to have %s instead.", + physicalNetworkType); + throw new HeatBridgeException(exceptionMessage); + } + } + + protected void processOVS(LInterface lInterface, String hostName, String interfaceName) { + Relationship lagRelationship = new Relationship(); + lagRelationship.setRelatedLink(AAIUriFactory + .createResourceUri( + AAIFluentTypeBuilder.cloudInfrastructure().pserver(hostName).lagInterface(interfaceName)) + .build().toString()); + lInterface.getRelationshipList().getRelationship().add(lagRelationship); + } + /** * Needs to be corrected according to the specification that is in draft If pserver/p-interface does not have a * SRIOV-PF object matching the PCI-ID of the Openstack port object, then create it in AAI. Openstack SRIOV Port @@ -464,9 +597,11 @@ public class HeatBridgeImpl implements HeatBridgeApi { lIf.setInterfaceDescription( "Attached to SR-IOV port: " + pserverHostName + "::" + matchingPifName.get()); try { - Optional matchingPIf = resourcesClient.get(PInterface.class, AAIUriFactory - .createResourceUri(AAIObjectType.P_INTERFACE, pserverHostName, matchingPifName.get()) - .depth(Depth.ONE)); + Optional matchingPIf = resourcesClient.get(PInterface.class, + AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .pserver(pserverHostName).pInterface(matchingPifName.get())) + .depth(Depth.ONE)); if (matchingPIf.isPresent()) { SriovPfs pIfSriovPfs = matchingPIf.get().getSriovPfs(); if (pIfSriovPfs == null) { @@ -484,16 +619,18 @@ public class HeatBridgeImpl implements HeatBridgeApi { logger.debug("Queuing AAI command to update sriov-pf object to pserver: " + pserverHostName + "/" + matchingPifName.get()); - AAIResourceUri sriovPfUri = AAIUriFactory.createResourceUri(AAIObjectType.SRIOV_PF, - pserverHostName, matchingPifName.get(), sriovPf.getPfPciId()); + AAIResourceUri sriovPfUri = AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.cloudInfrastructure().pserver(pserverHostName) + .pInterface(matchingPifName.get()).sriovPf(sriovPf.getPfPciId())); + if (!resourcesClient.exists(sriovPfUri)) { transaction.create(sriovPfUri, sriovPf); - AAIResourceUri sriovVfUri = AAIUriFactory.createResourceUri(AAIObjectType.SRIOV_VF, - cloudOwner, cloudRegionId, tenantId, port.getDeviceId(), lIf.getInterfaceName(), - port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString()); - + AAIResourceUri sriovVfUri = AAIUriFactory.createResourceUri(AAIFluentTypeBuilder + .cloudInfrastructure().cloudRegion(cloudOwner, cloudRegionId).tenant(tenantId) + .vserver(port.getDeviceId()).lInterface(lIf.getInterfaceName()).sriovVf( + port.getProfile().get(HeatBridgeConstants.OS_PCI_SLOT_KEY).toString())); transaction.connect(sriovPfUri, sriovVfUri); } } @@ -562,17 +699,16 @@ public class HeatBridgeImpl implements HeatBridgeApi { Objects.requireNonNull(vnfId, "Null vnf-id!"); Objects.requireNonNull(vfModuleId, "Null vf-module-id!"); try { - Optional vfModule = resourcesClient - .get(AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, vnfId, vfModuleId).depth(Depth.ONE), - NotFoundException.class) - .asBean(VfModule.class); + Optional vfModule = resourcesClient.get(AAIUriFactory + .createResourceUri(AAIFluentTypeBuilder.network().genericVnf(vnfId).vfModule(vfModuleId)) + .depth(Depth.ONE), NotFoundException.class).asBean(VfModule.class); AAIResultWrapper resultWrapper = new AAIResultWrapper(vfModule.get()); Optional relationships = resultWrapper.getRelationships(); logger.debug("VfModule contains relationships in AAI: {}", relationships.isPresent()); if (relationships.isPresent()) { - List l3NetworkUris = relationships.get().getRelatedUris(AAIObjectType.L3_NETWORK); + List l3NetworkUris = relationships.get().getRelatedUris(Types.L3_NETWORK); logger.debug("L3Network contains {} relationships in AAI", l3NetworkUris.size()); if (!l3NetworkUris.isEmpty()) { @@ -585,13 +721,13 @@ public class HeatBridgeImpl implements HeatBridgeApi { } } - List vserverUris = relationships.get().getRelatedUris(AAIObjectType.VSERVER); + List vserverUris = relationships.get().getRelatedUris(Types.VSERVER); logger.debug("VServer contains {} relationships in AAI", vserverUris.size()); createTransactionToDeleteSriovPfFromPserver(vserverUris); if (!vserverUris.isEmpty()) { for (AAIResourceUri vserverUri : vserverUris) { - if (env.getProperty("heatBridgeDryrun", Boolean.class, true)) { + if (env.getProperty("heatBridgeDryrun", Boolean.class, false)) { logger.debug("Would delete Vserver: {}", vserverUri.build().toString()); } else { resourcesClient.delete(vserverUri); @@ -617,7 +753,8 @@ public class HeatBridgeImpl implements HeatBridgeApi { String pserverName = entry.getKey(); List pciIds = entry.getValue(); Optional pserver = resourcesClient.get(Pserver.class, - AAIUriFactory.createResourceUri(AAIObjectType.PSERVER, pserverName).depth(Depth.TWO)); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure().pserver(pserverName)) + .depth(Depth.TWO)); if (pserver.isPresent()) { // For each pserver/p-interface match sriov-vfs by pic-id and delete them. pserver.get().getPInterfaces().getPInterface().stream().filter( @@ -626,15 +763,15 @@ public class HeatBridgeImpl implements HeatBridgeApi { if (pciIds.contains(sriovPf.getPfPciId())) { logger.debug("creating transaction to delete SR-IOV PF: " + pIf.getInterfaceName() + " from PServer: " + pserverName); - if (env.getProperty("heatBridgeDryrun", Boolean.class, true)) { + if (env.getProperty("heatBridgeDryrun", Boolean.class, false)) { logger.debug("Would delete Sriov Pf: {}", - AAIUriFactory - .createResourceUri(AAIObjectType.SRIOV_PF, pserverName, - pIf.getInterfaceName(), sriovPf.getPfPciId()) - .build().toString()); + AAIUriFactory.createResourceUri(AAIFluentTypeBuilder.cloudInfrastructure() + .pserver(pserverName).pInterface(pIf.getInterfaceName()) + .sriovPf(sriovPf.getPfPciId())).build()); } else { - resourcesClient.delete(AAIUriFactory.createResourceUri(AAIObjectType.SRIOV_PF, - pserverName, pIf.getInterfaceName(), sriovPf.getPfPciId())); + resourcesClient.delete(AAIUriFactory.createResourceUri( + AAIFluentTypeBuilder.cloudInfrastructure().pserver(pserverName) + .pInterface(pIf.getInterfaceName()).sriovPf(sriovPf.getPfPciId()))); } } })); @@ -648,12 +785,11 @@ public class HeatBridgeImpl implements HeatBridgeApi { AAIResultWrapper vserverWrapper = resourcesClient.get(vserverUri.depth(Depth.TWO)); Optional vserverRelationships = vserverWrapper.getRelationships(); if (vserverRelationships.isPresent() - && CollectionUtils.isNotEmpty(vserverRelationships.get().getRelatedLinks(AAIObjectType.PSERVER))) { + && CollectionUtils.isNotEmpty(vserverRelationships.get().getRelatedLinks(Types.PSERVER))) { Vserver vserver = vserverWrapper.asBean(Vserver.class).get(); List pciIds = HeatBridgeUtils.extractPciIdsFromVServer(vserver); if (CollectionUtils.isNotEmpty(pciIds)) { - List matchingPservers = - vserverRelationships.get().getRelatedUris(AAIObjectType.PSERVER); + List matchingPservers = vserverRelationships.get().getRelatedUris(Types.PSERVER); if (matchingPservers != null && matchingPservers.size() == 1) { pserverToPciIdMap.put(matchingPservers.get(0).getURIKeys().get("hostname"), pciIds); } @@ -667,4 +803,28 @@ public class HeatBridgeImpl implements HeatBridgeApi { Map map = new ConcurrentHashMap<>(); return t -> map.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null; } + + protected Optional findLinkedURI(String jsonResultsString) { + Results> results; + try { + results = mapper.readValue(jsonResultsString, new TypeReference>>() {}); + if (results.getResult().size() == 1) { + return Optional.of(results.getResult().get(0).get(RESOURCE_LINK)); + } else if (results.getResult().isEmpty()) { + return Optional.empty(); + } else { + throw new IllegalStateException("more than one result returned"); + } + } catch (IOException e) { + logger.error("Error retrieving URI from Results JSON", e); + return Optional.empty(); + } + } + + protected AAIDSLQueryClient getAAIDSLClient() { + if (aaiDSLClient == null) { + aaiDSLClient = new AAIDSLQueryClient(); + } + return aaiDSLClient; + } } 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 7d4e92d9ad..1fa757f547 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 @@ -252,6 +252,9 @@ public class AaiHelper { .filter(link -> link.getRel().equals(HeatBridgeConstants.OS_RESOURCES_SELF_LINK_KEY)).findFirst() .ifPresent(link -> aaiImage.setImageSelflink(link.getHref())); } + if (aaiImage.getImageSelflink() == null || aaiImage.getImageSelflink().isEmpty()) { + aaiImage.setImageSelflink("NA"); + } return aaiImage; } diff --git a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java index 18348f19d7..cea436b799 100644 --- a/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java +++ b/adapters/mso-openstack-adapters/src/test/java/org/onap/so/heatbridge/HeatBridgeImplTest.java @@ -72,6 +72,7 @@ import org.onap.aai.domain.yang.L3InterfaceIpv6AddressList; import org.onap.aai.domain.yang.LInterface; import org.onap.aai.domain.yang.PInterface; import org.onap.aai.domain.yang.SriovPf; +import org.onap.aaiclient.client.aai.AAIDSLQueryClient; import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.aai.AAIResourcesClient; import org.onap.aaiclient.client.aai.AAISingleTransactionClient; @@ -80,6 +81,7 @@ import org.onap.aaiclient.client.aai.entities.uri.AAIUriFactory; import org.onap.aaiclient.client.generated.fluentbuilders.AAIFluentTypeBuilder; import org.onap.aaiclient.client.graphinventory.GraphInventoryCommonObjectMapperProvider; import org.onap.aaiclient.client.graphinventory.exceptions.BulkProcessFailed; +import org.onap.so.cloud.resource.beans.NodeType; import org.onap.so.db.catalog.beans.CloudIdentity; import org.onap.so.heatbridge.constants.HeatBridgeConstants; import org.onap.so.heatbridge.helpers.AaiHelper; @@ -106,7 +108,7 @@ import com.google.common.collect.ImmutableMap; import inet.ipaddr.IPAddressString; -@RunWith(MockitoJUnitRunner.class) +@RunWith(MockitoJUnitRunner.Silent.class) public class HeatBridgeImplTest { private static final String CLOUD_OWNER = "CloudOwner"; @@ -125,34 +127,25 @@ public class HeatBridgeImplTest { @Mock private AAISingleTransactionClient transaction; + @Mock + private AAIDSLQueryClient mockDSLClient; + @Mock private Environment env; + @Mock + private Server server; + @InjectMocks - private HeatBridgeImpl heatbridge = - new HeatBridgeImpl(resourcesClient, cloudIdentity, CLOUD_OWNER, REGION_ID, REGION_ID, TENANT_ID); + private HeatBridgeImpl heatbridge = new HeatBridgeImpl(resourcesClient, cloudIdentity, CLOUD_OWNER, REGION_ID, + REGION_ID, TENANT_ID, NodeType.GREENFIELD); @Before public void setUp() throws HeatBridgeException, OpenstackClientException, BulkProcessFailed { when(resourcesClient.beginSingleTransaction()).thenReturn(transaction); } - @Ignore - @Test - public void testQueryNestedHeatStackResources() throws HeatBridgeException { - // Arrange - String heatStackId = "1234567"; - List expectedResourceList = (List) extractTestStackResources(); - when(osClient.getStackBasedResources(heatStackId, HeatBridgeConstants.OS_DEFAULT_HEAT_NESTING)) - .thenReturn(expectedResourceList); - - // Act - List resourceList = heatbridge.queryNestedHeatStackResources(heatStackId); - // Assert - verify(osClient).getStackBasedResources(heatStackId, HeatBridgeConstants.OS_DEFAULT_HEAT_NESTING); - assertEquals(resourceList, expectedResourceList); - } @Test public void testExtractStackResourceIdsByResourceType() throws HeatBridgeException { @@ -169,73 +162,6 @@ public class HeatBridgeImplTest { assertEquals(expectedServerIds, serverIds); } - @Ignore - @Test - public void testGetAllOpenstackServers() { - // Arrange - List stackResources = (List) extractTestStackResources(); - - Server server1 = mock(Server.class); - Server server2 = mock(Server.class); - List expectedServers = Arrays.asList(server1, server2); - - when(osClient.getServerById("43c2159b-2c04-46ac-bda5-594110cae2d3")).thenReturn(server1); - when(osClient.getServerById("7cff109a-b2b7-4933-97b4-ec44a8365568")).thenReturn(server2); - - // Act - List servers = heatbridge.getAllOpenstackServers(stackResources); - - // Assert - assertEquals(expectedServers, servers); - } - - @Ignore - @Test - public void testExtractOpenstackImagesFromServers() { - // Arrange - Server server1 = mock(Server.class); - Server server2 = mock(Server.class); - List servers = Arrays.asList(server1, server2); - - Image image1 = mock(Image.class); - Image image2 = mock(Image.class); - when(image1.getId()).thenReturn("1"); - when(image2.getId()).thenReturn("1"); - List expectedDistinctImages = Collections.singletonList(image1); - - when(server1.getImage()).thenReturn(image1); - when(server2.getImage()).thenReturn(image2); - - // Act - List images = heatbridge.extractOpenstackImagesFromServers(servers); - - // Assert - assertEquals(expectedDistinctImages, images); - } - - @Ignore - @Test - public void testExtractOpenstackFlavorsFromServers() { - // Arrange - Server server1 = mock(Server.class); - Server server2 = mock(Server.class); - List servers = Arrays.asList(server1, server2); - - Flavor flavor1 = mock(Flavor.class); - Flavor flavor2 = mock(Flavor.class); - when(flavor1.getId()).thenReturn("1"); - when(flavor2.getId()).thenReturn("2"); - List expectedFlavors = Arrays.asList(flavor1, flavor2); - - when(server1.getFlavor()).thenReturn(flavor1); - when(server2.getFlavor()).thenReturn(flavor2); - - // Act - List flavors = heatbridge.extractOpenstackFlavorsFromServers(servers); - - // Assert - assertEquals(expectedFlavors, flavors); - } @Test public void testUpdateVserversToAai() throws HeatBridgeException { @@ -428,6 +354,9 @@ public class HeatBridgeImplTest { when(port.getMacAddress()).thenReturn("78:4f:43:68:e2:78"); when(port.getNetworkId()).thenReturn("890a203a-23gg-56jh-df67-731656a8f13a"); when(port.getDeviceId()).thenReturn("test-device-id"); + + when(osClient.getServerById("test-device-id")).thenReturn(server); + when(server.getHypervisorHostname()).thenReturn("test.server.name"); String pfPciId = "0000:08:00.0"; when(port.getProfile()).thenReturn(ImmutableMap.of(HeatBridgeConstants.OS_PCI_SLOT_KEY, pfPciId, HeatBridgeConstants.OS_PHYSICAL_NETWORK_KEY, "physical_network_id")); @@ -448,6 +377,7 @@ public class HeatBridgeImplTest { when(network.getId()).thenReturn("test-network-id"); when(network.getNetworkType()).thenReturn(NetworkType.VLAN); when(network.getProviderSegID()).thenReturn("2345"); + when(network.getProviderPhyNet()).thenReturn("ovsnet"); when(osClient.getPortById("212a203a-9764-4f42-84ea-731536a8f13a")).thenReturn(port); when(osClient.getPortById("387e3904-8948-43d1-8635-b6c2042b54da")).thenReturn(port); diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java index 4755e58582..9195df0955 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayerTest.java @@ -39,12 +39,12 @@ import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; import org.onap.so.bpmn.servicedecomposition.bbobjects.Configuration; import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; import org.onap.so.bpmn.servicedecomposition.bbobjects.GenericVnf; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.L3Network; import org.onap.so.bpmn.servicedecomposition.bbobjects.LineOfBusiness; import org.onap.so.bpmn.servicedecomposition.bbobjects.NetworkPolicy; import org.onap.so.bpmn.servicedecomposition.bbobjects.OwningEntity; import org.onap.so.bpmn.servicedecomposition.bbobjects.Platform; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Pnf; import org.onap.so.bpmn.servicedecomposition.bbobjects.Project; import org.onap.so.bpmn.servicedecomposition.bbobjects.RouteTableReference; import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceInstance; @@ -80,6 +80,7 @@ import org.onap.so.db.catalog.beans.VnfcCustomization; import org.onap.so.serviceinstancebeans.CloudConfiguration; import org.onap.so.serviceinstancebeans.RequestDetails; import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; @@ -87,10 +88,11 @@ public class BBInputSetupMapperLayerTest { BBInputSetupMapperLayer bbInputSetupMapperLayer = new BBInputSetupMapperLayer(); - ObjectMapper mapper = new ObjectMapper(); + ObjectMapper mapper = new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false); private static final String RESOURCE_PATH = "src/test/resources/__files/ExecuteBuildingBlock/"; + @Test public void testMapOrchestrationStatusFromAAI() { OrchestrationStatus expected = OrchestrationStatus.INVENTORIED; diff --git a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java index b623475939..f6615e52c8 100644 --- a/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java +++ b/bpmn/MSOCommonBPMN/src/test/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupUtilsTest.java @@ -24,7 +24,6 @@ package org.onap.so.bpmn.servicedecomposition.tasks; import static com.shazam.shazamcrest.MatcherAssert.assertThat; import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; -import static org.hamcrest.CoreMatchers.containsString; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; @@ -65,12 +64,6 @@ import org.onap.aai.domain.yang.ServiceInstances; import org.onap.aai.domain.yang.VolumeGroup; import org.onap.aai.domain.yang.VolumeGroups; import org.onap.aai.domain.yang.VpnBinding; -import org.onap.so.bpmn.common.InjectionHelper; -import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; -import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; -import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; -import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException; -import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException; import org.onap.aaiclient.client.aai.AAIObjectPlurals; import org.onap.aaiclient.client.aai.AAIObjectType; import org.onap.aaiclient.client.aai.AAIResourcesClient; @@ -78,20 +71,28 @@ 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.graphinventory.entities.uri.Depth; -import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization; +import org.onap.so.bpmn.common.InjectionHelper; +import org.onap.so.bpmn.servicedecomposition.bbobjects.Customer; +import org.onap.so.bpmn.servicedecomposition.bbobjects.ServiceSubscription; +import org.onap.so.bpmn.servicedecomposition.entities.ExecuteBuildingBlock; +import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.MultipleObjectsFoundException; +import org.onap.so.bpmn.servicedecomposition.tasks.exceptions.NoServiceInstanceFoundException; import org.onap.so.db.catalog.beans.CollectionResourceInstanceGroupCustomization; import org.onap.so.db.catalog.beans.Service; +import org.onap.so.db.catalog.beans.VnfcInstanceGroupCustomization; import org.onap.so.db.catalog.client.CatalogDbClient; import org.onap.so.db.request.beans.InfraActiveRequests; import org.onap.so.db.request.beans.RequestProcessingData; import org.onap.so.db.request.client.RequestsDbClient; import org.onap.so.serviceinstancebeans.CloudConfiguration; import org.onap.so.serviceinstancebeans.RequestDetails; +import com.fasterxml.jackson.databind.DeserializationFeature; import com.fasterxml.jackson.databind.ObjectMapper; @RunWith(MockitoJUnitRunner.class) public class BBInputSetupUtilsTest { - protected ObjectMapper mapper = new ObjectMapper(); + protected ObjectMapper mapper = + new ObjectMapper().configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);; private static final String RESOURCE_PATH = "src/test/resources/__files/ExecuteBuildingBlock/"; @InjectMocks diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/aaiL3NetworkInputWithSubnets.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/aaiL3NetworkInputWithSubnets.json index 8e4e3632e9..0360c10d42 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/aaiL3NetworkInputWithSubnets.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/aaiL3NetworkInputWithSubnets.json @@ -71,8 +71,7 @@ }, "aggregateRoutes": { "aggregateRoute": [ - { - "aggRouteId": "routeId", + { "networkStartAddress": "10.80.12.0", "cidrMask": "23", "ipVersion": "4" @@ -80,4 +79,4 @@ ] }, "relationshipList": null -} \ No newline at end of file +} diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/l3NetworkExpectedWithSubnet.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/l3NetworkExpectedWithSubnet.json index f65fe17a2e..7c83df91a2 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/l3NetworkExpectedWithSubnet.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/l3NetworkExpectedWithSubnet.json @@ -53,8 +53,7 @@ } ], "aggregate-routes": [ - { - "route-id": "routeId", + { "network-start-address": "10.80.12.0", "cidr-mask": "23", "ip-version": "4" diff --git a/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java b/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java index 33958a7850..c601b88ae5 100644 --- a/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java +++ b/common/src/main/java/org/onap/so/utils/ExternalTaskServiceUtils.java @@ -78,13 +78,9 @@ public class ExternalTaskServiceUtils { @Scheduled(fixedDelay = 30000) public void checkAllClientsActive() { try { - logger.debug("Executing scheduled task to check and restart external task clients"); // TODO remove - // eventually List inactiveClients = getClients().stream().filter(client -> !client.isActive()).collect(Collectors.toList()); - inactiveClients.forEach(c -> { - logger.debug("External Task Client found to be inactive. Restarting Client."); c.start(); }); } catch (Exception e) { diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectPlurals.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectPlurals.java index 78f8350eff..998aea9065 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectPlurals.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectPlurals.java @@ -76,6 +76,8 @@ public class AAIObjectPlurals implements AAIObjectBase, GraphInventoryObjectPlur new AAIObjectPlurals(AAIObjectType.PNF, AAINamespaceConstants.NETWORK, "/pnfs"); public static final AAIObjectPlurals PROJECT = new AAIObjectPlurals(AAIObjectType.PROJECT, AAINamespaceConstants.BUSINESS, "/projects"); + public static final AAIObjectPlurals VSERVER = + new AAIObjectPlurals(AAIObjectType.VSERVER, AAIObjectType.TENANT.uriTemplate(), "/vservers"); private final String uriTemplate; private final String partialUri; diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectType.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectType.java index 2335a48d43..dae5c62dd3 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectType.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIObjectType.java @@ -20,7 +20,12 @@ package org.onap.aaiclient.client.aai; -import com.google.common.base.CaseFormat; +import java.io.Serializable; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.regex.Pattern; import org.onap.aai.annotations.Metadata; import org.onap.aai.domain.yang.AggregateRoute; import org.onap.aai.domain.yang.AllottedResource; @@ -41,6 +46,7 @@ import org.onap.aai.domain.yang.Image; import org.onap.aai.domain.yang.InstanceGroup; import org.onap.aai.domain.yang.L3Network; import org.onap.aai.domain.yang.LInterface; +import org.onap.aai.domain.yang.LagInterface; import org.onap.aai.domain.yang.LineOfBusiness; import org.onap.aai.domain.yang.LogicalLink; import org.onap.aai.domain.yang.ModelVer; @@ -69,6 +75,7 @@ import org.onap.aai.domain.yang.Tenant; import org.onap.aai.domain.yang.TunnelXconnect; import org.onap.aai.domain.yang.Vce; import org.onap.aai.domain.yang.VfModule; +import org.onap.aai.domain.yang.VlanRange; import org.onap.aai.domain.yang.VlanTag; import org.onap.aai.domain.yang.Vnfc; import org.onap.aai.domain.yang.VolumeGroup; @@ -82,12 +89,7 @@ import org.reflections.Reflections; import org.reflections.scanners.SubTypesScanner; import org.reflections.util.ClasspathHelper; import org.reflections.util.ConfigurationBuilder; -import java.io.Serializable; -import java.net.URL; -import java.util.HashMap; -import java.util.Map; -import java.util.Set; -import java.util.regex.Pattern; +import com.google.common.base.CaseFormat; public class AAIObjectType implements AAIObjectBase, GraphInventoryObjectType, Serializable { @@ -192,6 +194,8 @@ public class AAIObjectType implements AAIObjectBase, GraphInventoryObjectType, S public static final AAIObjectType IMAGE = new AAIObjectType(AAIObjectType.CLOUD_REGION.uriTemplate(), Image.class); public static final AAIObjectType FLAVOR = new AAIObjectType(AAIObjectType.CLOUD_REGION.uriTemplate(), Flavor.class); + + public static final AAIObjectType VLAN_RANGE = new AAIObjectType(CLOUD_REGION.uriTemplate(), VlanRange.class); public static final AAIObjectType UNKNOWN = new AAIObjectType("", "", "unknown") { private static final long serialVersionUID = 9208984071038447607L; @@ -234,6 +238,11 @@ public class AAIObjectType implements AAIObjectBase, GraphInventoryObjectType, S public static final AAIObjectType QUERY_ALLOTTED_RESOURCE = new AAIObjectType(AAIObjectType.SERVICE_INSTANCE.uriTemplate(), "?depth=2", "service-Instance"); + public static final AAIObjectType LAG_INTERFACE = + new AAIObjectType(AAIObjectType.PSERVER.uriTemplate(), LagInterface.class); + + + private final String uriTemplate; private final String parentUri; private final String partialUri; diff --git a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIVersion.java b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIVersion.java index ef43717b4f..4cdf5219f1 100644 --- a/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIVersion.java +++ b/graph-inventory/aai-client/src/main/java/org/onap/aaiclient/client/aai/AAIVersion.java @@ -33,7 +33,9 @@ public enum AAIVersion implements GraphInventoryVersion { V17("v17"), V18("v18"), V19("v19"), - V20("v20"); + V20("v20"), + V21("v21"), + V22("v22"); public static final AAIVersion LATEST = AAIVersion.values()[AAIVersion.values().length - 1]; private final String value; diff --git a/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessVnfc.java b/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessVnfc.java index 954ebdd013..d53de914a3 100644 --- a/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessVnfc.java +++ b/so-simulator/src/main/java/org/onap/so/simulator/actions/aai/ProcessVnfc.java @@ -35,11 +35,12 @@ public class ProcessVnfc extends AbstractTestAction { AAIResourcesClient aaiResourceClient = new AAIResourcesClient(); if (context.getVariable("requestAction").equals("CreateVfModuleInstance") - && context.getVariable("serviceAction").equals("assign")) { + && context.getVariable("serviceAction").equals("assign") + && context.getVariable("vfModuleName").equals("nc_dummy_id")) { - AAIResourceUri vnfcURI = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, "zauk51bfrwl09oam001"); + AAIResourceUri vnfcURI = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, "ssc_server_1"); Vnfc vnfc = new Vnfc(); - vnfc.setVnfcName("zauk51bfrwl09oam001"); + vnfc.setVnfcName("ssc_server_1"); vnfc.setNfcNamingCode("oamfw"); vnfc.setNfcFunction("EPC-OAM-FIREWALL"); vnfc.setProvStatus("PREPROV"); @@ -51,38 +52,20 @@ public class ProcessVnfc extends AbstractTestAction { vnfc.setModelVersionId("9e314c37-2258-4572-a399-c0dd7d5f1aec"); vnfc.setModelCustomizationId("2bd95cd4-d7ff-4af0-985d-2adea0339921"); - if (!aaiResourceClient.exists(vnfcURI)) + if (!aaiResourceClient.exists(vnfcURI)) { + logger.debug("creating VNFC"); aaiResourceClient.create(vnfcURI, vnfc); + + + } else { + aaiResourceClient.get(vnfcURI); + } AAIResourceUri vfModuleURI = AAIUriFactory.createResourceUri(AAIObjectType.VF_MODULE, context.getVariable("vnfId"), context.getVariable("vfModuleId")); - AAIResourceUri pserverURI = AAIUriFactory.createResourceUri(AAIObjectType.PSERVER, "test"); - AAIResourceUri vserverURI = AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, - context.getVariable("cloudOwner"), context.getVariable("cloudRegion"), - context.getVariable("tenant"), "d29f3151-592d-4011-9356-ad047794e236"); - aaiResourceClient.connect(vnfcURI, vserverURI); - aaiResourceClient.connect(vserverURI, pserverURI); + logger.debug("creating VNFC edge to vf module"); aaiResourceClient.connect(vfModuleURI, vnfcURI); - } else if (context.getVariable("requestAction").equals("CreateVfModuleInstance") - && context.getVariable("serviceAction").equals("activate")) { - // For recreate after soft delete - AAIResourceUri vnfcURI = AAIUriFactory.createResourceUri(AAIObjectType.VNFC, "zauk51bfrwl09oam001"); - AAIResourceUri vserverURI = AAIUriFactory.createResourceUri(AAIObjectType.VSERVER, - context.getVariable("cloudOwner"), context.getVariable("cloudRegion"), - context.getVariable("tenant"), "d29f3151-592d-4011-9356-ad047794e236"); - - Relationships relationships = aaiResourceClient.get(vnfcURI).getRelationships().get(); - List uris = relationships.getRelatedUris(AAIObjectType.VSERVER); - if (uris.isEmpty() || uris.size() == 0) { - if (!aaiResourceClient.exists(vserverURI)) { - AAICommonObjectMapperProvider aaiMapper = new AAICommonObjectMapperProvider(); - InputStream vserverFile = - new ClassPathResource("openstack/gr_api/CreateVserver.json").getInputStream(); - Vserver vserver = aaiMapper.getMapper().readValue(vserverFile, Vserver.class); - aaiResourceClient.create(vserverURI, vserver); - } - aaiResourceClient.connect(vnfcURI, vserverURI); - } } + } catch (Exception e) { logger.debug("Exception in ProcessVnfc.doExecute", e); } diff --git a/so-simulator/src/main/resources/openstack/gr_api/GetNeutronNetwork2.json b/so-simulator/src/main/resources/openstack/gr_api/GetNeutronNetwork2.json index 725c896b8d..773400e8f6 100644 --- a/so-simulator/src/main/resources/openstack/gr_api/GetNeutronNetwork2.json +++ b/so-simulator/src/main/resources/openstack/gr_api/GetNeutronNetwork2.json @@ -24,7 +24,8 @@ ], "physical_network": "sriovnet1", "pci_slot": "0000:5e:05.6", - "pci_vendor_info": "8086:154c" + "pci_vendor_info": "8086:154c", + "host_id": "50197c55fc934e7b3947e17db762f0839320f94983df774d84991ad2" }, "fixed_ips": [ { -- cgit 1.2.3-korg