handleTunnelUnknownUcastFloodOut(dpid, TABLE_1_ISOLATE_TENANT, TABLE_2_LOCAL_FORWARD, segmentationId, localPort, true);
}
- private void removeLocalBridgeRules(Node node, Long dpid, String segmentationId, String attachedMac, long localPort) {
+ private void removeLocalBridgeRules(Node node, Long dpid, String segmentationId, String attachedMac, long localPort, boolean isMigratedPort) {
/*
* Table(0) Rule #3
* ----------------
* table=2,tun_id=0x5,dl_dst=00:00:00:00:00:01 actions=output:2
*/
- handleLocalUcastOut(dpid, TABLE_2_LOCAL_FORWARD, segmentationId, localPort, attachedMac, false);
+ if(!isMigratedPort) {
+ handleLocalUcastOut(dpid, TABLE_2_LOCAL_FORWARD, segmentationId, localPort, attachedMac, false);
+ }
/*
* Table(2) Rule #2
programLocalVlanRules(node, dpid, segmentationId, attachedMac, localPort);
}
if ((isTunnel(networkType) || isVlan(networkType))) {
- programLocalSecurityGroupRules(attachedMac, node, intf, dpid, localPort, segmentationId, true);
+ programLocalSecurityGroupRules(attachedMac, node, intf, dpid, localPort, segmentationId, false, true);
}
if (isTunnel(networkType)) {
LOG.debug("Program local bridge rules for interface {}, "
}
private void removeLocalRules(String networkType, String segmentationId, Node node,
- OvsdbTerminationPointAugmentation intf) {
+ OvsdbTerminationPointAugmentation intf, boolean isMigratedPort) {
LOG.debug("removeLocalRules: node: {}, intf: {}, networkType: {}, segmentationId: {}",
node.getNodeId(), intf.getName(), networkType, segmentationId);
try {
removeLocalVlanRules(node, dpid, segmentationId, attachedMac, localPort);
} else if (isTunnel(networkType)) {
LOG.debug("Remove local bridge rules for interface {}", intf.getName());
- removeLocalBridgeRules(node, dpid, segmentationId, attachedMac, localPort);
+ removeLocalBridgeRules(node, dpid, segmentationId, attachedMac, localPort, isMigratedPort);
}
if (isTunnel(networkType) || isVlan(networkType)) {
- programLocalSecurityGroupRules(attachedMac, node, intf, dpid, localPort, segmentationId, false);
+ programLocalSecurityGroupRules(attachedMac, node, intf, dpid, localPort, segmentationId, isMigratedPort, false);
}
} catch (Exception e) {
LOG.error("Exception in removing Local Rules for {} on {}", intf, node, e);
private void removeTunnelRules (String tunnelType, String segmentationId, InetAddress dst, Node node,
OvsdbTerminationPointAugmentation intf,
- boolean local, boolean isLastInstanceOnNode) {
+ boolean local, boolean isLastInstanceOnNode, boolean isMigratedPort) {
LOG.debug("removeTunnelRules: node: {}, intf: {}, local: {}, tunnelType: {}, "
+ "segmentationId: {}, dstAddr: {}, isLastinstanceOnNode: {}",
node.getNodeId(), intf.getName(), local, tunnelType, segmentationId, dst, isLastInstanceOnNode);
LOG.debug("Identified Tunnel port {} -> OF ({}) on {}",
tunIntf.getName(), tunnelOFPort, node);
- if (!local) {
+ if (!local && !isMigratedPort) {
removeRemoteEgressTunnelBridgeRules(node, dpid, segmentationId, attachedMac,
tunnelOFPort, localPort);
}
}
private void programLocalSecurityGroupRules(String attachedMac, Node node, OvsdbTerminationPointAugmentation intf,
- Long dpid,long localPort, String segmentationId,
+ Long dpid,long localPort, String segmentationId, boolean isMigratedPort,
boolean write) {
LOG.debug("programLocalRules: Program fixed security group rules for interface {}", intf.getName());
if (write) {
securityGroupCacheManger.portAdded(securityGroupInPort.getSecurityGroupUUID(), neutronPortId);
} else {
- securityGroupCacheManger.portRemoved(securityGroupInPort.getSecurityGroupUUID(), neutronPortId);
+ if(!isMigratedPort) {
+ securityGroupCacheManger.portRemoved(securityGroupInPort.getSecurityGroupUUID(), neutronPortId);
+ }
}
}
} else {
@Override
public boolean handleInterfaceDelete(String tunnelType, NeutronNetwork network, Node srcNode,
- OvsdbTerminationPointAugmentation intf, boolean isLastInstanceOnNode) {
+ OvsdbTerminationPointAugmentation intf, boolean isLastInstanceOnNode, boolean isMigratedPort) {
Map<org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId,Node> nodes =
nodeCacheManager.getOvsdbNodes();
nodes.remove(southbound.extractBridgeOvsdbNodeId(srcNode));
} else {
// delete all other interfaces
removeLocalRules(network.getProviderNetworkType(), segmentationId,
- srcNode, intf);
+ srcNode, intf, isMigratedPort);
if (isVlan(network.getProviderNetworkType())) {
removeVlanRules(network, srcNode, intf, isLastInstanceOnNode);
LOG.info("Remove tunnel rules for interface "
+ intf.getName() + " on srcNode " + srcNode.getNodeId().getValue());
removeTunnelRules(tunnelType, segmentationId,
- dst, srcNode, intf, true, isLastInstanceOnNode);
+ dst, srcNode, intf, true, isLastInstanceOnNode, isMigratedPort);
Node dstBridgeNode = southbound.getBridgeNode(dstNode, Constants.INTEGRATION_BRIDGE);
//While removing last instance , check whether the network present in src node
//If network is not present in src node AND REMOTE MAC LEARNING IS not enabled,
//doesn't exist in a node, TunnelRules leaves it.
if (!isSrcinNw && !configurationService.isRemoteMacLearnEnabled()) {
removeTunnelRules(tunnelType, segmentationId,
- src, dstBridgeNode, intf, true, isLastInstanceOnNode);
+ src, dstBridgeNode, intf, true, isLastInstanceOnNode, isMigratedPort);
}
LOG.info("Remove tunnel rules for interface "
+ intf.getName() + " on dstNode " + dstNode.getNodeId().getValue());
removeTunnelRules(tunnelType, segmentationId, src,
- dstBridgeNode, intf, false, isLastInstanceOnNode);
+ dstBridgeNode, intf, false, isLastInstanceOnNode, isMigratedPort);
}
} else {
LOG.warn("Tunnel end-point configuration missing. Please configure it in "
securityGroupCacheManger.addToCache(remoteSgUuid, portUuid, nodeId);
} else {
securityGroupCacheManger.removeFromCache(remoteSgUuid,
- portUuid);
+ portUuid, nodeId);
}
} else {
programPortSecurityRule(dpid, segmentationId, attachedMac, portSecurityRule, securityGroup, null, write);
if (write) {
securityGroupCacheManger.addToCache(remoteSgUuid, portUuid, nodeId);
} else {
- securityGroupCacheManger.removeFromCache(remoteSgUuid, portUuid);
+ securityGroupCacheManger.removeFromCache(remoteSgUuid, portUuid, nodeId);
}
} else {
programPortSecurityRule(dpid, segmentationId, attachedMac, portSecurityRule, securityGroup, null, write);
flowBuilder.setMatch(matchBuilder.build());
// Add Flow Attributes
- String flowName = "UcastOut_" + segmentationId + "_" + localPort + "_" + attachedMac;
+ String flowName = "UcastOut_" + segmentationId + "_" + attachedMac;
FlowUtils.initFlowBuilder(flowBuilder, flowName, getTable());
if (write) {
flowBuilder.setMatch(matchBuilder.build());
// Add Flow Attributes
- String flowName = "TunnelOut_" + segmentationId + "_" + OFPortOut + "_" + attachedMac;
+ String flowName = "UcastOut_" + segmentationId + "_" + attachedMac;
FlowUtils.initFlowBuilder(flowBuilder, flowName, getTable());
if (write) {
MemberModifier.suppress(MemberMatcher.method(OF13Provider.class, "handleTunnelUnknownUcastFloodOut", Long.class, Short.class, Short.class, String.class, Long.class, boolean.class));
- Whitebox.invokeMethod(of13Provider, "removeLocalBridgeRules", mock(Node.class), Long.valueOf("45"), SEG_ID, MAC_ADDRESS, LOCAL_PORT);
+ Whitebox.invokeMethod(of13Provider, "removeLocalBridgeRules", mock(Node.class), Long.valueOf("45"), SEG_ID, MAC_ADDRESS, LOCAL_PORT, false);
PowerMockito.verifyPrivate(of13Provider, times(1)).invoke("handleLocalInPort", anyLong(), anyShort(), anyShort(), anyString(), anyLong(), anyString(), anyBoolean());
PowerMockito.verifyPrivate(of13Provider, times(1)).invoke("handleDropSrcIface", anyLong(), anyLong(), anyBoolean());
MemberModifier.suppress(MemberMatcher.method(OF13Provider.class, "deleteTunnelPort", Node.class, String.class, InetAddress.class, InetAddress.class));
- assertTrue("Error, did not delete the interface correclty", of13Provider.handleInterfaceDelete(TYPE, neutronNetwork, mock(Node.class), intf, false));
+ assertTrue("Error, did not delete the interface correclty", of13Provider.handleInterfaceDelete(TYPE, neutronNetwork, mock(Node.class), intf, false, false));
PowerMockito.verifyPrivate(of13Provider, times(1)).invoke("deleteTunnelPort", any(Node.class), anyString(), any(InetAddress.class), any(InetAddress.class));
when(southbound.isTunnel(any(OvsdbTerminationPointAugmentation.class))).thenReturn(false);
MemberModifier.suppress(MemberMatcher.method(OF13Provider.class, "deletePhysicalPort", Node.class, String.class));
- assertTrue("Error, did not delete the interface correclty", of13Provider.handleInterfaceDelete(TYPE, neutronNetwork, mock(Node.class), intf, false));
+ assertTrue("Error, did not delete the interface correclty", of13Provider.handleInterfaceDelete(TYPE, neutronNetwork, mock(Node.class), intf, false, false));
PowerMockito.verifyPrivate(of13Provider, times(1)).invoke("deletePhysicalPort", any(Node.class), anyString());
intfs.clear();
- MemberModifier.suppress(MemberMatcher.method(OF13Provider.class, "removeLocalRules", String.class, String.class, Node.class, OvsdbTerminationPointAugmentation.class));
+ MemberModifier.suppress(MemberMatcher.method(OF13Provider.class, "removeLocalRules", String.class, String.class, Node.class, OvsdbTerminationPointAugmentation.class, boolean.class));
MemberModifier.suppress(MemberMatcher.method(OF13Provider.class, "removeVlanRules", NeutronNetwork.class, Node.class, OvsdbTerminationPointAugmentation.class, boolean.class));
when(neutronNetwork.getProviderNetworkType()).thenReturn(NetworkHandler.NETWORK_TYPE_VLAN);
- assertTrue("Error, did not delete the interface correclty", of13Provider.handleInterfaceDelete(TYPE, neutronNetwork, mock(Node.class), intf, false));
- PowerMockito.verifyPrivate(of13Provider, times(1)).invoke("removeLocalRules", anyString(), anyString(), any(Node.class), any(OvsdbTerminationPointAugmentation.class));
+ assertTrue("Error, did not delete the interface correclty", of13Provider.handleInterfaceDelete(TYPE, neutronNetwork, mock(Node.class), intf, false, false));
+ PowerMockito.verifyPrivate(of13Provider, times(1)).invoke("removeLocalRules", anyString(), anyString(), any(Node.class), any(OvsdbTerminationPointAugmentation.class), any(boolean.class));
PowerMockito.verifyPrivate(of13Provider, times(1)).invoke("removeVlanRules", any(NeutronNetwork.class), any(Node.class), any(OvsdbTerminationPointAugmentation.class), anyBoolean());
TenantNetworkManager tenantNetworkManager = mock(TenantNetworkManager.class);
when(neutronNetwork.getProviderNetworkType()).thenReturn(NetworkHandler.NETWORK_TYPE_GRE);
when(southbound.getBridgeNode(any(Node.class), anyString())).thenReturn(node);
- MemberModifier.suppress(MemberMatcher.method(OF13Provider.class, "removeTunnelRules", String.class, String.class, InetAddress.class, Node.class, OvsdbTerminationPointAugmentation.class, boolean.class, boolean.class));
+ MemberModifier.suppress(MemberMatcher.method(OF13Provider.class, "removeTunnelRules", String.class, String.class, InetAddress.class, Node.class, OvsdbTerminationPointAugmentation.class, boolean.class, boolean.class, boolean.class));
- assertTrue("Error, did not delete the interface correclty", of13Provider.handleInterfaceDelete(TYPE, neutronNetwork, node, intf, false));
- PowerMockito.verifyPrivate(of13Provider, times(3)).invoke("removeTunnelRules", anyString(), anyString(), any(InetAddress.class), any(Node.class), any(OvsdbTerminationPointAugmentation.class), any(boolean.class), any(boolean.class));
+ assertTrue("Error, did not delete the interface correclty", of13Provider.handleInterfaceDelete(TYPE, neutronNetwork, node, intf, false, false));
+ PowerMockito.verifyPrivate(of13Provider, times(3)).invoke("removeTunnelRules", anyString(), anyString(), any(InetAddress.class), any(Node.class), any(OvsdbTerminationPointAugmentation.class), any(boolean.class), any(boolean.class), any(boolean.class));
}
// Problem with methods signatures: initializeFlowRules(Node) has the same signature than initializeFlowRules(Node, String)
if (write) {
securityGroupCacheManger.addToCache(securityRule.getSecurityRemoteGroupID(), port.getPortUUID(), nodeId);
} else {
- securityGroupCacheManger.removeFromCache(securityRule.getSecurityRemoteGroupID(), port.getPortUUID());
+ securityGroupCacheManger.removeFromCache(securityRule.getSecurityRemoteGroupID(), port.getPortUUID(), nodeId);
}
} else {
for (Neutron_IPs vmIp : vmIpList) {
import java.util.Map;
import java.util.stream.Collectors;
-
+import org.apache.commons.lang3.tuple.Pair;
import org.opendaylight.netvirt.openstack.netvirt.api.Action;
import org.opendaylight.netvirt.openstack.netvirt.api.BridgeConfigurationManager;
import org.opendaylight.netvirt.openstack.netvirt.api.ConfigurationService;
import org.opendaylight.netvirt.openstack.netvirt.impl.DistributedArpService;
import org.opendaylight.netvirt.openstack.netvirt.impl.NeutronL3Adapter;
import org.opendaylight.netvirt.utils.servicehelper.ServiceHelper;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.Uuid;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.InterfaceTypeVxlan;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbBridgeAugmentation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.ovsdb.rev150105.OvsdbNodeAugmentation;
LOG.debug("No tenant network found on node : {} for interface: {}", node, tp);
}
if (action.equals(Action.UPDATE)) {
- distributedArpService.processInterfaceEvent(node, tp, network, action);
+ distributedArpService.processInterfaceEvent(node, tp, network, false, action);
}
neutronL3Adapter.handleInterfaceEvent(node, tp, network, Action.UPDATE);
}
+ /**
+ * Get dpid from node.
+ *
+ * @param node the {@link Node Node} of interest in the notification
+ * @return dpid value
+ */
+ private Long getDpidForIntegrationBridge(Node node) {
+ // Check if node is integration bridge; and only then return its dpid
+ if (southbound.getBridge(node, configurationService.getIntegrationBridgeName()) != null) {
+ return southbound.getDataPathId(node);
+ }
+ return null;
+ }
+
+ /**
+ * Returns true, if the port is migrated else false.
+ *
+ * @param node the node associated with Neutron Port.
+ * @param neutronPort the port details.
+ * @return boolean true, if the port is migrated else false.
+ */
+ private boolean isMigratedPort(Node node, NeutronPort neutronPort) {
+ boolean isMigratedPort = false;
+ final Long dpId = getDpidForIntegrationBridge(node);
+ final Pair<Long, Uuid> nodeDpIdPair = neutronL3Adapter.getDpIdOfNeutronPort(neutronPort.getPortUUID());
+ Long dpIdNeutronPort = (nodeDpIdPair == null ? null : nodeDpIdPair.getLeft());
+ if(dpIdNeutronPort != null && !dpIdNeutronPort.equals(dpId)) {
+ isMigratedPort = true;
+ }
+ return isMigratedPort;
+ }
private void handleInterfaceDelete (Node node, OvsdbTerminationPointAugmentation intf,
boolean isLastInstanceOnNode, NeutronNetwork network) {
LOG.debug("handleInterfaceDelete: node: <{}>, isLastInstanceOnNode: {}, interface: <{}>",
node, isLastInstanceOnNode, intf);
- distributedArpService.processInterfaceEvent(node, intf, network, Action.DELETE);
- neutronL3Adapter.handleInterfaceEvent(node, intf, network, Action.DELETE);
final NeutronPort neutronPort = tenantNetworkManager.getTenantPort(intf);
+ boolean isMigratedPort = isMigratedPort(node, neutronPort);
+ distributedArpService.processInterfaceEvent(node, intf, network, isMigratedPort, Action.DELETE);
+ neutronL3Adapter.handleInterfaceEvent(node, intf, network, Action.DELETE);
programVLANNetworkFlowProvider(node, intf, network, neutronPort, false);
List<String> phyIfName = bridgeConfigurationManager.getAllPhysicalInterfaceNames(node);
if (isInterfaceOfInterest(intf, phyIfName)) {
// delete tunnel or physical interfaces
networkingProviderManager.getProvider(node).handleInterfaceDelete(network.getProviderNetworkType(),
- network, node, intf, isLastInstanceOnNode);
+ network, node, intf, isLastInstanceOnNode, isMigratedPort);
} else if (network != null) {
// vlan doesn't need a tunnel endpoint
if (!network.getProviderNetworkType().equalsIgnoreCase(NetworkHandler.NETWORK_TYPE_VLAN) &&
return;
}
networkingProviderManager.getProvider(node).handleInterfaceDelete(network.getProviderNetworkType(),
- network, node, intf, isLastInstanceOnNode);
+ network, node, intf, isLastInstanceOnNode, isMigratedPort);
}
+
}
@Override
* @param source Source node where interface was attached
* @param intf Termination point associated to the deleted interface
* @param isLastInstanceOnNode is last interface attached to the node ?
+ * @param isMigratedPort is the Neutron Port associated with the removed interface is being migrated to a new node?
* @return true if interface delete handled successfully
*/
boolean handleInterfaceDelete(String tunnelType, NeutronNetwork network, Node source,
- OvsdbTerminationPointAugmentation intf, boolean isLastInstanceOnNode);
+ OvsdbTerminationPointAugmentation intf, boolean isLastInstanceOnNode, boolean isMigratedPort);
/**
* Initialize the Flow rules given the OVSDB node.
* from the cache maintained.
* @param remoteSgUuid the remote security group uuid.
* @param portUuid portUUID the uuid of the port.
+ * @param nodeId the NodeId of the node.
*/
- void removeFromCache(String remoteSgUuid, String portUuid);
+ void removeFromCache(String remoteSgUuid, String portUuid, NodeId nodeId);
}
* Process the port event to write Arp rules for neutron ports.
*
* @param action the {@link Action} action to be handled.
+ * @param isMigratedPort true, if the port is migrated else false.
+ * @param bridgeNode the node for the port.
* @param neutronPort An instance of NeutronPort object.
*/
- public void handlePortEvent(NeutronPort neutronPort, Action action) {
+ public void handlePortEvent(NeutronPort neutronPort, Node bridgeNode, boolean isMigratedPort, Action action) {
LOG.debug("neutronPort Event {} action event {} ", neutronPort, action);
- this.handleNeutronPortForArp(neutronPort, action);
+ this.handleNeutronPortForArp(neutronPort, bridgeNode, isMigratedPort, action);
}
/**
* Write Arp rules based on event for neutron port.
*
* @param action the {@link Action} action to be handled.
+ * @param isMigratedPort true, if the port is migrated else false.
+ * @param bridgeNode the node for the port.
* @param neutronPort An instance of NeutronPort object.
*/
- private void handleNeutronPortForArp(NeutronPort neutronPort, Action action) {
+ private void handleNeutronPortForArp(NeutronPort neutronPort, Node bridgeNode, boolean isMigratedPort, Action action) {
if (!flgDistributedARPEnabled) {
return;
}
if (nodes.isEmpty()) {
LOG.trace("updateL3ForNeutronPort has no nodes to work with");
}
+ String owner = neutronPort.getDeviceOwner();
+ boolean isDhcpPort = owner != null && owner.equals(DHCP_DEVICE_OWNER);
for (Node node : nodes) {
- handleArpRule(node, neutronPort, providerSegmentationId, actionToPerform);
+ if(actionToPerform == Action.DELETE && !isDhcpPort &&
+ (isMigratedPort && !bridgeNode.getNodeId().equals(node.getNodeId()))) {
+ continue;
+ }
+ handleArpRule(node, neutronPort, providerSegmentationId, isMigratedPort, actionToPerform);
}
}
private void handleArpRule(Node node, NeutronPort neutronPort,
- String providerSegmentationId, Action actionToPerform) {
+ String providerSegmentationId, boolean isMigratedPort, Action actionToPerform) {
String owner = neutronPort.getDeviceOwner();
boolean isRouterInterface = owner != null && owner.equals(ROUTER_INTERFACE_DEVICE_OWNER);
boolean isDhcpPort = owner != null && owner.equals(DHCP_DEVICE_OWNER);
}
}
} else {
- for (Neutron_IPs neutronIPAddr : neutronPort.getFixedIPs()) {
- final String ipAddress = neutronIPAddr.getIpAddress();
- try {
- executor.submit(() ->
- programStaticRuleStage1(dpid, providerSegmentationId, macAddress,
- ipAddress, actionForNode));
- } catch (RejectedExecutionException ex) {
- LOG.error("handleArpRule : unable to accept execution.", ex);
- programStaticRuleStage1(dpid, providerSegmentationId, macAddress,
- ipAddress, actionForNode);
+ if(!isMigratedPort) {
+ for (Neutron_IPs neutronIPAddr : neutronPort.getFixedIPs()) {
+ final String ipAddress = neutronIPAddr.getIpAddress();
+ try {
+ executor.submit(() ->
+ programStaticRuleStage1(dpid, providerSegmentationId, macAddress,
+ ipAddress, actionForNode));
+ } catch (RejectedExecutionException ex) {
+ LOG.error("handleArpRule : unable to accept execution.", ex);
+ programStaticRuleStage1(dpid, providerSegmentationId, macAddress,
+ ipAddress, actionForNode);
+ }
}
}
}
* .OvsdbTerminationPointAugmentation} instance of OvsdbTerminationPointAugmentation object.
* @param neutronNetwork An {@link NeutronNetwork} instance of NeutronNetwork
* object.
+ * @param isMigratedPort true, if the port is migrated else false.
* @param action the {@link Action} action to be handled.
*/
public void processInterfaceEvent(final Node bridgeNode, final OvsdbTerminationPointAugmentation intf,
- final NeutronNetwork neutronNetwork, Action action) {
+ final NeutronNetwork neutronNetwork, boolean isMigratedPort, Action action) {
LOG.debug("southbound interface {} node:{} interface:{}, neutronNetwork:{}",
action, bridgeNode.getNodeId().getValue(), intf.getName(), neutronNetwork);
final NeutronPort neutronPort = tenantNetworkManager.getTenantPort(intf);
if (neutronPort != null) {
- this.handlePortEvent(neutronPort, action);
+ this.handlePortEvent(neutronPort, bridgeNode, isMigratedPort, action);
}
}
this.networkIdToRouterMacCache = new HashMap<>();
this.networkIdToRouterIpListCache = new HashMap<>();
this.subnetIdToRouterInterfaceCache = new HashMap<>();
- this.neutronPortToDpIdCache = new HashMap<>();
this.floatIpDataMapCache = new HashMap<>();
this.externalRouterMac = configurationService.getDefaultGatewayMacAddress(null);
} else {
LOG.debug("OVSDB L3 forwarding is disabled");
}
+ this.neutronPortToDpIdCache = new HashMap<>();
this.portCleanupCache = new ConcurrentHashMap<>();
this.networkCleanupCache = new ConcurrentHashMap<>();
}
LOG.debug("NetVirt L3 caches population is done");
}
- private Pair<Long, Uuid> getDpIdOfNeutronPort(String neutronTenantPortUuid) {
+ public Pair<Long, Uuid> getDpIdOfNeutronPort(String neutronTenantPortUuid) {
if(neutronPortToDpIdCache.get(neutronTenantPortUuid) == null) {
List<Node> bridges = this.southbound.readOvsdbTopologyBridgeNodes();
LOG.debug("getDpIdOfNeutronPort : {} bridges present in ovsdb topology",bridges.size());
storePortInCleanupCache(neutronPort);
}
- if (!this.enabled) {
- return;
- }
-
final Long dpId = getDpidForIntegrationBridge(bridgeNode);
final Uuid interfaceUuid = intf.getInterfaceUuid();
handleInterfaceEventAdd(neutronPortUuid, dpId, interfaceUuid);
}
- handleNeutronPortEvent(neutronPort, action);
+ if (this.enabled) {
+ handleNeutronPortEvent(neutronPort, action);
+ }
}
if (action == DELETE && interfaceUuid != null) {
}
@Override
- public void removeFromCache(String remoteSgUuid, String portUuid) {
+ public void removeFromCache(String remoteSgUuid, String portUuid, NodeId nodeId) {
LOG.debug("In removeFromCache remoteSgUuid:" + remoteSgUuid + " portUuid:" + portUuid);
Map<String, NodeId> remoteSgPorts = securityGroupCache.get(remoteSgUuid);
if (null == remoteSgPorts) {
for (Iterator<String> iterator = portSet.iterator(); iterator.hasNext();) {
String cachedPort = iterator.next();
if (cachedPort.equals(portUuid)) {
- iterator.remove();
- break;
+ NodeId cachedNodeId = remoteSgPorts.get(cachedPort);
+ if(cachedNodeId.equals(nodeId)) {
+ iterator.remove();
+ break;
+ }
}
}
if (portSet.isEmpty()) {
when(ev.getAction()).thenReturn(Action.UPDATE);
southboundHandler.processEvent(ev);
- verify(distributedArpService, times(1)).processInterfaceEvent(any(Node.class), any(OvsdbTerminationPointAugmentation.class), any(NeutronNetwork.class), any(Action.class));
+ verify(distributedArpService, times(1)).processInterfaceEvent(any(Node.class), any(OvsdbTerminationPointAugmentation.class), any(NeutronNetwork.class), any(Boolean.class), any(Action.class));
verify(neutronL3Adapter, times(1)).handleInterfaceEvent(any(Node.class), any(OvsdbTerminationPointAugmentation.class), any(NeutronNetwork.class), any(Action.class));
verify(networkingProvider, times(1)).handleInterfaceUpdate(any(NeutronNetwork.class), any(Node.class), any(OvsdbTerminationPointAugmentation.class));
Mockito.reset(neutronL3Adapter);
@Test
public void testHandlePortEvent() throws Exception {
NeutronPort neutronPort = PowerMockito.mock(NeutronPort.class);
+ Node node = PowerMockito.mock(Node.class);
// Suppress the called to these functions.
- MemberModifier.suppress(MemberMatcher.method(DistributedArpService.class, "handleNeutronPortForArp", NeutronPort.class, Action.class));
+ MemberModifier.suppress(MemberMatcher.method(DistributedArpService.class, "handleNeutronPortForArp", NeutronPort.class, Node.class, boolean.class, Action.class));
+
+ Whitebox.invokeMethod(distributedArpService, "handlePortEvent", neutronPort, node, false, Action.ADD);
+ PowerMockito.verifyPrivate(distributedArpService, times(1)).invoke("handleNeutronPortForArp", any(NeutronPort.class), any(Node.class), any(boolean.class), eq(Action.ADD));
- Whitebox.invokeMethod(distributedArpService, "handlePortEvent", neutronPort, Action.ADD);
- PowerMockito.verifyPrivate(distributedArpService, times(1)).invoke("handleNeutronPortForArp", any(NeutronPort.class), eq(Action.ADD));
-
//Case 1: Delete Action.
- Whitebox.invokeMethod(distributedArpService, "handlePortEvent", neutronPort, Action.DELETE);
- PowerMockito.verifyPrivate(distributedArpService, times(1)).invoke("handleNeutronPortForArp", any(NeutronPort.class), eq(Action.DELETE));
+ Whitebox.invokeMethod(distributedArpService, "handlePortEvent", neutronPort, node, false, Action.DELETE);
+ PowerMockito.verifyPrivate(distributedArpService, times(1)).invoke("handleNeutronPortForArp", any(NeutronPort.class), any(Node.class), any(boolean.class), eq(Action.DELETE));
}
/**
PowerMockito.when(southbound.readTerminationPointAugmentations(any(Node.class))).thenReturn(ports);
PowerMockito.doReturn(true).when(distributedArpService, "getNeutronPortsForNode", any(Node.class), any(List.class), anyString());
- Whitebox.invokeMethod(distributedArpService, "handleNeutronPortForArp", neutronPort, Action.ADD);
+ Whitebox.invokeMethod(distributedArpService, "handleNeutronPortForArp", neutronPort, mock(Node.class), false, Action.ADD);
PowerMockito.verifyPrivate(distributedArpService, times(1)).invoke("getDatapathIdIntegrationBridge", any(Node.class));
// Case 2: Delete Action.
- Whitebox.invokeMethod(distributedArpService, "handleNeutronPortForArp", neutronPort, Action.DELETE);
+ Whitebox.invokeMethod(distributedArpService, "handleNeutronPortForArp", neutronPort, mock(Node.class), false, Action.DELETE);
PowerMockito.verifyPrivate(distributedArpService, times(2)).invoke("getDatapathIdIntegrationBridge", any(Node.class));
}
public void testProcessInterfaceEvent() throws Exception {
NeutronPort neutronPort = mock(NeutronPort.class);
NeutronNetwork neutronNetwork = mock(NeutronNetwork.class);
- PowerMockito.doNothing().when(distributedArpService).handlePortEvent(any(NeutronPort.class), any(Action.class));
+ PowerMockito.doNothing().when(distributedArpService).handlePortEvent(any(NeutronPort.class), any(Node.class), any(boolean.class), any(Action.class));
// init instance variables.
TenantNetworkManager tenantNetworkManager = mock(TenantNetworkManager.class);
MemberModifier.field(DistributedArpService.class, "tenantNetworkManager").set(distributedArpService , tenantNetworkManager);
when(tenantNetworkManager.getTenantPort(intf)).thenReturn(neutronPort);
//Case 1: Add Action.
- distributedArpService.processInterfaceEvent(node, intf, neutronNetwork, Action.ADD);
- Mockito.verify(distributedArpService, times(1)).handlePortEvent(neutronPort, Action.ADD);
+ distributedArpService.processInterfaceEvent(node, intf, neutronNetwork, false, Action.ADD);
+ Mockito.verify(distributedArpService, times(1)).handlePortEvent(neutronPort, node, false, Action.ADD);
//Case 2: Delete Action.
- distributedArpService.processInterfaceEvent(node, intf, neutronNetwork, Action.DELETE);
- Mockito.verify(distributedArpService, times(1)).handlePortEvent(neutronPort, Action.DELETE);
+ distributedArpService.processInterfaceEvent(node, intf, neutronNetwork, false, Action.DELETE);
+ Mockito.verify(distributedArpService, times(1)).handlePortEvent(neutronPort, node, false, Action.DELETE);
}
/**
@Test
public void testPortRemovedFromCache() {
securityGroupCacheManagerImpl.addToCache(SECURITY_GROUP_ID_2, NEUTRON_PORT_ID_VM_3, nodeId_1);
- securityGroupCacheManagerImpl.removeFromCache(SECURITY_GROUP_ID_2, NEUTRON_PORT_ID_VM_3);
+ securityGroupCacheManagerImpl.removeFromCache(SECURITY_GROUP_ID_2, NEUTRON_PORT_ID_VM_3, nodeId_1);
securityGroupCacheManagerImpl.portRemoved(SECURITY_GROUP_ID_2, NEUTRON_PORT_ID_VM_2);
verify(securityServicesManager, times(0)).syncSecurityRule(any(NeutronPort.class), any(NeutronSecurityRule.class), any(Neutron_IPs.class),any(NodeId.class), any(NeutronSecurityGroup.class), anyBoolean());
}