use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps in project netvirt by opendaylight.
the class VpnManagerImpl method removeArpResponderFlowsToExternalNetworkIps.
@Override
public void removeArpResponderFlowsToExternalNetworkIps(String id, Collection<String> fixedIps, String macAddress, BigInteger dpnId, Uuid extNetworkId) {
if (dpnId == null || BigInteger.ZERO.equals(dpnId)) {
LOG.warn("Failed to remove arp responder flows for router {}. DPN id is missing.", id);
return;
}
String extInterfaceName = elanService.getExternalElanInterface(extNetworkId.getValue(), dpnId);
if (extInterfaceName == null) {
LOG.warn("Failed to remove responder flows for {}. No external interface found for DPN id {}", id, dpnId);
return;
}
Interface extInterfaceState = InterfaceUtils.getInterfaceStateFromOperDS(dataBroker, extInterfaceName);
if (extInterfaceState == null) {
LOG.debug("No interface state found for interface {}. Delaying responder flows for {}", extInterfaceName, id);
return;
}
Integer lportTag = extInterfaceState.getIfIndex();
if (lportTag == null) {
LOG.debug("No Lport tag found for interface {}. Delaying flows for router-id {}", extInterfaceName, id);
return;
}
if (macAddress == null) {
LOG.debug("Failed to remove arp responder flows for router-gateway-ip {} for router {}." + "External Gw MacAddress is missing.", fixedIps, id);
return;
}
removeArpResponderFlowsToExternalNetworkIps(id, fixedIps, dpnId, extInterfaceName, lportTag);
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps in project netvirt by opendaylight.
the class NatUtil method getNeutronPortForIp.
public static Port getNeutronPortForIp(DataBroker broker, IpAddress targetIP, String deviceType) {
List<Port> ports = getNeutronPorts(broker);
for (Port port : ports) {
if (deviceType.equals(port.getDeviceOwner()) && port.getFixedIps() != null) {
for (FixedIps ip : port.getFixedIps()) {
if (Objects.equals(ip.getIpAddress(), targetIP)) {
return port;
}
}
}
}
LOG.error("getNeutronPortForIp : Neutron Port missing for IP:{} DeviceType:{}", targetIP, deviceType);
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps in project netvirt by opendaylight.
the class InterfaceStateEventListener method removeSnatEntriesForPort.
// TODO Clean up the exception handling
@SuppressWarnings("checkstyle:IllegalCatch")
private void removeSnatEntriesForPort(String interfaceName, String routerName) {
Long routerId = NatUtil.getVpnId(dataBroker, routerName);
if (routerId == NatConstants.INVALID_ID) {
LOG.error("removeSnatEntriesForPort : routerId not found for routername {}", routerName);
return;
}
BigInteger naptSwitch = getNaptSwitchforRouter(dataBroker, routerName);
if (naptSwitch == null || naptSwitch.equals(BigInteger.ZERO)) {
LOG.error("removeSnatEntriesForPort : NaptSwitch is not elected for router {} with Id {}", routerName, routerId);
return;
}
// getInternalIp for port
List<String> fixedIps = getFixedIpsForPort(interfaceName);
if (fixedIps == null) {
LOG.warn("removeSnatEntriesForPort : Internal Ips not found for InterfaceName {} in router {} with id {}", interfaceName, routerName, routerId);
return;
}
for (String internalIp : fixedIps) {
LOG.debug("removeSnatEntriesForPort : Internal Ip retrieved for interface {} is {} in router with Id {}", interfaceName, internalIp, routerId);
IpPort ipPort = NatUtil.getInternalIpPortInfo(dataBroker, routerId, internalIp);
if (ipPort == null) {
LOG.debug("removeSnatEntriesForPort : no snatint-ip-port-map found for ip:{}", internalIp);
continue;
}
for (IntIpProtoType protoType : ipPort.getIntIpProtoType()) {
ProtocolTypes protocol = protoType.getProtocol();
for (Integer portnum : protoType.getPorts()) {
// build and remove the flow in outbound table
try {
removeNatFlow(naptSwitch, NwConstants.OUTBOUND_NAPT_TABLE, routerId, internalIp, portnum);
} catch (Exception ex) {
LOG.error("removeSnatEntriesForPort : Failed to remove snat flow for internalIP {} with " + "Port {} protocol {} for routerId {} in OUTBOUNDTABLE of NaptSwitch {}", internalIp, portnum, protocol, routerId, naptSwitch, ex);
}
// Get the external IP address and the port from the model
NAPTEntryEvent.Protocol proto = protocol.toString().equals(ProtocolTypes.TCP.toString()) ? NAPTEntryEvent.Protocol.TCP : NAPTEntryEvent.Protocol.UDP;
IpPortExternal ipPortExternal = NatUtil.getExternalIpPortMap(dataBroker, routerId, internalIp, String.valueOf(portnum), proto);
if (ipPortExternal == null) {
LOG.error("removeSnatEntriesForPort : Mapping for internalIp {} with port {} is not found in " + "router with Id {}", internalIp, portnum, routerId);
return;
}
String externalIpAddress = ipPortExternal.getIpAddress();
Integer portNumber = ipPortExternal.getPortNum();
// build and remove the flow in inboundtable
try {
removeNatFlow(naptSwitch, NwConstants.INBOUND_NAPT_TABLE, routerId, externalIpAddress, portNumber);
} catch (Exception ex) {
LOG.error("removeSnatEntriesForPort : Failed to remove snat flow internalIP {} with " + "Port {} protocol {} for routerId {} in INBOUNDTABLE of naptSwitch {}", externalIpAddress, portNumber, protocol, routerId, naptSwitch, ex);
}
String internalIpPort = internalIp + ":" + portnum;
// delete the entry from IntExtIpPortMap DS
try {
naptManager.removeFromIpPortMapDS(routerId, internalIpPort, proto);
naptManager.removePortFromPool(internalIpPort, externalIpAddress);
} catch (Exception ex) {
LOG.error("removeSnatEntriesForPort : releaseIpExtPortMapping failed, Removal of " + "ipportmap {} for router {} failed", internalIpPort, routerId, ex);
}
}
}
// delete the entry from SnatIntIpPortMap DS
LOG.debug("removeSnatEntriesForPort : Removing InternalIp:{} on router {}", internalIp, routerId);
naptManager.removeFromSnatIpPortDS(routerId, internalIp);
}
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps in project netvirt by opendaylight.
the class InterfaceStateEventListener method getFixedIpsForPort.
private List<String> getFixedIpsForPort(String interfname) {
LOG.debug("getFixedIpsForPort : getFixedIpsForPort method is called for interface {}", interfname);
try {
Future<RpcResult<GetFixedIPsForNeutronPortOutput>> result = neutronVpnService.getFixedIPsForNeutronPort(new GetFixedIPsForNeutronPortInputBuilder().setPortId(new Uuid(interfname)).build());
RpcResult<GetFixedIPsForNeutronPortOutput> rpcResult = result.get();
if (!rpcResult.isSuccessful()) {
LOG.error("getFixedIpsForPort : RPC Call to GetFixedIPsForNeutronPortOutput returned with Errors {}", rpcResult.getErrors());
} else {
return rpcResult.getResult().getFixedIPs();
}
} catch (InterruptedException | ExecutionException | NullPointerException ex) {
LOG.error("getFixedIpsForPort : Exception while receiving fixedIps for port {}", interfname, ex);
}
return null;
}
use of org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.port.attributes.FixedIps in project netvirt by opendaylight.
the class NeutronPortChangeListener method add.
@Override
protected void add(InstanceIdentifier<Port> identifier, Port port) {
if (port.getDeviceOwner().equalsIgnoreCase(Ipv6Constants.NETWORK_ROUTER_GATEWAY)) {
// Todo: revisit when IPv6 north-south support is implemented.
LOG.info("IPv6Service (TODO): Skipping router_gateway port {} for add event", port);
return;
}
LOG.debug("Add port notification handler is invoked for port {} ", port);
List<FixedIps> ipList = port.getFixedIps();
for (FixedIps fixedip : ipList) {
if (fixedip.getIpAddress().getIpv4Address() != null) {
continue;
}
addInterfaceInfo(port, fixedip);
}
}
Aggregations