From: Stephen Kitt Date: Thu, 10 Sep 2015 12:40:14 +0000 (+0200) Subject: Sonar clean-ups X-Git-Tag: release/beryllium-sr2~434^2 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=bdf367e4b7a7dc7ff16d5860ffb5f6771eed4cea;p=netvirt.git Sonar clean-ups Starting from source files containing collapsible ifs: * merge collapsible ifs; * remove unused parameters; * remove unused exceptions; * remove unused fields; * rename shadowing variables; * add private constructors for utility classes; * use more specific exceptions than RuntimeException; * clean up "if () return true; else return false;"; * some Java 7 <> operators; * add missing "static" for constants; * remove unused private methods (except in OF13Provider); * move some inline comments above the corresponding source line; * used boolean instead of Boolean for Map::contains(); * replace foreach-style constructs examining the first element only with explicit "if (...hasNext()) ... = ... next()"; * prohibit overriding methods called from constructors; * remove useless casts. Reverse the order of node augmentation handling in SouthboundUtil so that the augmentation case can actually trigger. Change-Id: Ie4fc662bdcc0e2133fdd4f57b783723466b1f2a9 Signed-off-by: Stephen Kitt --- diff --git a/northbound/src/main/java/org/opendaylight/ovsdb/northbound/OvsdbRow.java b/northbound/src/main/java/org/opendaylight/ovsdb/northbound/OvsdbRow.java index 977bbbd972..ac954bf9ef 100644 --- a/northbound/src/main/java/org/opendaylight/ovsdb/northbound/OvsdbRow.java +++ b/northbound/src/main/java/org/opendaylight/ovsdb/northbound/OvsdbRow.java @@ -16,12 +16,14 @@ import org.opendaylight.ovsdb.lib.OvsdbClient; import org.opendaylight.ovsdb.lib.notation.Row; import org.opendaylight.ovsdb.lib.schema.DatabaseSchema; import org.opendaylight.ovsdb.lib.schema.GenericTableSchema; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; -import com.fasterxml.jackson.core.JsonParseException; import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.node.ObjectNode; public class OvsdbRow { + private static final Logger LOG = LoggerFactory.getLogger(OvsdbRow.class); private static final String PARENTUUID = "parent_uuid"; private static final String PARENTTABLE = "parent_table"; private static final String PARENTCOLUMN = "parent_column"; @@ -70,21 +72,21 @@ public class OvsdbRow { if (rowNode == null) { return null; } - for(Iterator fieldNames = rowNode.fieldNames(); fieldNames.hasNext();) { + Iterator fieldNames = rowNode.fieldNames(); + if (fieldNames.hasNext()) { String tableName = fieldNames.next(); - Row row = null; try { - row = getRow(client, dbName, tableName, rowNode.get(tableName)); + Row row = getRow(client, dbName, tableName, rowNode.get(tableName)); + return new OvsdbRow(parentTable, parentUuid, parentColumn, tableName, row); } catch (InterruptedException | ExecutionException | IOException e) { - e.printStackTrace(); + LOG.error("Error retrieving the row for {}", tableName, e); return null; } - return new OvsdbRow(parentTable, parentUuid, parentColumn, tableName, row); } return null; } - public static Row getRow(OvsdbClient client, String dbName, String tableName, JsonNode rowJson) throws InterruptedException, ExecutionException, JsonParseException, IOException { + public static Row getRow(OvsdbClient client, String dbName, String tableName, JsonNode rowJson) throws InterruptedException, ExecutionException, IOException { DatabaseSchema dbSchema = client.getSchema(dbName).get(); GenericTableSchema schema = dbSchema.table(tableName, GenericTableSchema.class); return schema.createRow((ObjectNode)rowJson); diff --git a/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/OF13Provider.java b/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/OF13Provider.java index b8a096389b..12879dadda 100644 --- a/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/OF13Provider.java +++ b/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/OF13Provider.java @@ -1643,29 +1643,27 @@ public class OF13Provider implements ConfigInterface, NetworkingProvider { } } LOG.debug("createOutputGroupInstructions: addNew {}", addNew); - if (addNew) { + if (addNew && !buckets.getBucket().isEmpty()) { /* the new output action is not in the bucket, add to bucket */ - if (!buckets.getBucket().isEmpty()) { - Bucket bucket = buckets.getBucket().get(0); - List bucketActionList = Lists.newArrayList(); - bucketActionList.addAll(bucket.getAction()); - /* set order for new action and add to action list */ - ab.setOrder(bucketActionList.size()); - ab.setKey(new ActionKey(bucketActionList.size())); - bucketActionList.add(ab.build()); - - /* set bucket and buckets list. Reset groupBuilder with new buckets.*/ - BucketsBuilder bucketsBuilder = new BucketsBuilder(); - List bucketList = Lists.newArrayList(); - BucketBuilder bucketBuilder = new BucketBuilder(); - bucketBuilder.setBucketId(new BucketId((long) 1)); - bucketBuilder.setKey(new BucketKey(new BucketId((long) 1))); - bucketBuilder.setAction(bucketActionList); - bucketList.add(bucketBuilder.build()); - bucketsBuilder.setBucket(bucketList); - groupBuilder.setBuckets(bucketsBuilder.build()); - LOG.debug("createOutputGroupInstructions: bucketList {}", bucketList); - } + Bucket bucket = buckets.getBucket().get(0); + List bucketActionList = Lists.newArrayList(); + bucketActionList.addAll(bucket.getAction()); + /* set order for new action and add to action list */ + ab.setOrder(bucketActionList.size()); + ab.setKey(new ActionKey(bucketActionList.size())); + bucketActionList.add(ab.build()); + + /* set bucket and buckets list. Reset groupBuilder with new buckets.*/ + BucketsBuilder bucketsBuilder = new BucketsBuilder(); + List bucketList = Lists.newArrayList(); + BucketBuilder bucketBuilder = new BucketBuilder(); + bucketBuilder.setBucketId(new BucketId((long) 1)); + bucketBuilder.setKey(new BucketKey(new BucketId((long) 1))); + bucketBuilder.setAction(bucketActionList); + bucketList.add(bucketBuilder.build()); + bucketsBuilder.setBucket(bucketList); + groupBuilder.setBuckets(bucketsBuilder.build()); + LOG.debug("createOutputGroupInstructions: bucketList {}", bucketList); } } else { /* create group */ diff --git a/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/PipelineOrchestratorImpl.java b/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/PipelineOrchestratorImpl.java index 87b3dee1d3..edea48c26c 100644 --- a/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/PipelineOrchestratorImpl.java +++ b/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/PipelineOrchestratorImpl.java @@ -83,7 +83,7 @@ public class PipelineOrchestratorImpl implements ConfigInterface, NodeCacheListe return serviceRegistry.get(service); } - public void start() { + public final void start() { eventHandler.submit(new Runnable() { @Override public void run() { @@ -93,11 +93,8 @@ public class PipelineOrchestratorImpl implements ConfigInterface, NodeCacheListe LOG.info(">>>>> dequeue: {}", node); for (Service service : staticPipeline) { AbstractServiceInstance serviceInstance = getServiceInstance(service); - //LOG.info("pipeline: {} - {}", service, serviceInstance); - if (serviceInstance != null) { - if (southbound.getBridge(node) != null) { - serviceInstance.programDefaultPipelineRule(node); - } + if (serviceInstance != null && southbound.getBridge(node) != null) { + serviceInstance.programDefaultPipelineRule(node); } } } diff --git a/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/arp/GatewayMacResolverService.java b/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/arp/GatewayMacResolverService.java index d6ce3d8b7c..7c2cfbebae 100644 --- a/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/arp/GatewayMacResolverService.java +++ b/openstack/net-virt-providers/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/providers/openflow13/services/arp/GatewayMacResolverService.java @@ -21,8 +21,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicLong; -import javax.annotation.Nullable; - import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.ProviderContext; import org.opendaylight.openflowplugin.api.OFConstants; import org.opendaylight.ovsdb.openstack.netvirt.api.GatewayMacResolver; @@ -30,7 +28,6 @@ import org.opendaylight.ovsdb.openstack.netvirt.providers.ConfigInterface; import org.opendaylight.ovsdb.openstack.netvirt.providers.NetvirtProvidersProvider; import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.AbstractServiceInstance; import org.opendaylight.ovsdb.openstack.netvirt.providers.openflow13.Service; -import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.IpAddress; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev100924.Ipv4Address; import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev100924.MacAddress; import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.FlowCapableNode; @@ -100,11 +97,11 @@ public class GatewayMacResolverService extends AbstractServiceInstance private SalFlowService flowService; private final AtomicLong flowCookie = new AtomicLong(); private final ConcurrentMap gatewayToArpMetadataMap = - new ConcurrentHashMap(); - private final int ARP_WATCH_BROTHERS = 10; - private final int WAIT_CYCLES = 3; - private final int PER_CYCLE_WAIT_DURATION = 1000; - private final int REFRESH_INTERVAL = 10; + new ConcurrentHashMap<>(); + private static final int ARP_WATCH_BROTHERS = 10; + private static final int WAIT_CYCLES = 3; + private static final int PER_CYCLE_WAIT_DURATION = 1000; + private static final int REFRESH_INTERVAL = 10; private final ListeningExecutorService arpWatcherWall = MoreExecutors.listeningDecorator(Executors.newFixedThreadPool(ARP_WATCH_BROTHERS)); private final ScheduledExecutorService gatewayMacRefresherPool = Executors.newScheduledThreadPool(1); private final ScheduledExecutorService refreshRequester = Executors.newSingleThreadScheduledExecutor(); @@ -183,7 +180,6 @@ public class GatewayMacResolverService extends AbstractServiceInstance * @param sourceMacAddress Source Mac address for the ARP request packet * @param periodicRefresh Enable/Disable periodic refresh of the Gateway Mac address * NOTE:Periodic refresh is not supported yet. - * @param gatewayIp Resolve MAC address of this Gateway Ip * @return Future object */ @Override @@ -305,13 +301,6 @@ public class GatewayMacResolverService extends AbstractServiceInstance }); } - private static @Nullable Ipv4Address getIPv4Addresses(IpAddress ipAddress) { - if (ipAddress.getIpv4Address() == null) { - return null; - } - return ipAddress.getIpv4Address(); - } - private Flow createArpReplyToControllerFlow(final ArpMessageAddress senderAddress, final Ipv4Address ipForRequestedMac) { checkNotNull(senderAddress); checkNotNull(ipForRequestedMac); @@ -330,11 +319,11 @@ public class GatewayMacResolverService extends AbstractServiceInstance arpFlow.setMatch(match); arpFlow.setInstructions(new InstructionsBuilder().setInstruction( ImmutableList.of(SEND_TO_CONTROLLER_INSTRUCTION)).build()); - arpFlow.setId(createFlowId(senderAddress, ipForRequestedMac)); + arpFlow.setId(createFlowId(ipForRequestedMac)); return arpFlow.build(); } - private FlowId createFlowId(ArpMessageAddress senderAddress, Ipv4Address ipForRequestedMac) { + private FlowId createFlowId(Ipv4Address ipForRequestedMac) { String flowId = ARP_REPLY_TO_CONTROLLER_FLOW_NAME + "|" + ipForRequestedMac.getValue(); return new FlowId(flowId); } diff --git a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/SouthboundHandler.java b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/SouthboundHandler.java index 8f21cb8902..8eaed984f1 100644 --- a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/SouthboundHandler.java +++ b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/SouthboundHandler.java @@ -295,10 +295,8 @@ public class SouthboundHandler extends AbstractHandler private void processPortUpdate(Node node, OvsdbTerminationPointAugmentation port) { LOG.debug("processPortUpdate <{}> <{}>", node, port); NeutronNetwork network = tenantNetworkManager.getTenantNetwork(port); - if (network != null ){ - if(!network.getRouterExternal()){ - this.handleInterfaceUpdate(node, port); - } + if (network != null && !network.getRouterExternal()) { + this.handleInterfaceUpdate(node, port); } } diff --git a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/BridgeConfigurationManagerImpl.java b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/BridgeConfigurationManagerImpl.java index a9e84bad2d..bc40093955 100644 --- a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/BridgeConfigurationManagerImpl.java +++ b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/BridgeConfigurationManagerImpl.java @@ -10,7 +10,6 @@ package org.opendaylight.ovsdb.openstack.netvirt.impl; import org.opendaylight.neutron.spi.NeutronNetwork; import org.opendaylight.ovsdb.openstack.netvirt.ConfigInterface; -import org.opendaylight.ovsdb.openstack.netvirt.MdsalHelper; import org.opendaylight.ovsdb.openstack.netvirt.NetworkHandler; import org.opendaylight.ovsdb.openstack.netvirt.api.BridgeConfigurationManager; import org.opendaylight.ovsdb.openstack.netvirt.api.ConfigurationService; @@ -127,19 +126,7 @@ public class BridgeConfigurationManagerImpl implements BridgeConfigurationManage Preconditions.checkNotNull(portNameExt); if (southbound.isBridgeOnOvsdbNode(ovsdbNode, brExt)) { - //this would look better if used a method like isNetworkPatchCreated() - if (isPortOnBridge(bridgeNode, portNameInt)) { - Node extBridgeNode = southbound.readBridgeNode(ovsdbNode, brExt); - if (isPortOnBridge(extBridgeNode, portNameExt)) { - ready = true; - } else { - LOG.trace("isNodeL3Ready: node: {}, {} missing", - bridgeNode, portNameExt); - } - } else { - LOG.trace("isNodeL3Ready: node: {}, {} missing", - bridgeNode, portNameInt); - } + ready = isNetworkPatchCreated(bridgeNode, southbound.readBridgeNode(ovsdbNode, brExt)); } else { LOG.trace("isNodeL3Ready: node: {}, {} missing", bridgeNode, brExt); @@ -261,7 +248,7 @@ public class BridgeConfigurationManagerImpl implements BridgeConfigurationManage /** * Returns true if a patch port exists between the Integration Bridge and Network Bridge */ - private boolean isNetworkPatchCreated(Node node, Node intBridge, Node netBridge) { + private boolean isNetworkPatchCreated(Node intBridge, Node netBridge) { Preconditions.checkNotNull(configurationService); boolean isPatchCreated = false; @@ -280,7 +267,7 @@ public class BridgeConfigurationManagerImpl implements BridgeConfigurationManage /** * Creates the Integration Bridge */ - private boolean createIntegrationBridge(Node ovsdbNode) throws Exception { + private boolean createIntegrationBridge(Node ovsdbNode) { Preconditions.checkNotNull(configurationService); if (!addBridge(ovsdbNode, configurationService.getIntegrationBridgeName())) { @@ -290,7 +277,7 @@ public class BridgeConfigurationManagerImpl implements BridgeConfigurationManage return true; } - private boolean createExternalBridge(Node ovsdbNode) throws Exception { + private boolean createExternalBridge(Node ovsdbNode) { Preconditions.checkNotNull(configurationService); if (!addBridge(ovsdbNode, configurationService.getExternalBridgeName())) { @@ -355,7 +342,7 @@ public class BridgeConfigurationManagerImpl implements BridgeConfigurationManage Interface br-int type: internal */ - private boolean createBridges(Node bridgeNode, Node ovsdbNode, NeutronNetwork network) throws Exception { + private boolean createBridges(Node bridgeNode, Node ovsdbNode, NeutronNetwork network) { Preconditions.checkNotNull(configurationService); Preconditions.checkNotNull(networkingProviderManager); @@ -408,7 +395,7 @@ public class BridgeConfigurationManagerImpl implements BridgeConfigurationManage /** * Add a Port to a Bridge */ - private boolean addPortToBridge (Node node, String bridgeName, String portName) throws Exception { + private boolean addPortToBridge (Node node, String bridgeName, String portName) { boolean rv = true; if (southbound.extractTerminationPointAugmentation(node, portName) == null) { @@ -432,7 +419,7 @@ public class BridgeConfigurationManagerImpl implements BridgeConfigurationManage /** * Add a Patch Port to a Bridge */ - private boolean addPatchPort (Node node, String bridgeName, String portName, String peerPortName) throws Exception { + private boolean addPatchPort (Node node, String bridgeName, String portName, String peerPortName) { boolean rv = true; if (southbound.extractTerminationPointAugmentation(node, portName) == null) { @@ -456,7 +443,7 @@ public class BridgeConfigurationManagerImpl implements BridgeConfigurationManage /** * Add Bridge to a Node */ - private boolean addBridge(Node ovsdbNode, String bridgeName) throws Exception { + private boolean addBridge(Node ovsdbNode, String bridgeName) { boolean rv = true; if ((!southbound.isBridgeOnOvsdbNode(ovsdbNode, bridgeName)) || (southbound.getBridgeFromConfig(ovsdbNode, bridgeName) == null)) { @@ -466,13 +453,10 @@ public class BridgeConfigurationManagerImpl implements BridgeConfigurationManage } private String getControllerIPAddress() { - InetAddress controllerIP = null; - String addressString = ConfigProperties.getProperty(this.getClass(), "ovsdb.controller.address"); if (addressString != null) { try { - controllerIP = InetAddress.getByName(addressString); - if (controllerIP != null) { + if (InetAddress.getByName(addressString) != null) { return addressString; } } catch (UnknownHostException e) { @@ -483,8 +467,7 @@ public class BridgeConfigurationManagerImpl implements BridgeConfigurationManage addressString = ConfigProperties.getProperty(this.getClass(), "of.address"); if (addressString != null) { try { - controllerIP = InetAddress.getByName(addressString); - if (controllerIP != null) { + if (InetAddress.getByName(addressString) != null) { return addressString; } } catch (UnknownHostException e) { diff --git a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/NeutronL3Adapter.java b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/NeutronL3Adapter.java index f5ef9be5de..b679902d37 100644 --- a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/NeutronL3Adapter.java +++ b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/NeutronL3Adapter.java @@ -73,12 +73,17 @@ public class NeutronL3Adapter implements ConfigInterface { private volatile GatewayMacResolver gatewayMacResolver; private class FloatIpData { - private final Long dpid; // br-int of node where floating ip is associated with tenant port - private final Long ofPort; // patch port in br-int used to reach br-ex - private final String segId; // segmentation id of the net where fixed ip is instantiated - private final String macAddress; // mac address assigned to neutron port of floating ip + // br-int of node where floating ip is associated with tenant port + private final Long dpid; + // patch port in br-int used to reach br-ex + private final Long ofPort; + // segmentation id of the net where fixed ip is instantiated + private final String segId; + // mac address assigned to neutron port of floating ip + private final String macAddress; private final String floatingIpAddress; - private final String fixedIpAddress; // ip address given to tenant vm + // ip address given to tenant vm + private final String fixedIpAddress; private final String neutronRouterMac; FloatIpData(final Long dpid, final Long ofPort, final String segId, final String macAddress, @@ -212,14 +217,12 @@ public class NeutronL3Adapter implements ConfigInterface { }else{ NeutronNetwork externalNetwork = neutronNetworkCache.getNetwork(neutronPort.getNetworkUUID()); - if(externalNetwork != null){ - if(externalNetwork.isRouterExternal()){ - final NeutronSubnet externalSubnet = getExternalNetworkSubnet(neutronPort); - // TODO support IPv6 - if (externalSubnet != null && + if (externalNetwork != null && externalNetwork.isRouterExternal()) { + final NeutronSubnet externalSubnet = getExternalNetworkSubnet(neutronPort); + // TODO support IPv6 + if (externalSubnet != null && externalSubnet.getIpVersion() == 4) { - gatewayMacResolver.stopPeriodicRefresh(new Ipv4Address(externalSubnet.getGatewayIP())); - } + gatewayMacResolver.stopPeriodicRefresh(new Ipv4Address(externalSubnet.getGatewayIP())); } } } @@ -234,7 +237,8 @@ public class NeutronL3Adapter implements ConfigInterface { for (Neutron_IPs neutronIP : neutronPort.getFixedIPs()) { NeutronRouter_Interface neutronRouterInterface = new NeutronRouter_Interface(neutronIP.getSubnetUUID(), neutronPort.getPortUUID()); - neutronRouterInterface.setID(neutronIP.getSubnetUUID()); // id of router interface to be same as subnet + // id of router interface to be same as subnet + neutronRouterInterface.setID(neutronIP.getSubnetUUID()); neutronRouterInterface.setTenantID(neutronPort.getTenantID()); this.handleNeutronRouterInterfaceEvent(null /*neutronRouter*/, neutronRouterInterface, action); @@ -245,14 +249,12 @@ public class NeutronL3Adapter implements ConfigInterface { // need to do this check here because a router interface is not added to a node until tenant becomes needed // there. // - if (!isDelete) { - if (neutronPort.getFixedIPs() != null) { - for (Neutron_IPs neutronIP : neutronPort.getFixedIPs()) { - NeutronRouter_Interface neutronRouterInterface = + if (!isDelete && neutronPort.getFixedIPs() != null) { + for (Neutron_IPs neutronIP : neutronPort.getFixedIPs()) { + NeutronRouter_Interface neutronRouterInterface = subnetIdToRouterInterfaceCache.get(neutronIP.getSubnetUUID()); - if (neutronRouterInterface != null) { - this.handleNeutronRouterInterfaceEvent(null /*neutronRouter*/, neutronRouterInterface, action); - } + if (neutronRouterInterface != null) { + this.handleNeutronRouterInterfaceEvent(null /*neutronRouter*/, neutronRouterInterface, action); } } } @@ -345,7 +347,8 @@ public class NeutronL3Adapter implements ConfigInterface { // this.programFlowsForFloatingIP(neutronFloatingIP, action == Action.DELETE); if (action != Action.DELETE) { - programFlowsForFloatingIPArpAdd(neutronFloatingIP); // must be first, as it updates floatIpDataMapCache + // must be first, as it updates floatIpDataMapCache + programFlowsForFloatingIPArpAdd(neutronFloatingIP); programFlowsForFloatingIPInbound(neutronFloatingIP, Action.ADD); programFlowsForFloatingIPOutbound(neutronFloatingIP, Action.ADD); @@ -353,7 +356,8 @@ public class NeutronL3Adapter implements ConfigInterface { programFlowsForFloatingIPOutbound(neutronFloatingIP, Action.DELETE); programFlowsForFloatingIPInbound(neutronFloatingIP, Action.DELETE); - programFlowsForFloatingIPArpDelete(neutronFloatingIP.getID()); // must be last, as it updates floatIpDataMapCache + // must be last, as it updates floatIpDataMapCache + programFlowsForFloatingIPArpDelete(neutronFloatingIP.getID()); } } @@ -654,14 +658,14 @@ public class NeutronL3Adapter implements ConfigInterface { // will look at desired action for node. final String cacheKey = node.getNodeId().getValue() + ":" + providerSegmentationId + ":" + ipStr; - final Boolean isProgrammed = l3ForwardingCache.contains(cacheKey); + final boolean isProgrammed = l3ForwardingCache.contains(cacheKey); - if (actionForNode == Action.DELETE && isProgrammed == Boolean.FALSE) { + if (actionForNode == Action.DELETE && !isProgrammed) { LOG.trace("programL3ForwardingStage1 for node {} providerId {} mac {} ip {} action {} is already done", node.getNodeId().getValue(), providerSegmentationId, macAddress, ipStr, actionForNode); return; } - if (actionForNode == Action.ADD && isProgrammed == Boolean.TRUE) { + if (actionForNode == Action.ADD && isProgrammed) { LOG.trace("programL3ForwardingStage1 for node {} providerId {} mac {} ip {} action {} is already done", node.getNodeId().getValue(), providerSegmentationId, macAddress, ipStr, actionForNode); return; @@ -914,16 +918,16 @@ public class NeutronL3Adapter implements ConfigInterface { final String cacheKey = node.getNodeId().getValue() + ":" + sourceSegmentationId + ":" + destinationSegmentationId + ":" + ipStr + "/" + Integer.toString(mask); - final Boolean isProgrammed = routerInterfacesCache.contains(cacheKey); + final boolean isProgrammed = routerInterfacesCache.contains(cacheKey); - if (actionForNode == Action.DELETE && isProgrammed == Boolean.FALSE) { + if (actionForNode == Action.DELETE && !isProgrammed) { LOG.trace("programRouterInterfaceStage1 for node {} sourceSegId {} destSegId {} mac {} ip {} mask {}" + " action {} is already done", node.getNodeId().getValue(), sourceSegmentationId, destinationSegmentationId, macAddress, ipStr, mask, actionForNode); return; } - if (actionForNode == Action.ADD && isProgrammed == Boolean.TRUE) { + if (actionForNode == Action.ADD && isProgrammed) { LOG.trace("programRouterInterfaceStage1 for node {} sourceSegId {} destSegId {} mac {} ip {} mask {}" + " action {} is already done", node.getNodeId().getValue(), sourceSegmentationId, destinationSegmentationId, @@ -981,14 +985,14 @@ public class NeutronL3Adapter implements ConfigInterface { // will look at desired action for node. // final String cacheKey = dpid + ":" + segOrOfPort + ":" + ipStr; - final Boolean isProgrammed = staticArpEntryCache.contains(cacheKey); + final boolean isProgrammed = staticArpEntryCache.contains(cacheKey); - if (action == Action.DELETE && isProgrammed == Boolean.FALSE) { + if (action == Action.DELETE && !isProgrammed) { LOG.trace("programStaticArpStage1 dpid {} segOrOfPort {} mac {} ip {} action {} is already done", dpid, segOrOfPort, macAddress, ipStr, action); return true; } - if (action == Action.ADD && isProgrammed == Boolean.TRUE) { + if (action == Action.ADD && isProgrammed) { LOG.trace("programStaticArpStage1 dpid {} segOrOfPort {} mac {} ip {} action {} is already done", dpid, segOrOfPort, macAddress, ipStr, action); return true; @@ -1041,15 +1045,15 @@ public class NeutronL3Adapter implements ConfigInterface { // will look at desired action for node. // final String cacheKey = dpid + ":" + inboundOFPort + ":" + providerSegmentationId + ":" + matchAddress; - final Boolean isProgrammed = inboundIpRewriteCache.contains(cacheKey); + final boolean isProgrammed = inboundIpRewriteCache.contains(cacheKey); - if (action == Action.DELETE && isProgrammed == Boolean.FALSE) { + if (action == Action.DELETE && !isProgrammed) { LOG.trace("programInboundIpRewriteStage1 dpid {} OFPort {} seg {} matchAddress {} rewriteAddress {}" + " action {} is already done", dpid, inboundOFPort, providerSegmentationId, matchAddress, rewriteAddress, action); return true; } - if (action == Action.ADD && isProgrammed == Boolean.TRUE) { + if (action == Action.ADD && isProgrammed) { LOG.trace("programInboundIpRewriteStage1 dpid {} OFPort {} seg {} matchAddress {} rewriteAddress {}" + " action is already done", dpid, inboundOFPort, providerSegmentationId, matchAddress, rewriteAddress, action); @@ -1106,14 +1110,14 @@ public class NeutronL3Adapter implements ConfigInterface { // will look at desired action for node. // final String cacheKey = node.getNodeId().getValue() + ":" + providerSegmentationId + ":" + cidr; - final Boolean isProgrammed = outboundIpRewriteExclusionCache.contains(cacheKey); + final boolean isProgrammed = outboundIpRewriteExclusionCache.contains(cacheKey); - if (actionForRewriteExclusion == Action.DELETE && isProgrammed == Boolean.FALSE) { + if (actionForRewriteExclusion == Action.DELETE && !isProgrammed) { LOG.trace("programIpRewriteExclusionStage1 node {} providerId {} cidr {} action {} is already done", node.getNodeId().getValue(), providerSegmentationId, cidr, actionForRewriteExclusion); return; } - if (actionForRewriteExclusion == Action.ADD && isProgrammed == Boolean.TRUE) { + if (actionForRewriteExclusion == Action.ADD && isProgrammed) { LOG.trace("programIpRewriteExclusionStage1 node {} providerId {} cidr {} action {} is already done", node.getNodeId().getValue(), providerSegmentationId, cidr, actionForRewriteExclusion); return; @@ -1153,15 +1157,15 @@ public class NeutronL3Adapter implements ConfigInterface { // will look at desired action for node. // final String cacheKey = fid.dpid + ":" + fid.segId + ":" + fid.fixedIpAddress; - final Boolean isProgrammed = outboundIpRewriteCache.contains(cacheKey); + final boolean isProgrammed = outboundIpRewriteCache.contains(cacheKey); - if (action == Action.DELETE && isProgrammed == Boolean.FALSE) { + if (action == Action.DELETE && !isProgrammed) { LOG.trace("programOutboundIpRewriteStage1 dpid {} seg {} fixedIpAddress {} floatIp {} action {} " + "is already done", fid.dpid, fid.segId, fid.fixedIpAddress, fid.floatingIpAddress, action); return; } - if (action == Action.ADD && isProgrammed == Boolean.TRUE) { + if (action == Action.ADD && isProgrammed) { LOG.trace("programOutboundIpRewriteStage1 dpid {} seg {} fixedIpAddress {} floatIp {} action {} " + "is already done", fid.dpid, fid.segId, fid.fixedIpAddress, fid.floatingIpAddress, action); diff --git a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/SecurityServicesImpl.java b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/SecurityServicesImpl.java index 284074d936..efad7fca4d 100644 --- a/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/SecurityServicesImpl.java +++ b/openstack/net-virt/src/main/java/org/opendaylight/ovsdb/openstack/netvirt/impl/SecurityServicesImpl.java @@ -197,18 +197,16 @@ public class SecurityServicesImpl implements ConfigInterface, SecurityServicesMa Constants.EXTERNAL_ID_INTERFACE_ID); if (null != portId) { NeutronPort port = neutronPortCache.getPort(portId); - if (null != port) { - if (!(port.getID().equals(neutronPort.getID())) - && port.getDeviceOwner().contains("compute")) { - List portFixedIp = port.getFixedIPs(); - if (null == portFixedIp || portFixedIp.isEmpty()) { - return false; - } - if (portFixedIp.iterator().next().getSubnetUUID() - .equals(neutronPort.getFixedIPs().iterator().next().getSubnetUUID())) { - LOG.trace("isLastPortinSubnet: Port is not the only port."); - return false; - } + if (null != port && !(port.getID().equals(neutronPort.getID())) + && port.getDeviceOwner().contains("compute")) { + List portFixedIp = port.getFixedIPs(); + if (null == portFixedIp || portFixedIp.isEmpty()) { + return false; + } + if (portFixedIp.iterator().next().getSubnetUUID() + .equals(neutronPort.getFixedIPs().iterator().next().getSubnetUUID())) { + LOG.trace("isLastPortinSubnet: Port is not the only port."); + return false; } } } @@ -231,14 +229,13 @@ public class SecurityServicesImpl implements ConfigInterface, SecurityServicesMa for (TerminationPoint tp : terminationPoints) { OvsdbTerminationPointAugmentation ovsdbTerminationPointAugmentation = tp.getAugmentation(OvsdbTerminationPointAugmentation.class); - if (null != ovsdbTerminationPointAugmentation) { - if (!(ovsdbTerminationPointAugmentation.getName().equals(Constants.INTEGRATION_BRIDGE)) - && !(terminationPointAugmentation.getInterfaceUuid() - .equals(ovsdbTerminationPointAugmentation.getInterfaceUuid()))) { - LOG.debug("isLastPortinBridge: it the last port in bridge {}", - terminationPointAugmentation.getName()); - return false; - } + if (null != ovsdbTerminationPointAugmentation + && !(ovsdbTerminationPointAugmentation.getName().equals(Constants.INTEGRATION_BRIDGE)) + && !(terminationPointAugmentation.getInterfaceUuid() + .equals(ovsdbTerminationPointAugmentation.getInterfaceUuid()))) { + LOG.debug("isLastPortinBridge: it the last port in bridge {}", + terminationPointAugmentation.getName()); + return false; } } }