public static boolean isDhcpPort(Port port) { return DEVICE_OWNER_DHCP.equals(port.getDeviceOwner()); }
public static boolean isFloatingIpPort(Port port) { return DEVICE_OWNER_FLOATING_IP.equals(port.getDeviceOwner()); } }
public static boolean isRouterInterfacePort(Port port) { return DEVICE_OWNER_ROUTER_IFACE.equals(port.getDeviceOwner()); }
public static boolean isRouterGatewayPort(Port port) { return DEVICE_OWNER_ROUTER_GATEWAY.equals(port.getDeviceOwner()); }
public static boolean isQrouterPort(Port port) { return DEVICE_OWNER_ROUTER_IFACE.equals(port.getDeviceOwner()) && port.getAugmentation(PortBindingExtension.class) != null && DEVICE_VIF_TYPE.equals(port.getAugmentation(PortBindingExtension.class).getVifType()); }
@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); } }
public static Port getNeutronPortForFloatingIp(DataBroker broker, org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.inet.types.rev130715.IpAddress targetIP) { InstanceIdentifier<Ports> portsIdentifier = InstanceIdentifier.create(Neutron.class).child(Ports.class); Optional<Ports> portsOptional = VpnUtil.read(broker, LogicalDatastoreType.CONFIGURATION, portsIdentifier); if (!portsOptional.isPresent() || portsOptional.get().getPort() == null) { LOG.trace("No neutron ports found"); return null; } for (Port port : portsOptional.get().getPort()) { if (NeutronConstants.DEVICE_OWNER_FLOATING_IP.equals(port.getDeviceOwner()) && port.getFixedIps() != null) { for (FixedIps ip : port.getFixedIps()) { if (Objects.equals(ip.getIpAddress(), targetIP)) { return port; } } } } return null; }
public static Port getNeutronPortForIp(DataBroker broker, IpAddress targetIP, String deviceType) { InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports> portsIdentifier = InstanceIdentifier .create(Neutron.class) .child(org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports.class); Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.neutron.ports.rev150712.ports.attributes.Ports> portsOptional = read( broker, LogicalDatastoreType.CONFIGURATION, portsIdentifier); if (!portsOptional.isPresent() || portsOptional.get().getPort() == null) { LOG.trace("No neutron ports found"); return null; } for (Port port : portsOptional.get().getPort()) { if (deviceType.equals(port.getDeviceOwner()) && port.getFixedIps() != null) { for (FixedIps ip : port.getFixedIps()) { if (Objects.equals(ip.getIpAddress(), targetIP)) { return port; } } } } return null; }
@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); } }
@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()); } }
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); networkIdToRouterMacCache.put(port.getNetworkId().getValue()
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); networkIdToRouterMacCache.put(port.getNetworkId().getValue()
@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()); } } }
if ((update.getDeviceOwner() != null) && (update.getDeviceId() != null)) { if (update.getDeviceOwner().equals(NeutronConstants.DEVICE_OWNER_ROUTER_INF)) { handleRouterInterfaceAdded(update); if (NeutronConstants.DEVICE_OWNER_GATEWAY_INF.equals(update.getDeviceOwner())) { handleRouterGatewayUpdated(update);
private void unregisterEndpointAndRemoveMapping(UnregisterEndpointInput baseEpUnreg, Port port, ReadWriteTransaction rwTx) { boolean isUnregisteredBaseEndpoint = epRegistrator.unregisterEndpoint(baseEpUnreg); if (isUnregisteredBaseEndpoint) { 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); LOG.trace("Removing Port-BaseEndpoint mapping for port {} (device owner {}) and endpoint {}", port.getUuid().getValue(), port.getDeviceOwner(), portByBaseEndpointKey); removeBaseEndpointMappings(portByBaseEndpointKey, portId, rwTx); } }
@Deprecated private void registerEndpointAndStoreMapping( org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.RegisterEndpointInput regEpInput, Port port, ReadWriteTransaction rwTx) { boolean isRegisteredEndpoint = epRegistrator.registerEndpoint(regEpInput); if (!isRegisteredEndpoint) { LOG.error("Failed to register an endpoint: {}", regEpInput); return; } UniqueId portId = new UniqueId(port.getUuid().getValue()); EndpointKey epKey = new EndpointKey(new L2BridgeDomainId(port.getNetworkId().getValue()), new MacAddress( port.getMacAddress().getValue())); LOG.trace("Adding Port-Endpoint mapping for port {} (device owner {}) and endpoint {}", port.getUuid() .getValue(), port.getDeviceOwner(), epKey); EndpointByPort endpointByPort = MappingFactory.createEndpointByPort(epKey, portId); rwTx.put(LogicalDatastoreType.OPERATIONAL, NeutronGbpIidFactory.endpointByPortIid(portId), endpointByPort, true); PortByEndpoint portByEndpoint = MappingFactory.createPortByEndpoint(portId, epKey); rwTx.put(LogicalDatastoreType.OPERATIONAL, NeutronGbpIidFactory.portByEndpointIid(epKey.getL2Context(), epKey.getMacAddress()), portByEndpoint, true); }
@Deprecated private void unregisterEndpointAndRemoveMapping( org.opendaylight.yang.gen.v1.urn.opendaylight.groupbasedpolicy.endpoint.rev140421.UnregisterEndpointInput unregEpInput, Port port, ReadWriteTransaction rwTx) { boolean isUnregisteredEndpoint = epRegistrator.unregisterEndpoint(unregEpInput); if (isUnregisteredEndpoint) { UniqueId portId = new UniqueId(port.getUuid().getValue()); EndpointKey epKey = new EndpointKey(new L2BridgeDomainId(port.getNetworkId().getValue()), new MacAddress( port.getMacAddress().getValue())); LOG.trace("Removing Port-Endpoint mapping for port {} (device owner {}) and endpoint {}", port.getUuid() .getValue(), port.getDeviceOwner(), epKey); DataStoreHelper.removeIfExists(LogicalDatastoreType.OPERATIONAL, NeutronGbpIidFactory.endpointByPortIid(portId), rwTx); DataStoreHelper.removeIfExists(LogicalDatastoreType.OPERATIONAL, NeutronGbpIidFactory.portByEndpointIid(epKey.getL2Context(), epKey.getMacAddress()), rwTx); } }
result.setDeviceOwner(port.getDeviceOwner()); if (port.getExtraDhcpOpts() != null) { List<NeutronPort_ExtraDHCPOption> options = new ArrayList<>();
result.setDeviceOwner(port.getDeviceOwner()); if (port.getExtraDhcpOpts() != null) { List<NeutronPort_ExtraDHCPOption> options = new ArrayList<>();
result.setDeviceOwner(port.getDeviceOwner()); if (port.getExtraDhcpOpts() != null) { List<NeutronPort_ExtraDHCPOption> options = new ArrayList<>();