Search in sources :

Example 16 with Objective

use of org.onosproject.net.flowobjective.Objective in project onos by opennetworkinglab.

the class DhcpRelayManagerTest method testInstallIgnoreRuleWhenDeviceComesUp.

/**
 * Should try install ignore rules when device comes up.
 */
@Test
public void testInstallIgnoreRuleWhenDeviceComesUp() throws IOException {
    ObjectMapper om = new ObjectMapper();
    JsonNode json = om.readTree(Resources.getResource(CONFIG_FILE_PATH));
    IgnoreDhcpConfig config = new IgnoreDhcpConfig();
    json = json.path("apps").path(DHCP_RELAY_APP).path(IgnoreDhcpConfig.KEY);
    config.init(APP_ID, IgnoreDhcpConfig.KEY, json, om, null);
    reset(manager.cfgService, flowObjectiveService, manager.deviceService);
    expect(manager.cfgService.getConfig(APP_ID, IgnoreDhcpConfig.class)).andReturn(config).anyTimes();
    Device device = createNiceMock(Device.class);
    expect(device.is(Pipeliner.class)).andReturn(true).anyTimes();
    expect(device.id()).andReturn(DEV_1_ID).anyTimes();
    expect(manager.deviceService.getDevice(DEV_1_ID)).andReturn(device).anyTimes();
    DeviceEvent event = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED, device);
    Capture<Objective> capturedFromDev1 = newCapture(CaptureType.ALL);
    flowObjectiveService.apply(eq(DEV_1_ID), capture(capturedFromDev1));
    expectLastCall().times(DHCP_SELECTORS.size());
    replay(manager.cfgService, flowObjectiveService, manager.deviceService, device);
    manager.deviceListener.event(event);
    // Wait until all flow objective events are captured before triggering onSuccess
    int expectFlowObjCount = Dhcp4HandlerImpl.DHCP_SELECTORS.size() + Dhcp6HandlerImpl.DHCP_SELECTORS.size();
    assertAfter(EVENT_PROCESSING_MS, () -> assertEquals(expectFlowObjCount, capturedFromDev1.getValues().size()));
    capturedFromDev1.getValues().forEach(obj -> obj.context().ifPresent(ctx -> ctx.onSuccess(obj)));
    assertAfter(EVENT_PROCESSING_MS, () -> assertEquals(1, v4Handler.ignoredVlans.size()));
    assertAfter(EVENT_PROCESSING_MS, () -> assertEquals(1, v6Handler.ignoredVlans.size()));
}
Also used : NetworkConfigRegistry(org.onosproject.net.config.NetworkConfigRegistry) Dhcp6IaPdOption(org.onlab.packet.dhcp.Dhcp6IaPdOption) DeviceService(org.onosproject.net.device.DeviceService) ARP(org.onlab.packet.ARP) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) InterfaceServiceAdapter(org.onosproject.net.intf.InterfaceServiceAdapter) Pair(org.apache.commons.lang3.tuple.Pair) IgnoreDhcpConfig(org.onosproject.dhcprelay.config.IgnoreDhcpConfig) Map(java.util.Map) ApplicationId(org.onosproject.core.ApplicationId) JsonNode(com.fasterxml.jackson.databind.JsonNode) DhcpRelayCounters(org.onosproject.dhcprelay.store.DhcpRelayCounters) Dhcp6IaNaOption(org.onlab.packet.dhcp.Dhcp6IaNaOption) Ip6Address(org.onlab.packet.Ip6Address) DhcpRelayStore(org.onosproject.dhcprelay.store.DhcpRelayStore) Ip4Address(org.onlab.packet.Ip4Address) Set(java.util.Set) StoreDelegate(org.onosproject.store.StoreDelegate) DeviceEvent(org.onosproject.net.device.DeviceEvent) DhcpServerConfig(org.onosproject.dhcprelay.config.DhcpServerConfig) DeviceId(org.onosproject.net.DeviceId) Dictionary(java.util.Dictionary) Pipeliner(org.onosproject.net.behaviour.Pipeliner) Host(org.onosproject.net.Host) ComponentContext(org.osgi.service.component.ComponentContext) HostService(org.onosproject.net.host.HostService) ArrayList(java.util.ArrayList) Dhcp6InterfaceIdOption(org.onlab.packet.dhcp.Dhcp6InterfaceIdOption) DhcpRelayStoreEvent(org.onosproject.dhcprelay.store.DhcpRelayStoreEvent) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DeserializationException(org.onlab.packet.DeserializationException) CircuitId(org.onlab.packet.dhcp.CircuitId) DhcpRelayAgentOption(org.onlab.packet.dhcp.DhcpRelayAgentOption) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Before(org.junit.Before) Charsets(org.apache.commons.io.Charsets) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) Capture(org.easymock.Capture) Resources(com.google.common.io.Resources) VlanId(org.onlab.packet.VlanId) Test(org.junit.Test) IOException(java.io.IOException) EasyMock(org.easymock.EasyMock) Dhcp6IaAddressOption(org.onlab.packet.dhcp.Dhcp6IaAddressOption) IPv6(org.onlab.packet.IPv6) IPv4(org.onlab.packet.IPv4) DHCP6(org.onlab.packet.DHCP6) DhcpRecord(org.onosproject.dhcprelay.store.DhcpRecord) Objective(org.onosproject.net.flowobjective.Objective) MacAddress(org.onlab.packet.MacAddress) Dhcp6Duid(org.onlab.packet.dhcp.Dhcp6Duid) DHCP(org.onlab.packet.DHCP) Assert(org.junit.Assert) DefaultDhcpRelayConfig(org.onosproject.dhcprelay.config.DefaultDhcpRelayConfig) Route(org.onosproject.routeservice.Route) HostLocation(org.onosproject.net.HostLocation) Interface(org.onosproject.net.intf.Interface) TestApplicationId(org.onosproject.TestApplicationId) CoreService(org.onosproject.core.CoreService) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) Dhcp6ClientIdOption(org.onlab.packet.dhcp.Dhcp6ClientIdOption) ByteBuffer(java.nio.ByteBuffer) Ethernet(org.onlab.packet.Ethernet) HostProviderService(org.onosproject.net.host.HostProviderService) Dhcp6IaPrefixOption(org.onlab.packet.dhcp.Dhcp6IaPrefixOption) After(org.junit.After) ImmutableSet(com.google.common.collect.ImmutableSet) Device(org.onosproject.net.Device) Collection(java.util.Collection) PacketProcessor(org.onosproject.net.packet.PacketProcessor) Streams(com.google.common.collect.Streams) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) TestTools.assertAfter(org.onlab.junit.TestTools.assertAfter) IndirectDhcpRelayConfig(org.onosproject.dhcprelay.config.IndirectDhcpRelayConfig) List(java.util.List) InboundPacket(org.onosproject.net.packet.InboundPacket) PacketContext(org.onosproject.net.packet.PacketContext) Optional(java.util.Optional) HostDescription(org.onosproject.net.host.HostDescription) IpPrefix(org.onlab.packet.IpPrefix) PacketContextAdapter(org.onosproject.net.packet.PacketContextAdapter) RouteStoreAdapter(org.onosproject.routeservice.RouteStoreAdapter) Dhcp6RelayOption(org.onlab.packet.dhcp.Dhcp6RelayOption) DhcpRelayCountersStore(org.onosproject.dhcprelay.store.DhcpRelayCountersStore) FlowObjectiveService(org.onosproject.net.flowobjective.FlowObjectiveService) DefaultHost(org.onosproject.net.DefaultHost) ImmutableList(com.google.common.collect.ImmutableList) OutboundPacket(org.onosproject.net.packet.OutboundPacket) PacketServiceAdapter(org.onosproject.net.packet.PacketServiceAdapter) HostId(org.onosproject.net.HostId) DHCP_RELAY_APP(org.onosproject.dhcprelay.DhcpRelayManager.DHCP_RELAY_APP) IpAddress(org.onlab.packet.IpAddress) DefaultInboundPacket(org.onosproject.net.packet.DefaultInboundPacket) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Dhcp6Option(org.onlab.packet.dhcp.Dhcp6Option) Maps(com.google.common.collect.Maps) UDP(org.onlab.packet.UDP) DhcpOption(org.onlab.packet.dhcp.DhcpOption) CaptureType(org.easymock.CaptureType) PacketPriority(org.onosproject.net.packet.PacketPriority) IgnoreDhcpConfig(org.onosproject.dhcprelay.config.IgnoreDhcpConfig) DeviceEvent(org.onosproject.net.device.DeviceEvent) Objective(org.onosproject.net.flowobjective.Objective) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) Pipeliner(org.onosproject.net.behaviour.Pipeliner) Device(org.onosproject.net.Device) JsonNode(com.fasterxml.jackson.databind.JsonNode) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ConnectPoint(org.onosproject.net.ConnectPoint) Test(org.junit.Test)

