private void handleRouterGatewayUpdated(Port routerGwPort) { Uuid routerId = new Uuid(routerGwPort.getDeviceId()); Router router = NeutronvpnUtils.getNeutronRouter(dataBroker, routerId); if (router == null) { LOG.warn("No router found for router GW port {} router id {}", routerGwPort.getUuid(), routerId.getValue()); return; } gwMacResolver.sendArpRequestsToExtGateways(router); }
@Override protected void update(InstanceIdentifier<Port> identifier, Port original, Port update) { LOG.debug("update port notification handler is invoked..."); if (update.getDeviceOwner().equalsIgnoreCase(Ipv6Constants.NETWORK_ROUTER_INTERFACE)) { ifMgr.updateRouterIntf(update.getUuid(), new Uuid(update.getDeviceId()), update.getFixedIps()); } else { ifMgr.updateHostIntf(update.getUuid(), update.getFixedIps()); } }
@Override protected void remove(InstanceIdentifier<Port> identifier, Port input) { if (LOG.isTraceEnabled()) { LOG.trace("Removing Port : key: " + identifier + ", value=" + input); } Network network = NeutronvpnUtils.getNeutronNetwork(dataBroker, input.getNetworkId()); if (network == null || !NeutronvpnUtils.isNetworkTypeSupported(network)) { //FIXME: This should be removed when support for VLAN and GRE network types is added LOG.error("neutron vpn doesn't support vlan/gre network provider type for the port {} which is part of " + "network {}.", input.getName(), network); return; } NeutronvpnUtils.removeFromPortCache(input); if ((input.getDeviceOwner() != null) && (input.getDeviceId() != null)) { if (input.getDeviceOwner().equals(NeutronConstants.DEVICE_OWNER_ROUTER_INF)) { handleRouterInterfaceRemoved(input); /* nothing else to do here */ return; } } if (input.getFixedIps() != null && !input.getFixedIps().isEmpty()) { handleNeutronPortDeleted(input); } }
if(!ports.getPort().isEmpty()) { for( Port port : ports.getPort()) { if (port.getDeviceId().equals(router.getUuid().getValue()) && port.getDeviceOwner().equals(OWNER_ROUTER_INTERFACE)) { LOG.debug("L3 Cache Population : Router interface {} found.",port);
private static ContextId resolveL3ContextForPort(Port port, FixedIps portFixedIPs, Neutron neutron) { Set<Port> routerIfacePorts = PortUtils.findRouterInterfacePorts(neutron.getPorts()); for (Port routerIfacePort : routerIfacePorts) { Uuid routerIfacePortSubnet = routerIfacePort.getFixedIps().get(0).getSubnetId(); // if port is in the same subnet as router interface then we want to use L3Context of // router if (portFixedIPs.getSubnetId().equals(routerIfacePortSubnet)) { LOG.trace("Router interface port was found in the same subnet as port have {}", port); return new ContextId(routerIfacePort.getDeviceId()); } } return new ContextId(port.getNetworkId().getValue()); } }
@Override protected void add(InstanceIdentifier<Port> identifier, Port input) { if (LOG.isTraceEnabled()) { LOG.trace("Adding Port : key: " + identifier + ", value=" + input); } Network network = NeutronvpnUtils.getNeutronNetwork(dataBroker, input.getNetworkId()); if (network == null || !NeutronvpnUtils.isNetworkTypeSupported(network)) { //FIXME: This should be removed when support for VLAN and GRE network types is added LOG.error("neutron vpn doesn't support vlan/gre network provider type for the port {} " + "which is part of network {}.", input.getName(), network); return; } NeutronvpnUtils.addToPortCache(input); /* check if router interface has been created */ if ((input.getDeviceOwner() != null) && (input.getDeviceId() != null)) { if (input.getDeviceOwner().equals(NeutronConstants.DEVICE_OWNER_ROUTER_INF)) { handleRouterInterfaceAdded(input); /* nothing else to do here */ return; } if (NeutronConstants.DEVICE_OWNER_GATEWAY_INF.equals(input.getDeviceOwner())) { handleRouterGatewayUpdated(input); } } if (input.getFixedIps() != null && !input.getFixedIps().isEmpty()) { handleNeutronPortCreated(input); } }
if(!ports.getPort().isEmpty()) { for( Port port : ports.getPort()) { if (port.getDeviceId().equals(router.getUuid().getValue()) && port.getDeviceOwner().equals(OWNER_ROUTER_INTERFACE)) { LOG.debug("L3 Cache Population : Router interface {} found.",port);
private void handleRouterInterfaceRemoved(Port routerPort) { if (routerPort.getDeviceId() != null) { Uuid routerId = new Uuid(routerPort.getDeviceId()); for (FixedIps portIP : routerPort.getFixedIps()) { if (portIP.getIpAddress().getIpv4Address() != null) { Uuid vpnId = NeutronvpnUtils.getVpnForRouter(dataBroker, routerId, true); if(vpnId == null) { vpnId = routerId; } nvpnManager.removeSubnetFromVpn(vpnId, portIP.getSubnetId()); nvpnManager.updateSubnetNodeWithFixedIps(portIP.getSubnetId(), null, null, null, null); nvpnNatManager.handleSubnetsForExternalRouter(routerId, dataBroker); String ipValue = portIP.getIpAddress().getIpv4Address().getValue(); NeutronvpnUtils.removeVpnPortFixedIpToPort(dataBroker, vpnId.getValue(), ipValue); } else { LOG.error("No IPv4 address assigned to port {)", routerPort.getUuid().getValue()); } } } }
@Deprecated private static L3Address resolveL3AddressFromPort(Port port, FixedIps portFixedIPs, Neutron neutron) { Set<Port> routerIfacePorts = PortUtils.findRouterInterfacePorts(neutron.getPorts()); for (Port routerIfacePort : routerIfacePorts) { Uuid routerIfacePortSubnet = routerIfacePort.getFixedIps().get(0).getSubnetId(); // if port is in the same subnet as router interface then we want to use L3Context of // router if (portFixedIPs.getSubnetId().equals(routerIfacePortSubnet)) { L3ContextId epL3ContextId = new L3ContextId(routerIfacePort.getDeviceId()); LOG.trace("Router interface port was found in the same subnet as port have {}", port); return new L3AddressBuilder().setL3Context(epL3ContextId) .setIpAddress(portFixedIPs.getIpAddress()) .build(); } } return new L3AddressBuilder().setL3Context(new L3ContextId(port.getNetworkId().getValue())) .setIpAddress(portFixedIPs.getIpAddress()) .build(); }
if ((update.getDeviceOwner() != null) && (update.getDeviceId() != null)) { if (update.getDeviceOwner().equals(NeutronConstants.DEVICE_OWNER_ROUTER_INF)) { handleRouterInterfaceAdded(update);
result.setDeviceID(port.getDeviceId()); result.setDeviceOwner(port.getDeviceOwner()); if (port.getExtraDhcpOpts() != null) {
result.setDeviceID(port.getDeviceId()); result.setDeviceOwner(port.getDeviceOwner()); if (port.getExtraDhcpOpts() != null) {
result.setDeviceID(port.getDeviceId()); result.setDeviceOwner(port.getDeviceOwner()); if (port.getExtraDhcpOpts() != null) {
result.setDeviceID(port.getDeviceId()); result.setDeviceOwner(port.getDeviceOwner()); if (port.getExtraDhcpOpts() != null) {
@Override protected void add(InstanceIdentifier<Port> identifier, Port port) { LOG.info("Add port notification handler is invoked..."); List<FixedIps> ipList = port.getFixedIps(); for (FixedIps fixedip : ipList) { if (fixedip.getIpAddress().getIpv4Address() != null) { continue; } if (port.getDeviceOwner().equalsIgnoreCase(Ipv6Constants.NETWORK_ROUTER_INTERFACE)) { // Add router interface ifMgr.addRouterIntf(port.getUuid(), new Uuid(port.getDeviceId()), fixedip.getSubnetId(), port.getNetworkId(), fixedip.getIpAddress(), port.getMacAddress().getValue(), port.getDeviceOwner()); } else { // Add host interface ifMgr.addHostIntf(port.getUuid(), fixedip.getSubnetId(), port.getNetworkId(), fixedip.getIpAddress(), port.getMacAddress().getValue(), port.getDeviceOwner()); } } }
result.setDeviceID(port.getDeviceId()); result.setDeviceOwner(port.getDeviceOwner()); if (port.getExtraDhcpOpts() != null) {
ContextId routerL3Context = new ContextId(port.getDeviceId());
private void handleRouterInterfaceAdded(Port routerPort) { if (routerPort.getDeviceId() != null) { Uuid routerId = new Uuid(routerPort.getDeviceId()); Uuid infNetworkId = routerPort.getNetworkId(); Uuid existingVpnId = NeutronvpnUtils.getVpnForNetwork(dataBroker, infNetworkId);