Search in sources :

Example 1 with EncapsulationConstraint

use of org.onosproject.net.intent.constraint.EncapsulationConstraint in project onos by opennetworkinglab.

the class SdnIpFib method encapUpdate.

/*
     * Triggered when the network configuration configuration is modified.
     * It checks if the encapsulation type has changed from last time, and in
     * case modifies all intents.
     */
private void encapUpdate() {
    synchronized (this) {
        // Get the encapsulation type just set from the configuration
        EncapsulationType encap = encap();
        for (Map.Entry<IpPrefix, MultiPointToSinglePointIntent> entry : routeIntents.entrySet()) {
            // Get each intent currently registered by SDN-IP
            MultiPointToSinglePointIntent intent = entry.getValue();
            // Make sure the same constraint is not already part of the
            // intent constraints
            List<Constraint> constraints = intent.constraints();
            if (!constraints.stream().filter(c -> c instanceof EncapsulationConstraint && new EncapsulationConstraint(encap).equals(c)).findAny().isPresent()) {
                MultiPointToSinglePointIntent.Builder intentBuilder = MultiPointToSinglePointIntent.builder(intent);
                // Set the new encapsulation constraint
                setEncap(intentBuilder, constraints, encap);
                // Build and submit the new intent
                MultiPointToSinglePointIntent newIntent = intentBuilder.build();
                routeIntents.put(entry.getKey(), newIntent);
                intentSynchronizer.submit(newIntent);
            }
        }
    }
}
Also used : IpPrefix(org.onlab.packet.IpPrefix) NetworkConfigService(org.onosproject.net.config.NetworkConfigService) Interface(org.onosproject.net.intf.Interface) CoreService(org.onosproject.core.CoreService) NONE(org.onosproject.net.EncapsulationType.NONE) NetworkConfigEvent(org.onosproject.net.config.NetworkConfigEvent) LoggerFactory(org.slf4j.LoggerFactory) RouteEvent(org.onosproject.routeservice.RouteEvent) InterfaceService(org.onosproject.net.intf.InterfaceService) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ConnectPoint(org.onosproject.net.ConnectPoint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) ArrayList(java.util.ArrayList) Ethernet(org.onlab.packet.Ethernet) InterfaceListener(org.onosproject.net.intf.InterfaceListener) Component(org.osgi.service.component.annotations.Component) TrafficSelector(org.onosproject.net.flow.TrafficSelector) ImmutableList(com.google.common.collect.ImmutableList) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) Map(java.util.Map) ApplicationId(org.onosproject.core.ApplicationId) PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) Activate(org.osgi.service.component.annotations.Activate) IntentSynchronizationService(org.onosproject.intentsync.IntentSynchronizationService) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) IpAddress(org.onlab.packet.IpAddress) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) RouteService(org.onosproject.routeservice.RouteService) SdnIpConfig(org.onosproject.sdnip.config.SdnIpConfig) Logger(org.slf4j.Logger) Deactivate(org.osgi.service.component.annotations.Deactivate) VlanId(org.onlab.packet.VlanId) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Set(java.util.Set) InterfaceEvent(org.onosproject.net.intf.InterfaceEvent) Sets(com.google.common.collect.Sets) Constraint(org.onosproject.net.intent.Constraint) RouteListener(org.onosproject.routeservice.RouteListener) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) Key(org.onosproject.net.intent.Key) List(java.util.List) EncapsulationType(org.onosproject.net.EncapsulationType) ConnectivityIntent(org.onosproject.net.intent.ConnectivityIntent) MacAddress(org.onlab.packet.MacAddress) Reference(org.osgi.service.component.annotations.Reference) ResolvedRoute(org.onosproject.routeservice.ResolvedRoute) NetworkConfigListener(org.onosproject.net.config.NetworkConfigListener) IpPrefix(org.onlab.packet.IpPrefix) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) EncapsulationType(org.onosproject.net.EncapsulationType) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) Constraint(org.onosproject.net.intent.Constraint) Map(java.util.Map) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent)