Example 17 with Objective

use of org.onosproject.net.flowobjective.Objective in project onos by opennetworkinglab.

the class DhcpRelayManagerTest method testIgnoreVlan.

/**
 * Ignores specific vlans from specific devices if config.
 *
 * @throws Exception the exception from this test
 */
@Test
public void testIgnoreVlan() throws Exception {
    ObjectMapper om = new ObjectMapper();
    JsonNode json = om.readTree(Resources.getResource(CONFIG_FILE_PATH));
    IgnoreDhcpConfig config = new IgnoreDhcpConfig();
    json = json.path("apps").path(DHCP_RELAY_APP).path(IgnoreDhcpConfig.KEY);
    config.init(APP_ID, IgnoreDhcpConfig.KEY, json, om, null);
    Capture<Objective> capturedFromDev1 = newCapture(CaptureType.ALL);
    flowObjectiveService.apply(eq(DEV_1_ID), capture(capturedFromDev1));
    expectLastCall().times(DHCP_SELECTORS.size());
    Capture<Objective> capturedFromDev2 = newCapture(CaptureType.ALL);
    flowObjectiveService.apply(eq(DEV_2_ID), capture(capturedFromDev2));
    expectLastCall().times(DHCP_SELECTORS.size());
    replay(flowObjectiveService);
    manager.updateConfig(config);
    verify(flowObjectiveService);
    List<Objective> objectivesFromDev1 = capturedFromDev1.getValues();
    List<Objective> objectivesFromDev2 = capturedFromDev2.getValues();
    assertTrue(objectivesFromDev1.containsAll(objectivesFromDev2));
    assertTrue(objectivesFromDev2.containsAll(objectivesFromDev1));
    for (int index = 0; index < objectivesFromDev1.size(); index++) {
        TrafficSelector selector = DefaultTrafficSelector.builder(DHCP_SELECTORS.get(index)).matchVlanId(IGNORED_VLAN).build();
        ForwardingObjective fwd = (ForwardingObjective) objectivesFromDev1.get(index);
        assertEquals(selector, fwd.selector());
        assertEquals(DefaultTrafficTreatment.emptyTreatment(), fwd.treatment());
        assertEquals(IGNORE_CONTROL_PRIORITY, fwd.priority());
        assertEquals(ForwardingObjective.Flag.VERSATILE, fwd.flag());
        assertEquals(Objective.Operation.ADD, fwd.op());
        fwd.context().ifPresent(ctx -> {
            ctx.onSuccess(fwd);
        });
    }
    objectivesFromDev2.forEach(obj -> obj.context().ifPresent(ctx -> ctx.onSuccess(obj)));
    assertEquals(2, v4Handler.ignoredVlans.size());
    assertEquals(2, v6Handler.ignoredVlans.size());
}
Also used : NetworkConfigRegistry(org.onosproject.net.config.NetworkConfigRegistry) Dhcp6IaPdOption(org.onlab.packet.dhcp.Dhcp6IaPdOption) DeviceService(org.onosproject.net.device.DeviceService) ARP(org.onlab.packet.ARP) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) InterfaceServiceAdapter(org.onosproject.net.intf.InterfaceServiceAdapter) Pair(org.apache.commons.lang3.tuple.Pair) IgnoreDhcpConfig(org.onosproject.dhcprelay.config.IgnoreDhcpConfig) Map(java.util.Map) ApplicationId(org.onosproject.core.ApplicationId) JsonNode(com.fasterxml.jackson.databind.JsonNode) DhcpRelayCounters(org.onosproject.dhcprelay.store.DhcpRelayCounters) Dhcp6IaNaOption(org.onlab.packet.dhcp.Dhcp6IaNaOption) Ip6Address(org.onlab.packet.Ip6Address) DhcpRelayStore(org.onosproject.dhcprelay.store.DhcpRelayStore) Ip4Address(org.onlab.packet.Ip4Address) Set(java.util.Set) StoreDelegate(org.onosproject.store.StoreDelegate) DeviceEvent(org.onosproject.net.device.DeviceEvent) DhcpServerConfig(org.onosproject.dhcprelay.config.DhcpServerConfig) DeviceId(org.onosproject.net.DeviceId) Dictionary(java.util.Dictionary) Pipeliner(org.onosproject.net.behaviour.Pipeliner) Host(org.onosproject.net.Host) ComponentContext(org.osgi.service.component.ComponentContext) HostService(org.onosproject.net.host.HostService) ArrayList(java.util.ArrayList) Dhcp6InterfaceIdOption(org.onlab.packet.dhcp.Dhcp6InterfaceIdOption) DhcpRelayStoreEvent(org.onosproject.dhcprelay.store.DhcpRelayStoreEvent) Lists(com.google.common.collect.Lists) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DeserializationException(org.onlab.packet.DeserializationException) CircuitId(org.onlab.packet.dhcp.CircuitId) DhcpRelayAgentOption(org.onlab.packet.dhcp.DhcpRelayAgentOption) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) Before(org.junit.Before) Charsets(org.apache.commons.io.Charsets) ComponentConfigService(org.onosproject.cfg.ComponentConfigService) Capture(org.easymock.Capture) Resources(com.google.common.io.Resources) VlanId(org.onlab.packet.VlanId) Test(org.junit.Test) IOException(java.io.IOException) EasyMock(org.easymock.EasyMock) Dhcp6IaAddressOption(org.onlab.packet.dhcp.Dhcp6IaAddressOption) IPv6(org.onlab.packet.IPv6) IPv4(org.onlab.packet.IPv4) DHCP6(org.onlab.packet.DHCP6) DhcpRecord(org.onosproject.dhcprelay.store.DhcpRecord) Objective(org.onosproject.net.flowobjective.Objective) MacAddress(org.onlab.packet.MacAddress) Dhcp6Duid(org.onlab.packet.dhcp.Dhcp6Duid) DHCP(org.onlab.packet.DHCP) Assert(org.junit.Assert) DefaultDhcpRelayConfig(org.onosproject.dhcprelay.config.DefaultDhcpRelayConfig) Route(org.onosproject.routeservice.Route) HostLocation(org.onosproject.net.HostLocation) Interface(org.onosproject.net.intf.Interface) TestApplicationId(org.onosproject.TestApplicationId) CoreService(org.onosproject.core.CoreService) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) Dhcp6ClientIdOption(org.onlab.packet.dhcp.Dhcp6ClientIdOption) ByteBuffer(java.nio.ByteBuffer) Ethernet(org.onlab.packet.Ethernet) HostProviderService(org.onosproject.net.host.HostProviderService) Dhcp6IaPrefixOption(org.onlab.packet.dhcp.Dhcp6IaPrefixOption) After(org.junit.After) ImmutableSet(com.google.common.collect.ImmutableSet) Device(org.onosproject.net.Device) Collection(java.util.Collection) PacketProcessor(org.onosproject.net.packet.PacketProcessor) Streams(com.google.common.collect.Streams) InterfaceIpAddress(org.onosproject.net.host.InterfaceIpAddress) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) TestTools.assertAfter(org.onlab.junit.TestTools.assertAfter) IndirectDhcpRelayConfig(org.onosproject.dhcprelay.config.IndirectDhcpRelayConfig) List(java.util.List) InboundPacket(org.onosproject.net.packet.InboundPacket) PacketContext(org.onosproject.net.packet.PacketContext) Optional(java.util.Optional) HostDescription(org.onosproject.net.host.HostDescription) IpPrefix(org.onlab.packet.IpPrefix) PacketContextAdapter(org.onosproject.net.packet.PacketContextAdapter) RouteStoreAdapter(org.onosproject.routeservice.RouteStoreAdapter) Dhcp6RelayOption(org.onlab.packet.dhcp.Dhcp6RelayOption) DhcpRelayCountersStore(org.onosproject.dhcprelay.store.DhcpRelayCountersStore) FlowObjectiveService(org.onosproject.net.flowobjective.FlowObjectiveService) DefaultHost(org.onosproject.net.DefaultHost) ImmutableList(com.google.common.collect.ImmutableList) OutboundPacket(org.onosproject.net.packet.OutboundPacket) PacketServiceAdapter(org.onosproject.net.packet.PacketServiceAdapter) HostId(org.onosproject.net.HostId) DHCP_RELAY_APP(org.onosproject.dhcprelay.DhcpRelayManager.DHCP_RELAY_APP) IpAddress(org.onlab.packet.IpAddress) DefaultInboundPacket(org.onosproject.net.packet.DefaultInboundPacket) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Dhcp6Option(org.onlab.packet.dhcp.Dhcp6Option) Maps(com.google.common.collect.Maps) UDP(org.onlab.packet.UDP) DhcpOption(org.onlab.packet.dhcp.DhcpOption) CaptureType(org.easymock.CaptureType) PacketPriority(org.onosproject.net.packet.PacketPriority) IgnoreDhcpConfig(org.onosproject.dhcprelay.config.IgnoreDhcpConfig) Objective(org.onosproject.net.flowobjective.Objective) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) JsonNode(com.fasterxml.jackson.databind.JsonNode) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) ConnectPoint(org.onosproject.net.ConnectPoint) Test(org.junit.Test)

