From 63606eb03d8f955ac433ac3f001da076e83f5034 Mon Sep 17 00:00:00 2001 From: "Boslet, Cory" Date: Tue, 7 Jul 2020 11:45:27 -0400 Subject: Added checks on the cloud owner to determine if Added checks on the cloud owner to determine if vlans should be done, added null pointer checks, fixed and add unit test. Removed autowiring of client and removed logging Changed the default value of the cloud owner. Updated unit test to mock the new env property call Removed to make HeatBridgeImpl a spring class. Issue-ID: SO-3033 Signed-off-by: Benjamin, Max (mb388a) Change-Id: I31cfa83bc74fe9786f220d952a78e5bf4f04bb3e --- .../so/adapters/tasks/inventory/CreateAAIInventory.java | 3 ++- .../main/java/org/onap/so/heatbridge/HeatBridgeApi.java | 4 +++- .../main/java/org/onap/so/heatbridge/HeatBridgeImpl.java | 15 ++++++++++++--- 3 files changed, 17 insertions(+), 5 deletions(-) (limited to 'adapters/mso-openstack-adapters/src/main/java/org/onap') 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 eab0451aa6..df4229c985 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 @@ -108,7 +108,8 @@ public class CreateAAIInventory { if (!CollectionUtils.isEmpty(oobMgtNetNames)) { oobMgtNetIds = heatBridgeClient.extractNetworkIds(oobMgtNetNames); } - heatBridgeClient.buildAddVserverLInterfacesToAaiAction(stackResources, oobMgtNetIds); + heatBridgeClient.buildAddVserverLInterfacesToAaiAction(stackResources, oobMgtNetIds, + cloudInformation.getOwner()); logger.debug( "Successfully queried neutron resources and built AAI actions to add l-interfaces to vservers."); 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 d0ca87df95..9c098863f2 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 @@ -134,8 +134,10 @@ public interface HeatBridgeApi { * * @param stackResources Openstack Heat stack resource list * @param oobMgtNetIds List of OOB network IDs list + * @param cloudOwner */ - void buildAddVserverLInterfacesToAaiAction(List stackResources, List oobMgtNetIds); + void buildAddVserverLInterfacesToAaiAction(List stackResources, List oobMgtNetIds, + String cloudOwner); /** * 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 53736e912f..f37555392a 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 @@ -79,6 +79,7 @@ import org.onap.so.heatbridge.openstack.factory.OpenstackClientFactoryImpl; import org.onap.so.heatbridge.utils.HeatBridgeUtils; import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; +import org.onap.so.spring.SpringContextHelper; import org.openstack4j.model.compute.Server; import org.openstack4j.model.heat.Resource; import org.openstack4j.model.network.IP; @@ -87,6 +88,7 @@ import org.openstack4j.model.network.NetworkType; import org.openstack4j.model.network.Port; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.core.env.Environment; import com.google.common.base.Preconditions; import com.google.common.base.Strings; import com.google.common.collect.ImmutableMap; @@ -109,6 +111,8 @@ public class HeatBridgeImpl implements HeatBridgeApi { private String tenantId; 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, @@ -124,7 +128,10 @@ public class HeatBridgeImpl implements HeatBridgeApi { this.regionId = regionId; this.tenantId = tenantId; this.resourcesClient = resourcesClient; - this.transaction = resourcesClient.beginSingleTransaction(); + if (resourcesClient != null) + this.transaction = resourcesClient.beginSingleTransaction(); + if (SpringContextHelper.getAppContext() != null) + this.env = SpringContextHelper.getAppContext().getEnvironment(); } public HeatBridgeImpl() { @@ -253,7 +260,7 @@ public class HeatBridgeImpl implements HeatBridgeApi { @Override public void buildAddVserverLInterfacesToAaiAction(final List stackResources, - final List oobMgtNetIds) { + final List oobMgtNetIds, String cloudOwner) { Objects.requireNonNull(osClient, ERR_MSG_NULL_OS_CLIENT); List portIds = extractStackResourceIdsByResourceType(stackResources, HeatBridgeConstants.OS_PORT_RESOURCE_TYPE); @@ -283,7 +290,9 @@ public class HeatBridgeImpl implements HeatBridgeApi { } lIf.setL2Multicasting(isL2Multicast); updateLInterfaceIps(port, lIf); - updateLInterfaceVlan(port, lIf); + if (cloudOwner.equals(env.getProperty("mso.cloudOwner.included", ""))) { + updateLInterfaceVlan(port, lIf); + } // Update l-interface to the vserver transaction.create(AAIUriFactory.createResourceUri(AAIObjectType.L_INTERFACE, cloudOwner, cloudRegionId, -- cgit 1.2.3-korg