Example 2 with EncapsulationConstraint

use of org.onosproject.net.intent.constraint.EncapsulationConstraint in project onos by opennetworkinglab.

the class SimpleFabricRouting method buildConstraints.

// constraints generator
private List<Constraint> buildConstraints(List<Constraint> constraints, EncapsulationType encap) {
    if (!encap.equals(EncapsulationType.NONE)) {
        List<Constraint> newConstraints = new ArrayList<>(constraints);
        constraints.stream().filter(c -> c instanceof EncapsulationConstraint).forEach(newConstraints::remove);
        newConstraints.add(new EncapsulationConstraint(encap));
        return ImmutableList.copyOf(newConstraints);
    }
    return constraints;
}
Also used : HashedPathSelectionConstraint(org.onosproject.net.intent.constraint.HashedPathSelectionConstraint) REACTIVE_MATCH_IP_PROTO(org.onosproject.simplefabric.api.Constants.REACTIVE_MATCH_IP_PROTO) DefaultFlowRule(org.onosproject.net.flow.DefaultFlowRule) Interface(org.onosproject.net.intf.Interface) FabricNetwork(org.onosproject.simplefabric.api.FabricNetwork) CoreService(org.onosproject.core.CoreService) DeviceService(org.onosproject.net.device.DeviceService) LoggerFactory(org.slf4j.LoggerFactory) ALLOW_ETH_ADDRESS_SELECTOR(org.onosproject.simplefabric.api.Constants.ALLOW_ETH_ADDRESS_SELECTOR) ROUTING_APP_ID(org.onosproject.simplefabric.api.Constants.ROUTING_APP_ID) DefaultTrafficTreatment(org.onosproject.net.flow.DefaultTrafficTreatment) ByteBuffer(java.nio.ByteBuffer) ConnectPoint(org.onosproject.net.ConnectPoint) Ethernet(org.onlab.packet.Ethernet) FlowRuleService(org.onosproject.net.flow.FlowRuleService) SimpleFabricEvent(org.onosproject.simplefabric.api.SimpleFabricEvent) ApplicationId(org.onosproject.core.ApplicationId) Ip4Prefix(org.onlab.packet.Ip4Prefix) PRI_REACTIVE_BORDER_STEP(org.onosproject.simplefabric.api.Constants.PRI_REACTIVE_BORDER_STEP) Ip6Address(org.onlab.packet.Ip6Address) Ip4Address(org.onlab.packet.Ip4Address) ALLOW_IPV6(org.onosproject.simplefabric.api.Constants.ALLOW_IPV6) Device(org.onosproject.net.Device) Deactivate(org.osgi.service.component.annotations.Deactivate) PacketProcessor(org.onosproject.net.packet.PacketProcessor) Set(java.util.Set) ICMP(org.onlab.packet.ICMP) PacketService(org.onosproject.net.packet.PacketService) Constraint(org.onosproject.net.intent.Constraint) EthType(org.onlab.packet.EthType) Key(org.onosproject.net.intent.Key) List(java.util.List) InboundPacket(org.onosproject.net.packet.InboundPacket) EncapsulationType(org.onosproject.net.EncapsulationType) REACTIVE_SINGLE_TO_SINGLE(org.onosproject.simplefabric.api.Constants.REACTIVE_SINGLE_TO_SINGLE) FlowRule(org.onosproject.net.flow.FlowRule) PacketContext(org.onosproject.net.packet.PacketContext) LinkService(org.onosproject.net.link.LinkService) PRI_REACTIVE_BORDER_INTERCEPT(org.onosproject.simplefabric.api.Constants.PRI_REACTIVE_BORDER_INTERCEPT) DeviceId(org.onosproject.net.DeviceId) PRI_REACTIVE_LOCAL_FORWARD(org.onosproject.simplefabric.api.Constants.PRI_REACTIVE_LOCAL_FORWARD) IpPrefix(org.onlab.packet.IpPrefix) REACTIVE_HASHED_PATH_SELECTION(org.onosproject.simplefabric.api.Constants.REACTIVE_HASHED_PATH_SELECTION) ICMP6(org.onlab.packet.ICMP6) Host(org.onosproject.net.Host) InterfaceService(org.onosproject.net.intf.InterfaceService) HostService(org.onosproject.net.host.HostService) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Component(org.osgi.service.component.annotations.Component) SimpleFabricListener(org.onosproject.simplefabric.api.SimpleFabricListener) TrafficSelector(org.onosproject.net.flow.TrafficSelector) ImmutableList(com.google.common.collect.ImmutableList) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) IntentService(org.onosproject.net.intent.IntentService) OutboundPacket(org.onosproject.net.packet.OutboundPacket) Intent(org.onosproject.net.intent.Intent) PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) Activate(org.osgi.service.component.annotations.Activate) FabricRoute(org.onosproject.simplefabric.api.FabricRoute) PRI_REACTIVE_BORDER_FORWARD(org.onosproject.simplefabric.api.Constants.PRI_REACTIVE_BORDER_FORWARD) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) IpAddress(org.onlab.packet.IpAddress) SimpleFabricService(org.onosproject.simplefabric.api.SimpleFabricService) TrafficTreatment(org.onosproject.net.flow.TrafficTreatment) PrintStream(java.io.PrintStream) PRI_REACTIVE_BORDER_BASE(org.onosproject.simplefabric.api.Constants.PRI_REACTIVE_BORDER_BASE) Logger(org.slf4j.Logger) PRI_REACTIVE_LOCAL_INTERCEPT(org.onosproject.simplefabric.api.Constants.PRI_REACTIVE_LOCAL_INTERCEPT) VlanId(org.onlab.packet.VlanId) FabricSubnet(org.onosproject.simplefabric.api.FabricSubnet) Ip6Prefix(org.onlab.packet.Ip6Prefix) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) IPv6(org.onlab.packet.IPv6) IPv4(org.onlab.packet.IPv4) REACTIVE_ALLOW_LINK_CP(org.onosproject.simplefabric.api.Constants.REACTIVE_ALLOW_LINK_CP) MacAddress(org.onlab.packet.MacAddress) PacketPriority(org.onosproject.net.packet.PacketPriority) Reference(org.osgi.service.component.annotations.Reference) Comparator(java.util.Comparator) Collections(java.util.Collections) DefaultOutboundPacket(org.onosproject.net.packet.DefaultOutboundPacket) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) HashedPathSelectionConstraint(org.onosproject.net.intent.constraint.HashedPathSelectionConstraint) Constraint(org.onosproject.net.intent.Constraint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) ArrayList(java.util.ArrayList)