Example 18 with Objective

use of org.onosproject.net.flowobjective.Objective in project trellis-control by opennetworkinglab.

the class HostHandler method processIntfVlanUpdatedEvent.

/**
 * Update forwarding objective for unicast bridging and unicast routing.
 * Also check the validity of updated interface configuration on VLAN.
 *
 * @param deviceId device ID that host attaches to
 * @param portNum port number that host attaches to
 * @param vlanId Vlan ID configured on the switch port
 * @param popVlan true to pop Vlan tag at TrafficTreatment, false otherwise
 * @param install true to populate the objective, false to revoke
 */
// TODO Current implementation does not handle dual-homed hosts with auxiliary locations.
void processIntfVlanUpdatedEvent(DeviceId deviceId, PortNumber portNum, VlanId vlanId, boolean popVlan, boolean install) {
    ConnectPoint connectPoint = new ConnectPoint(deviceId, portNum);
    Set<Host> hosts = hostService.getConnectedHosts(connectPoint);
    if (hosts == null || hosts.size() == 0) {
        log.debug("processIntfVlanUpdatedEvent: No hosts connected to {}", connectPoint);
        return;
    }
    List<CompletableFuture<Void>> hostFutures = Lists.newArrayList();
    hosts.forEach(host -> hostFutures.add(hostWorkers.submit(() -> processIntfVlanUpdatedEventInternal(host, deviceId, portNum, vlanId, popVlan, install), host.id().hashCode())));
    // Let's wait for the completion of all hosts
    try {
        CompletableFuture.allOf(hostFutures.toArray(new CompletableFuture[0])).thenApply(objectives -> hostFutures.stream().map(CompletableFuture::join).collect(Collectors.toList())).get();
    } catch (InterruptedException | ExecutionException e) {
        log.warn("Exception caught when executing processIntfVlanUpdatedEvent futures");
        hostFutures.forEach(future -> future.cancel(false));
    }
}
Also used : HostLocation(org.onosproject.net.HostLocation) Tools(org.onlab.util.Tools) Host(org.onosproject.net.Host) PredictableExecutor(org.onlab.util.PredictableExecutor) PortNumber(org.onosproject.net.PortNumber) LoggerFactory(org.slf4j.LoggerFactory) Tools.groupedThreads(org.onlab.util.Tools.groupedThreads) CompletableFuture(java.util.concurrent.CompletableFuture) HostService(org.onosproject.net.host.HostService) ConnectPoint(org.onosproject.net.ConnectPoint) HashSet(java.util.HashSet) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) Lists(com.google.common.collect.Lists) PhasedRecoveryService(org.onosproject.segmentrouting.phasedrecovery.api.PhasedRecoveryService) HostEvent(org.onosproject.net.host.HostEvent) IpAddress(org.onlab.packet.IpAddress) Logger(org.slf4j.Logger) VlanId(org.onlab.packet.VlanId) Set(java.util.Set) Phase(org.onosproject.segmentrouting.phasedrecovery.api.Phase) ProbeMode(org.onosproject.net.host.ProbeMode) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) EthType(org.onlab.packet.EthType) List(java.util.List) Objective(org.onosproject.net.flowobjective.Objective) Optional(java.util.Optional) MacAddress(org.onlab.packet.MacAddress) DeviceId(org.onosproject.net.DeviceId) IpPrefix(org.onlab.packet.IpPrefix) CompletableFuture(java.util.concurrent.CompletableFuture) Host(org.onosproject.net.Host) ExecutionException(java.util.concurrent.ExecutionException) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 19 with Objective

