import javax.annotation.Nullable;
+import com.sun.jndi.cosnaming.IiopUrl;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.ReadWriteTransaction;
import org.opendaylight.controller.md.sal.binding.api.WriteTransaction;
this.epRegistrator = checkNotNull(epRegistrator);
}
- @Override
- public void onCreated(Port port, Neutron neutron) {
+ @Override public void onCreated(Port createdItem, Neutron neutron) {
+ onCreated(createdItem, neutron, true);
+ }
+
+ public void onCreated(Port port, Neutron neutron, boolean addBaseEpMapping) {
LOG.trace("created port - {}", port);
if (PortUtils.isRouterInterfacePort(port)) {
LOG.trace("Port is router interface port: {}", port.getUuid().getValue());
UniqueId portId = new UniqueId(port.getUuid().getValue());
addBaseEndpointMappings(addrEpKey, portId, rwTx);
- // Add Qrouter port as Endpoint
+ // Add Qrouter and VPProuter port as Endpoint
if (port.getAugmentation(PortBindingExtension.class) != null &&
PortUtils.DEVICE_VIF_TYPE.equals(port.getAugmentation(PortBindingExtension.class).getVifType())) {
LOG.trace("Port is QRouter port: {}", port.getUuid().getValue());
createEndpointRegFromPort(
port, ipWithSubnet, networkContainment, epgsFromSecGroups, neutron);
registerBaseEndpointAndStoreMapping(
- ImmutableList.of(l2BaseEp.build(), l3BaseEp.build()), port, rwTx);
+ ImmutableList.of(l2BaseEp.build(), l3BaseEp.build()), port, rwTx, addBaseEpMapping);
registerEndpointAndStoreMapping(epInBuilder.build(), port, rwTx);
}
ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction();
registerBaseEndpointAndStoreMapping(
- ImmutableList.of(l2BaseEp.build(), l3BaseEp.build()), port, rwTx);
+ ImmutableList.of(l2BaseEp.build(), l3BaseEp.build()), port, rwTx, addBaseEpMapping);
registerEndpointAndStoreMapping(epInBuilder.build(), port, rwTx);
DataStoreHelper.submitToDs(rwTx);
} else if (PortUtils.isNormalPort(port)) {
baseEpRegs.add(l3BaseEp.build());
}
ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction();
- registerBaseEndpointAndStoreMapping(baseEpRegs, port, rwTx);
+ registerBaseEndpointAndStoreMapping(baseEpRegs, port, rwTx, addBaseEpMapping);
registerEndpointAndStoreMapping(epInBuilder.build(), port, rwTx);
DataStoreHelper.submitToDs(rwTx);
} else if (PortUtils.isRouterGatewayPort(port)) {
Set<Port> portsInSameSubnet = PortUtils.findPortsBySubnet(subnetUuid, neutron.getPorts());
for (Port portInSameSubnet : portsInSameSubnet) {
if (PortUtils.isNormalPort(portInSameSubnet) || PortUtils.isDhcpPort(portInSameSubnet)
- || PortUtils.isQrouterPort(portInSameSubnet)) {
+ || PortUtils.isQrouterOrVppRouterPort(portInSameSubnet)) {
// endpoints are created only from neutron normal port or DHCP port
Optional<FixedIps> firstFixedIps = PortUtils.resolveFirstFixedIps(portInSameSubnet);
if (firstFixedIps.isPresent()) {
// endpoint has only one network containment therefore only first IP is used
FixedIps ipWithSubnet = firstFixedIps.get();
List<EndpointGroupId> endpointGroupIds = new ArrayList<>();
- if (PortUtils.isDhcpPort(portInSameSubnet) || PortUtils.isQrouterPort(portInSameSubnet)) {
+ if (PortUtils.isDhcpPort(portInSameSubnet) || PortUtils.isQrouterOrVppRouterPort(portInSameSubnet)) {
endpointGroupIds.add(NetworkService.EPG_ID);
} else if (PortUtils.isNormalPort(portInSameSubnet)) {
endpointGroupIds.add(NetworkClient.EPG_ID);
}
private void registerBaseEndpointAndStoreMapping(List<AddressEndpointReg> addrEpRegs, Port port,
- WriteTransaction wTx) {
+ WriteTransaction wTx, boolean addBaseEpMappings) {
RegisterEndpointInput regBaseEpInput = new RegisterEndpointInputBuilder().setAddressEndpointReg(addrEpRegs)
.build();
return;
}
for (AddressEndpointReg addrEpReg : addrEpRegs) {
- if (MappingUtils.L2_BRDIGE_DOMAIN.equals(addrEpReg.getContextType())) {
+ if (MappingUtils.L2_BRDIGE_DOMAIN.equals(addrEpReg.getContextType()) && addBaseEpMappings) {
UniqueId portId = new UniqueId(port.getUuid().getValue());
LOG.trace("Adding Port-BaseEndpoint mapping for port {} (device owner {}) and endpoint {}",
port.getUuid());
}
private void unregisterEndpointAndRemoveMapping(UnregisterEndpointInput baseEpUnreg, Port port,
- ReadWriteTransaction rwTx) {
+ ReadWriteTransaction rwTx, boolean removeBaseEpMappings) {
boolean isUnregisteredBaseEndpoint = epRegistrator.unregisterEndpoint(baseEpUnreg);
if (isUnregisteredBaseEndpoint) {
UniqueId portId = new UniqueId(port.getUuid().getValue());
MacAddressType.class, new ContextId(port.getNetworkId().getValue()), MappingUtils.L2_BRDIGE_DOMAIN);
LOG.trace("Removing Port-BaseEndpoint mapping for port {} (device owner {}) and endpoint {}",
port.getUuid().getValue(), port.getDeviceOwner(), portByBaseEndpointKey);
- removeBaseEndpointMappings(portByBaseEndpointKey, portId, rwTx);
+ if (removeBaseEpMappings) {
+ removeBaseEndpointMappings(portByBaseEndpointKey, portId, rwTx);
+ }
}
}
@Override
public void onUpdated(Port oldPort, Port newPort, Neutron oldNeutron, Neutron newNeutron) {
LOG.trace("updated port - OLD: {}\nNEW: {}", oldPort, newPort);
- onDeleted(oldPort, oldNeutron, newNeutron);
- onCreated(newPort, newNeutron);
+ onDeleted(oldPort, oldNeutron, newNeutron, false);
+ onCreated(newPort, newNeutron, false);
}
- @Override
- public void onDeleted(Port port, Neutron oldNeutron, Neutron newNeutron) {
+ @Override public void onDeleted(Port deletedItem, Neutron oldNeutron, Neutron newNeutron) {
+ onDeleted(deletedItem, oldNeutron, newNeutron, true);
+ }
+
+ public void onDeleted(Port port, Neutron oldNeutron, Neutron newNeutron, boolean removeBaseEpMapping) {
LOG.trace("deleted port - {}", port);
if (PortUtils.isRouterInterfacePort(port)) {
LOG.trace("Port is router interface port: {}", port.getUuid().getValue());
FixedIps portIpWithSubnet = potentialPortIpWithSubnet.get();
L3ContextId l3Context = new L3ContextId(port.getNetworkId().getValue());
// change L3Context for all EPs with same subnet as router port
- changeL3ContextForEpsInSubnet(portIpWithSubnet.getSubnetId(), oldNeutron);
+ changeL3ContextForEpsInSubnet(portIpWithSubnet.getSubnetId(), newNeutron);
// set L3Context as parent for bridge domain which is parent of subnet
TenantId tenantId = new TenantId(port.getTenantId().getValue());
Optional<Subnet> potentialRouterPortSubnet = SubnetUtils.findSubnet(portIpWithSubnet.getSubnetId(),
NetworkDomain subnet = NeutronSubnetAware.createSubnet(routerPortSubnet, null);
rwTx.put(LogicalDatastoreType.CONFIGURATION, L2L3IidFactory.subnetIid(tenantId, subnet.getNetworkDomainId()),
subnet);
- UniqueId portId = new UniqueId(port.getUuid().getValue());
- PortByBaseEndpointKey portByBaseEndpointKey = new PortByBaseEndpointKey(port.getMacAddress().getValue(),
- MacAddressType.class, new ContextId(port.getNetworkId().getValue()), MappingUtils.L2_BRDIGE_DOMAIN);
- removeBaseEndpointMappings(portByBaseEndpointKey, portId, rwTx);
+ unregisterEndpointAndRemoveMapping(createUnregisterEndpointInput(port, oldNeutron), port, rwTx);
+ unregisterEndpointAndRemoveMapping(createUnregisterBaseEndpointInput(port, oldNeutron), port, rwTx, removeBaseEpMapping);
DataStoreHelper.submitToDs(rwTx);
} else if (PortUtils.isDhcpPort(port)) {
LOG.trace("Port is DHCP port: {}", port.getUuid().getValue());
ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction();
unregisterEndpointAndRemoveMapping(createUnregisterEndpointInput(port, oldNeutron), port, rwTx);
- unregisterEndpointAndRemoveMapping(createUnregisterBaseEndpointInput(port, oldNeutron), port, rwTx);
+ unregisterEndpointAndRemoveMapping(createUnregisterBaseEndpointInput(port, oldNeutron), port, rwTx, removeBaseEpMapping);
DataStoreHelper.submitToDs(rwTx);
} else if (PortUtils.isNormalPort(port)) {
LOG.trace("Port is normal port: {}", port.getUuid().getValue());
ReadWriteTransaction rwTx = dataProvider.newReadWriteTransaction();
unregisterEndpointAndRemoveMapping(createUnregisterEndpointInput(port, oldNeutron), port, rwTx);
- unregisterEndpointAndRemoveMapping(createUnregisterBaseEndpointInput(port, oldNeutron), port, rwTx);
+ unregisterEndpointAndRemoveMapping(createUnregisterBaseEndpointInput(port, oldNeutron), port, rwTx, removeBaseEpMapping);
DataStoreHelper.submitToDs(rwTx);
} else if (PortUtils.isRouterGatewayPort(port)) {
// do nothing because actual trigger is detaching of port from router