Example 3 with EncapsulationConstraint

use of org.onosproject.net.intent.constraint.EncapsulationConstraint in project onos by opennetworkinglab.

the class SimpleFabricForwarding method buildConstraints.

private List<Constraint> buildConstraints(List<Constraint> constraints, EncapsulationType encapsulation) {
    if (!encapsulation.equals(EncapsulationType.NONE)) {
        List<Constraint> newConstraints = new ArrayList<>(constraints);
        constraints.stream().filter(c -> c instanceof EncapsulationConstraint).forEach(newConstraints::remove);
        newConstraints.add(new EncapsulationConstraint(encapsulation));
        return ImmutableList.copyOf(newConstraints);
    }
    return constraints;
}
Also used : Host(org.onosproject.net.Host) Interface(org.onosproject.net.intf.Interface) FabricNetwork(org.onosproject.simplefabric.api.FabricNetwork) CoreService(org.onosproject.core.CoreService) LoggerFactory(org.slf4j.LoggerFactory) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) HostService(org.onosproject.net.host.HostService) ConnectPoint(org.onosproject.net.ConnectPoint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) Component(org.osgi.service.component.annotations.Component) SimpleFabricListener(org.onosproject.simplefabric.api.SimpleFabricListener) TrafficSelector(org.onosproject.net.flow.TrafficSelector) ImmutableList(com.google.common.collect.ImmutableList) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) IntentService(org.onosproject.net.intent.IntentService) SimpleFabricEvent(org.onosproject.simplefabric.api.SimpleFabricEvent) Map(java.util.Map) ApplicationId(org.onosproject.core.ApplicationId) Intent(org.onosproject.net.intent.Intent) PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) Activate(org.osgi.service.component.annotations.Activate) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ResourceGroup(org.onosproject.net.ResourceGroup) PRI_L2NETWORK_BROADCAST(org.onosproject.simplefabric.api.Constants.PRI_L2NETWORK_BROADCAST) SimpleFabricService(org.onosproject.simplefabric.api.SimpleFabricService) PrintStream(java.io.PrintStream) ImmutableSet(com.google.common.collect.ImmutableSet) Logger(org.slf4j.Logger) Deactivate(org.osgi.service.component.annotations.Deactivate) Collection(java.util.Collection) VlanId(org.onlab.packet.VlanId) Set(java.util.Set) FORWARDING_APP_ID(org.onosproject.simplefabric.api.Constants.FORWARDING_APP_ID) Maps(com.google.common.collect.Maps) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) Constraint(org.onosproject.net.intent.Constraint) ReferenceCardinality(org.osgi.service.component.annotations.ReferenceCardinality) Objects(java.util.Objects) Key(org.onosproject.net.intent.Key) List(java.util.List) EncapsulationType(org.onosproject.net.EncapsulationType) PRI_L2NETWORK_UNICAST(org.onosproject.simplefabric.api.Constants.PRI_L2NETWORK_UNICAST) MacAddress(org.onlab.packet.MacAddress) Reference(org.osgi.service.component.annotations.Reference) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) Constraint(org.onosproject.net.intent.Constraint) ArrayList(java.util.ArrayList)