use of org.onosproject.net.flowobjective.Objective in project trellis-control by opennetworkinglab.

the class RoutingRulePopulator method revokeRoute.

/**
 * Removes IP rules for a route when the next hop is gone.
 * This method should not be invoked directly without going through DefaultRoutingHandler.
 *
 * @param deviceId device ID of the device that next hop attaches to
 * @param prefix IP prefix of the route
 * @param hostMac MAC address of the next hop
 * @param hostVlanId Vlan ID of the nexthop
 * @param outPort port that next hop attaches to
 * @param directHost host is of type direct or indirect
 * @return future that carries the flow objective if succeeded, null if otherwise
 */
CompletableFuture<Objective> revokeRoute(DeviceId deviceId, IpPrefix prefix, MacAddress hostMac, VlanId hostVlanId, PortNumber outPort, boolean directHost) {
    log.debug("Revoke IP table entry for route {} at {}:{}", prefix, deviceId, outPort);
    ForwardingObjective.Builder fwdBuilder;
    try {
        fwdBuilder = routingFwdObjBuilder(deviceId, prefix, hostMac, hostVlanId, outPort, null, null, directHost, true);
    } catch (DeviceConfigNotFoundException e) {
        log.warn(e.getMessage() + " Aborting revokeIpRuleForHost.");
        return CompletableFuture.completedFuture(null);
    }
    if (fwdBuilder == null) {
        log.warn("Aborting host routing table entries due " + "to error for dev:{} route:{}", deviceId, prefix);
        return CompletableFuture.completedFuture(null);
    }
    CompletableFuture<Objective> future = new CompletableFuture<>();
    ObjectiveContext context = new DefaultObjectiveContext((objective) -> {
        log.debug("IP rule for route {} revoked", prefix);
        future.complete(objective);
    }, (objective, error) -> {
        log.warn("Failed to revoke IP rule for route {}: {}", prefix, error);
        future.complete(null);
    });
    srManager.flowObjectiveService.forward(deviceId, fwdBuilder.remove(context));
    return future;
}
Also used : ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) Objective(org.onosproject.net.flowobjective.Objective) CompletableFuture(java.util.concurrent.CompletableFuture) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) ObjectiveContext(org.onosproject.net.flowobjective.ObjectiveContext) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) Builder(org.onosproject.net.flowobjective.ForwardingObjective.Builder) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) DeviceConfigNotFoundException(org.onosproject.segmentrouting.config.DeviceConfigNotFoundException)

