use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIpsKey in project netvirt by opendaylight.
the class NeutronPortChangeListener method handleRouterInterfaceRemoved.
private void handleRouterInterfaceRemoved(Port routerPort) {
if (routerPort.getDeviceId() != null) {
Uuid routerId = new Uuid(routerPort.getDeviceId());
Uuid infNetworkId = routerPort.getNetworkId();
elanService.removeKnownL3DmacAddress(routerPort.getMacAddress().getValue(), infNetworkId.getValue());
Uuid vpnId = ObjectUtils.defaultIfNull(neutronvpnUtils.getVpnForRouter(routerId, true), routerId);
Map<FixedIpsKey, FixedIps> keyFixedIpsMap = routerPort.nonnullFixedIps();
boolean vpnInstanceInternetIpVersionRemoved = false;
Uuid vpnInstanceInternetUuid = null;
for (FixedIps portIP : keyFixedIpsMap.values()) {
// Internet VPN : flush InternetVPN first
Uuid subnetId = portIP.getSubnetId();
Subnetmap sn = neutronvpnUtils.getSubnetmap(subnetId);
if (sn != null && sn.getInternetVpnId() != null) {
if (neutronvpnUtils.shouldVpnHandleIpVersionChangeToRemove(sn, sn.getInternetVpnId())) {
vpnInstanceInternetIpVersionRemoved = true;
vpnInstanceInternetUuid = sn.getInternetVpnId();
}
nvpnManager.updateVpnInternetForSubnet(sn, sn.getInternetVpnId(), false);
}
}
/* Remove ping responder for router interfaces
* A router interface reference in a VPN will have to be removed before the host interface references
* for that subnet in the VPN are removed. This is to ensure that the FIB Entry of the router interface
* is not the last entry to be removed for that subnet in the VPN.
* If router interface FIB entry is the last to be removed for a subnet in a VPN , then all the host
* interface references in the vpn will already have been cleared, which will cause failures in
* cleanup of router interface flows*/
nvpnManager.deleteVpnInterface(routerPort.getUuid().getValue(), null, /* vpn-id */
null);
// update RouterInterfaces map
LoggingFutures.addErrorLogging(txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, confTx -> {
IpVersionChoice ipVersion = IpVersionChoice.UNDEFINED;
for (FixedIps portIP : keyFixedIpsMap.values()) {
Subnetmap sn = neutronvpnUtils.getSubnetmap(portIP.getSubnetId());
if (null == sn) {
LOG.error("Subnetmap for subnet {} not found", portIP.getSubnetId().getValue());
continue;
}
// router Port have either IPv4 or IPv6, never both
ipVersion = neutronvpnUtils.getIpVersionFromString(sn.getSubnetIp());
String ipValue = portIP.getIpAddress().stringValue();
neutronvpnUtils.removeVpnPortFixedIpToPort(vpnId.getValue(), ipValue, confTx);
// NOTE: Please donot change the order of calls to removeSubnetFromVpn and
// and updateSubnetNodeWithFixedIP
nvpnManager.removeSubnetFromVpn(vpnId, sn, sn.getInternetVpnId());
nvpnManager.updateSubnetNodeWithFixedIp(portIP.getSubnetId(), null, null, null, null, null);
}
nvpnManager.removeFromNeutronRouterInterfacesMap(routerId, routerPort.getUuid().getValue());
deleteElanInterface(routerPort.getUuid().getValue(), confTx);
deleteOfPortInterface(routerPort, confTx);
jobCoordinator.enqueueJob(routerId.toString(), () -> {
nvpnNatManager.handleSubnetsForExternalRouter(routerId);
return Collections.emptyList();
});
if (neutronvpnUtils.shouldVpnHandleIpVersionChoiceChange(ipVersion, routerId, false)) {
LOG.debug("vpnInstanceOpDataEntry is getting update with ip address family {} for VPN {}", ipVersion, vpnId.getValue());
neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnId.getValue(), ipVersion, false);
}
}), LOG, "Error handling interface removal");
if (vpnInstanceInternetIpVersionRemoved) {
neutronvpnUtils.updateVpnInstanceWithIpFamily(vpnInstanceInternetUuid.getValue(), IpVersionChoice.IPV6, false);
neutronvpnUtils.updateVpnInstanceWithFallback(routerId, vpnInstanceInternetUuid, false);
}
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIpsKey in project netvirt by opendaylight.
the class NeutronPortChangeListener method handleNeutronPortCreated.
private void handleNeutronPortCreated(final Port port) {
final String portName = port.getUuid().getValue();
final Uuid portId = port.getUuid();
final String networkId = port.getNetworkId().getValue();
final Map<FixedIpsKey, FixedIps> keyFixedIpsMap = port.nonnullFixedIps();
if (NeutronConstants.IS_ODL_DHCP_PORT.test(port)) {
return;
}
if (!NeutronUtils.isPortVnicTypeNormal(port) && (!isPortTypeSwitchdev(port) || !isSupportedVnicTypeByHost(port, NeutronConstants.VNIC_TYPE_DIRECT))) {
for (FixedIps ip : keyFixedIpsMap.values()) {
nvpnManager.updateSubnetmapNodeWithPorts(ip.getSubnetId(), null, portId);
}
LOG.info("Port {} is not a normal and not a direct with switchdev VNIC type ;" + "OF Port interfaces are not created", portName);
return;
}
jobCoordinator.enqueueJob("PORT- " + portName, () -> {
// add direct port to subnetMaps config DS
// TODO: for direct port as well, operations should be carried out per subnet based on port IP
ListenableFuture<?> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> {
LOG.info("Of-port-interface creation for port {}", portName);
// Create of-port interface for this neutron port
String portInterfaceName = createOfPortInterface(port, tx);
LOG.debug("Creating ELAN Interface for port {}", portName);
createElanInterface(port, portInterfaceName, tx);
Set<Uuid> vpnIdList = new HashSet<>();
Set<Uuid> routerIds = new HashSet<>();
for (FixedIps ip : keyFixedIpsMap.values()) {
Subnetmap subnetMap = nvpnManager.updateSubnetmapNodeWithPorts(ip.getSubnetId(), portId, null);
if (subnetMap != null && subnetMap.getInternetVpnId() != null) {
if (!vpnIdList.contains(subnetMap.getInternetVpnId())) {
vpnIdList.add(subnetMap.getInternetVpnId());
}
}
if (subnetMap != null && subnetMap.getVpnId() != null) {
// can't use NeutronvpnUtils.getVpnForNetwork to optimise here, because it gives BGPVPN id
// obtained subnetMaps belongs to one network => vpnId must be the same for each port Ip
Uuid vpnId = subnetMap.getVpnId();
if (vpnId != null) {
vpnIdList.add(vpnId);
}
}
if (subnetMap != null && subnetMap.getRouterId() != null) {
routerIds.add(subnetMap.getRouterId());
}
}
if (!vpnIdList.isEmpty()) {
// create new vpn-interface for neutron port
LOG.debug("handleNeutronPortCreated: Adding VPN Interface for port {} from network {}", portName, networkId);
nvpnManager.createVpnInterface(vpnIdList, port, tx);
for (Uuid routerId : routerIds) {
nvpnManager.addToNeutronRouterInterfacesMap(routerId, port.getUuid().getValue());
}
}
});
LoggingFutures.addErrorLogging(future, LOG, "handleNeutronPortCreated: Failed for port {} with networkId {}", portName, networkId);
return Collections.singletonList(future);
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIpsKey in project netvirt by opendaylight.
the class SubnetRouteInterfaceStateChangeListener method getSubnetId.
@NonNull
protected List<Uuid> getSubnetId(Interface intrf) {
List<Uuid> listSubnetIds = new ArrayList<>();
if (!NeutronUtils.isUuid(intrf.getName())) {
LOG.debug("SubnetRouteInterfaceListener: Interface {} doesn't have valid uuid pattern", intrf.getName());
return listSubnetIds;
}
PortOpDataEntry portOpEntry = subOpDpnManager.getPortOpDataEntry(intrf.getName());
if (portOpEntry != null) {
List<Uuid> subnet = portOpEntry.getSubnetIds();
if (subnet != null) {
return subnet;
}
return listSubnetIds;
}
LOG.trace("SubnetRouteInterfaceListener : Received Port {} event for {} that is not part of subnetRoute", intrf.getOperStatus(), intrf.getName());
Port port = neutronVpnManager.getNeutronPort(intrf.getName());
if (port == null) {
return listSubnetIds;
}
Map<FixedIpsKey, FixedIps> portIpsMap = port.getFixedIps();
if (portIpsMap != null) {
for (FixedIps portIp : portIpsMap.values()) {
listSubnetIds.add(portIp.getSubnetId());
}
}
return listSubnetIds;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIpsKey in project netvirt by opendaylight.
the class NeutronPortChangeListener method handleNeutronPortDeleted.
private void handleNeutronPortDeleted(final Port port) {
final String portName = port.getUuid().getValue();
final Uuid portId = port.getUuid();
final Map<FixedIpsKey, FixedIps> keyFixedIpsMap = port.nonnullFixedIps();
if (!NeutronUtils.isPortVnicTypeNormal(port) && !isPortTypeSwitchdev(port)) {
for (FixedIps ip : keyFixedIpsMap.values()) {
// remove direct port from subnetMaps config DS
// TODO: for direct port as well, operations should be carried out per subnet based on port IP
nvpnManager.removePortsFromSubnetmapNode(ip.getSubnetId(), null, portId);
}
LOG.info("Port {} is not a normal and not a direct with switchdev VNIC type ;" + "Skipping OF Port interfaces removal", portName);
return;
}
jobCoordinator.enqueueJob("PORT- " + portName, () -> {
ListenableFuture<?> future = txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, confTx -> {
Uuid vpnId = null;
Set<Uuid> routerIds = new HashSet<>();
Uuid internetVpnId = null;
for (FixedIps ip : keyFixedIpsMap.values()) {
Subnetmap subnetMap = nvpnManager.removePortsFromSubnetmapNode(ip.getSubnetId(), portId, null);
if (subnetMap == null) {
continue;
}
if (subnetMap.getVpnId() != null) {
// can't use NeutronvpnUtils.getVpnForNetwork to optimise here, because it gives BGPVPN id
// obtained subnetMaps belongs to one network => vpnId must be the same for each port Ip
vpnId = subnetMap.getVpnId();
}
if (subnetMap.getRouterId() != null) {
routerIds.add(subnetMap.getRouterId());
}
internetVpnId = subnetMap.getInternetVpnId();
if (NeutronConstants.DEVICE_OWNER_GATEWAY_INF.equals(port.getDeviceOwner()) || NeutronConstants.DEVICE_OWNER_FLOATING_IP.equals(port.getDeviceOwner())) {
String ipAddress = ip.getIpAddress().stringValue();
if (vpnId != null) {
neutronvpnUtils.removeVpnPortFixedIpToPort(vpnId.getValue(), ipAddress, confTx);
}
if (internetVpnId != null) {
neutronvpnUtils.removeVpnPortFixedIpToPort(internetVpnId.getValue(), ipAddress, confTx);
}
}
}
if (vpnId != null || internetVpnId != null) {
// remove vpn-interface for this neutron port
LOG.debug("removing VPN Interface for port {}", portName);
if (!routerIds.isEmpty()) {
for (Uuid routerId : routerIds) {
nvpnManager.removeFromNeutronRouterInterfacesMap(routerId, portName);
}
}
nvpnManager.deleteVpnInterface(portName, null, /* vpn-id */
confTx);
}
// Remove of-port interface for this neutron port
// ELAN interface is also implicitly deleted as part of this operation
LOG.debug("Of-port-interface removal for port {}", portName);
deleteOfPortInterface(port, confTx);
// dissociate fixedIP from floatingIP if associated
nvpnManager.dissociatefixedIPFromFloatingIP(port.getUuid().getValue());
});
LoggingFutures.addErrorLogging(future, LOG, "handleNeutronPortDeleted: Failed to update interface {} with networkId", portName, port.getNetworkId().getValue());
return Collections.singletonList(future);
});
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIpsKey in project netvirt by opendaylight.
the class NeutronSubnetGwMacResolver method sendArpRequestsToExtGatewayTask.
private void sendArpRequestsToExtGatewayTask(Router router) {
LOG.trace("Send ARP requests to external GW for router {}", router);
Port extPort = getRouterExtGatewayPort(router);
if (extPort == null) {
LOG.trace("External GW port for router {} is missing", router.getUuid().getValue());
return;
}
String extInterface = getExternalInterface(router);
if (extInterface == null) {
LOG.trace("No external interface defined for router {}", router.getUuid().getValue());
return;
}
Map<FixedIpsKey, FixedIps> keyFixedIpsMap = extPort.getFixedIps();
if (keyFixedIpsMap == null || keyFixedIpsMap.isEmpty()) {
LOG.trace("External GW port {} for router {} has no fixed IPs", extPort.getUuid().getValue(), router.getUuid().getValue());
return;
}
MacAddress macAddress = extPort.getMacAddress();
if (macAddress == null) {
LOG.trace("External GW port {} for router {} has no mac address", extPort.getUuid().getValue(), router.getUuid().getValue());
return;
}
for (FixedIps fixIp : keyFixedIpsMap.values()) {
Uuid subnetId = fixIp.getSubnetId();
IpAddress srcIpAddress = fixIp.getIpAddress();
IpAddress dstIpAddress = getExternalGwIpAddress(subnetId);
String srcIpAddressString = srcIpAddress.stringValue();
String dstIpAddressString = dstIpAddress.stringValue();
if (NWUtil.isIpv4Address(srcIpAddressString)) {
sendArpRequest(srcIpAddress, dstIpAddress, macAddress, extInterface);
} else {
sendNeighborSolication(new Ipv6Address(srcIpAddressString), macAddress, new Ipv6Address(dstIpAddressString), extInterface);
}
}
}
Aggregations