Example 4 with EncapsulationConstraint

use of org.onosproject.net.intent.constraint.EncapsulationConstraint in project onos by opennetworkinglab.

the class VirtualNetworkIntentManagerTest method testGetIntents.

/**
 * Tests the getIntents, getIntent(), getIntentData(), getIntentCount(),
 * isLocal() methods.
 */
@Test
public void testGetIntents() {
    VirtualNetwork virtualNetwork = setupVirtualNetworkTopology();
    Key intentKey = Key.of("test", APP_ID);
    List<Constraint> constraints = new ArrayList<>();
    constraints.add(new EncapsulationConstraint(EncapsulationType.VLAN));
    VirtualNetworkIntent virtualIntent = VirtualNetworkIntent.builder().networkId(virtualNetwork.id()).key(intentKey).appId(APP_ID).ingressPoint(cp1).egressPoint(cp5).constraints(constraints).build();
    // Test the submit() method.
    vnetIntentService.submit(virtualIntent);
    // Wait for the both intents to go into an INSTALLED state.
    try {
        if (!created.tryAcquire(MAX_PERMITS, MAX_WAIT_TIME, TimeUnit.SECONDS)) {
            fail("Failed to wait for intent to get installed.");
        }
    } catch (InterruptedException e) {
        fail("Semaphore exception during intent installation." + e.getMessage());
    }
    // Test the getIntents() method
    assertEquals("The intents size did not match as expected.", 1, Iterators.size(vnetIntentService.getIntents().iterator()));
    // Test the getIntent() method
    assertNotNull("The intent should have been found.", vnetIntentService.getIntent(virtualIntent.key()));
    // Test the getIntentData() method
    assertEquals("The intent data size did not match as expected.", 1, Iterators.size(vnetIntentService.getIntentData().iterator()));
    // Test the getIntentCount() method
    assertEquals("The intent count did not match as expected.", 1, vnetIntentService.getIntentCount());
    // Test the isLocal() method
    assertTrue("The intent should be local.", vnetIntentService.isLocal(virtualIntent.key()));
}
Also used : VirtualNetwork(org.onosproject.incubator.net.virtual.VirtualNetwork) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) Constraint(org.onosproject.net.intent.Constraint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) ArrayList(java.util.ArrayList) VirtualNetworkIntent(org.onosproject.incubator.net.virtual.VirtualNetworkIntent) Key(org.onosproject.net.intent.Key) Test(org.junit.Test)