Example 20 with Objective

use of org.onosproject.net.flowobjective.Objective in project trellis-control by opennetworkinglab.

the class RoutingRulePopulator method populateBridging.

/**
 * Populate a bridging rule on given deviceId that matches given mac, given vlan and
 * output to given port.
 *
 * @param deviceId device ID
 * @param port port
 * @param mac mac address
 * @param vlanId VLAN ID
 * @return future that carries the flow objective if succeeded, null if otherwise
 */
CompletableFuture<Objective> populateBridging(DeviceId deviceId, PortNumber port, MacAddress mac, VlanId vlanId) {
    ForwardingObjective.Builder fob = bridgingFwdObjBuilder(deviceId, mac, vlanId, port, false);
    if (fob == null) {
        log.warn("Fail to build fwd obj for host {}/{}. Abort.", mac, vlanId);
        return CompletableFuture.completedFuture(null);
    }
    CompletableFuture<Objective> future = new CompletableFuture<>();
    ObjectiveContext context = new DefaultObjectiveContext((objective) -> {
        log.debug("Brigding rule for {}/{} populated", mac, vlanId);
        future.complete(objective);
    }, (objective, error) -> {
        log.warn("Failed to populate bridging rule for {}/{}: {}", mac, vlanId, error);
        future.complete(null);
    });
    srManager.flowObjectiveService.forward(deviceId, fob.add(context));
    return future;
}
Also used : ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultFilteringObjective(org.onosproject.net.flowobjective.DefaultFilteringObjective) FilteringObjective(org.onosproject.net.flowobjective.FilteringObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective) Objective(org.onosproject.net.flowobjective.Objective) CompletableFuture(java.util.concurrent.CompletableFuture) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) ObjectiveContext(org.onosproject.net.flowobjective.ObjectiveContext) DefaultObjectiveContext(org.onosproject.net.flowobjective.DefaultObjectiveContext) Builder(org.onosproject.net.flowobjective.ForwardingObjective.Builder) ForwardingObjective(org.onosproject.net.flowobjective.ForwardingObjective) DefaultForwardingObjective(org.onosproject.net.flowobjective.DefaultForwardingObjective)

Aggregations

Objective (org.onosproject.net.flowobjective.Objective)64 ForwardingObjective (org.onosproject.net.flowobjective.ForwardingObjective)58 DefaultForwardingObjective (org.onosproject.net.flowobjective.DefaultForwardingObjective)42 FilteringObjective (org.onosproject.net.flowobjective.FilteringObjective)42 NextObjective (org.onosproject.net.flowobjective.NextObjective)42 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)38 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)37 TrafficSelector (org.onosproject.net.flow.TrafficSelector)37 ObjectiveContext (org.onosproject.net.flowobjective.ObjectiveContext)36 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)34 DeviceId (org.onosproject.net.DeviceId)32 DefaultFilteringObjective (org.onosproject.net.flowobjective.DefaultFilteringObjective)29 ConnectPoint (org.onosproject.net.ConnectPoint)27 DefaultNextObjective (org.onosproject.net.flowobjective.DefaultNextObjective)27 List (java.util.List)26 ObjectiveError (org.onosproject.net.flowobjective.ObjectiveError)26 Set (java.util.Set)25 Lists (com.google.common.collect.Lists)24 CompletableFuture (java.util.concurrent.CompletableFuture)24 Collectors (java.util.stream.Collectors)24