Example 5 with EncapsulationConstraint

use of org.onosproject.net.intent.constraint.EncapsulationConstraint in project onos by opennetworkinglab.

the class VplsIntentUtility method setEncap.

/**
 * Sets one or more encapsulation constraints on the intent builder given.
 *
 * @param builder the intent builder
 * @param constraints the existing intent constraints
 * @param encap the encapsulation type to be set
 */
public static void setEncap(ConnectivityIntent.Builder builder, List<Constraint> constraints, EncapsulationType encap) {
    // Constraints might be an immutable list, so a new modifiable list
    // is created
    List<Constraint> newConstraints = new ArrayList<>(constraints);
    // Remove any encapsulation constraint if already in the list
    constraints.stream().filter(c -> c instanceof EncapsulationConstraint).forEach(newConstraints::remove);
    // constraint should be added to the list
    if (!encap.equals(NONE)) {
        newConstraints.add(new EncapsulationConstraint(encap));
    }
    // Submit new constraint list as immutable list
    builder.constraints(ImmutableList.copyOf(newConstraints));
}
Also used : Host(org.onosproject.net.Host) Interface(org.onosproject.net.intf.Interface) LoggerFactory(org.slf4j.LoggerFactory) VplsData(org.onosproject.vpls.api.VplsData) SinglePointToMultiPointIntent(org.onosproject.net.intent.SinglePointToMultiPointIntent) ConnectPoint(org.onosproject.net.ConnectPoint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) ArrayList(java.util.ArrayList) TrafficSelector(org.onosproject.net.flow.TrafficSelector) ImmutableList(com.google.common.collect.ImmutableList) MultiPointToSinglePointIntent(org.onosproject.net.intent.MultiPointToSinglePointIntent) ApplicationId(org.onosproject.core.ApplicationId) Intent(org.onosproject.net.intent.Intent) PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ResourceGroup(org.onosproject.net.ResourceGroup) ImmutableSet(com.google.common.collect.ImmutableSet) Logger(org.slf4j.Logger) VlanId(org.onlab.packet.VlanId) Set(java.util.Set) Collectors(java.util.stream.Collectors) Sets(com.google.common.collect.Sets) Constraint(org.onosproject.net.intent.Constraint) Objects(java.util.Objects) Key(org.onosproject.net.intent.Key) List(java.util.List) EncapsulationType(org.onosproject.net.EncapsulationType) ConnectivityIntent(org.onosproject.net.intent.ConnectivityIntent) MacAddress(org.onlab.packet.MacAddress) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) PartialFailureConstraint(org.onosproject.net.intent.constraint.PartialFailureConstraint) Constraint(org.onosproject.net.intent.Constraint) ArrayList(java.util.ArrayList)

Aggregations

EncapsulationConstraint (org.onosproject.net.intent.constraint.EncapsulationConstraint)24 ConnectPoint (org.onosproject.net.ConnectPoint)16 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)16 TrafficSelector (org.onosproject.net.flow.TrafficSelector)16 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)16 ImmutableList (com.google.common.collect.ImmutableList)15 EncapsulationType (org.onosproject.net.EncapsulationType)15 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)15 Intent (org.onosproject.net.intent.Intent)15 List (java.util.List)14 Set (java.util.Set)14 VlanId (org.onlab.packet.VlanId)13 ApplicationId (org.onosproject.core.ApplicationId)13 CoreService (org.onosproject.core.CoreService)13 ArrayList (java.util.ArrayList)12 DeviceId (org.onosproject.net.DeviceId)12 Test (org.junit.Test)11 Ethernet (org.onlab.packet.Ethernet)11 Collectors (java.util.stream.Collectors)9 Collection (java.util.Collection)8