Search in sources :

Example 6 with DefaultPath

use of org.onosproject.net.DefaultPath in project onos by opennetworkinglab.

the class PointToPointIntentCompiler method createProtectedIntent.

// FIXME: Compatibility with EncapsulationConstraint
private List<Intent> createProtectedIntent(ConnectPoint ingressPoint, ConnectPoint egressPoint, PointToPointIntent intent, List<Intent> installable) {
    log.trace("createProtectedIntent");
    DisjointPath path = getDisjointPath(intent, ingressPoint.deviceId(), egressPoint.deviceId());
    List<Intent> reusableIntents = null;
    if (installable != null) {
        reusableIntents = filterInvalidSubIntents(installable, intent);
        if (reusableIntents.size() == installable.size()) {
            // all old paths are still viable
            return installable;
        }
    }
    List<Intent> intentList = new ArrayList<>();
    // primary path intent
    List<Link> links = new ArrayList<>();
    links.addAll(path.links());
    links.add(createEdgeLink(egressPoint, false));
    // backup path intent
    List<Link> backupLinks = new ArrayList<>();
    backupLinks.addAll(path.backup().links());
    backupLinks.add(createEdgeLink(egressPoint, false));
    /*
         * One of the old paths is still entirely intact. This old path has
         * already been made primary, so we must add a backup path intent
         * and modify the failover group treatment accordingly.
         */
    if (reusableIntents != null && reusableIntents.size() > 1) {
        /*
             * Ensures that the egress port on source device is different than
             * that of existing path so that failover group will be useful
             * (would not be useful if both output ports in group bucket were
             * the same). Does not necessarily ensure that the new backup path
             * is entirely disjoint from the old path.
             */
        PortNumber primaryPort = getPrimaryPort(intent);
        if (primaryPort != null && !links.get(0).src().port().equals(primaryPort)) {
            reusableIntents.add(createPathIntent(new DefaultPath(PID, links, path.weight(), path.annotations()), intent, PathIntent.ProtectionType.BACKUP));
            updateFailoverGroup(intent, links);
            return reusableIntents;
        } else {
            reusableIntents.add(createPathIntent(new DefaultPath(PID, backupLinks, path.backup().weight(), path.backup().annotations()), intent, PathIntent.ProtectionType.BACKUP));
            updateFailoverGroup(intent, backupLinks);
            return reusableIntents;
        }
    }
    intentList.add(createPathIntent(new DefaultPath(PID, links, path.weight(), path.annotations()), intent, PathIntent.ProtectionType.PRIMARY));
    intentList.add(createPathIntent(new DefaultPath(PID, backupLinks, path.backup().weight(), path.backup().annotations()), intent, PathIntent.ProtectionType.BACKUP));
    // add contents appropriately.
    if (groupService.getGroup(ingressPoint.deviceId(), makeGroupKey(intent.id())) == null) {
        // manufactured fast failover flow rule intent
        createFailoverTreatmentGroup(path.links(), path.backup().links(), intent);
        FlowRuleIntent frIntent = new FlowRuleIntent(intent.appId(), intent.key(), createFailoverFlowRules(intent), asList(ingressPoint.deviceId()), PathIntent.ProtectionType.FAILOVER, intent.resourceGroup());
        intentList.add(frIntent);
    } else {
        updateFailoverGroup(intent, links);
        updateFailoverGroup(intent, backupLinks);
    }
    return intentList;
}
Also used : ArrayList(java.util.ArrayList) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent) Intent(org.onosproject.net.intent.Intent) PathIntent(org.onosproject.net.intent.PathIntent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) PointToPointIntent(org.onosproject.net.intent.PointToPointIntent) DefaultPath(org.onosproject.net.DefaultPath) PortNumber(org.onosproject.net.PortNumber) DisjointPath(org.onosproject.net.DisjointPath) DefaultEdgeLink.createEdgeLink(org.onosproject.net.DefaultEdgeLink.createEdgeLink) Link(org.onosproject.net.Link) EdgeLink(org.onosproject.net.EdgeLink) FlowRuleIntent(org.onosproject.net.intent.FlowRuleIntent)

Example 7 with DefaultPath

use of org.onosproject.net.DefaultPath in project onos by opennetworkinglab.

the class PathIntentCompilerTest method setUp.

/**
 * Configures mock objects used in all the test cases.
 * Creates the intents to test as well.
 */
@Before
public void setUp() {
    sut = new PathIntentCompiler();
    coreService = createMock(CoreService.class);
    expect(coreService.registerApplication("org.onosproject.net.intent")).andReturn(appId);
    sut.coreService = coreService;
    sut.resourceService = new MockResourceService();
    super.setUp();
    intent = PathIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).priority(PRIORITY).path(new DefaultPath(pid, links, ScalarWeight.toWeight(hops))).build();
    // Intent with VLAN encap without egress VLAN
    constraintVlanIntent = PathIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).priority(PRIORITY).constraints(ImmutableList.of(new EncapsulationConstraint(EncapsulationType.VLAN))).path(new DefaultPath(pid, links, ScalarWeight.toWeight(hops))).build();
    // Intent with VLAN encap with ingress and egress VLAN
    constrainIngressEgressVlanIntent = PathIntent.builder().appId(APP_ID).selector(vlanSelector).treatment(vlanTreatment).priority(PRIORITY).constraints(ImmutableList.of(new EncapsulationConstraint(EncapsulationType.VLAN))).path(new DefaultPath(pid, links, ScalarWeight.toWeight(hops))).build();
    constraintMplsIntent = PathIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).priority(PRIORITY).constraints(ImmutableList.of(new EncapsulationConstraint(EncapsulationType.MPLS))).path(new DefaultPath(pid, links, ScalarWeight.toWeight(hops))).build();
    edgeIntentNoVlan = PathIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).priority(PRIORITY).constraints(ImmutableList.of(new EncapsulationConstraint(EncapsulationType.VLAN))).path(new DefaultPath(pid, edgeNet, ScalarWeight.toWeight(edgeHops))).build();
    edgeIntentIngressVlan = PathIntent.builder().appId(APP_ID).selector(vlanSelector).treatment(treatment).priority(PRIORITY).constraints(ImmutableList.of(new EncapsulationConstraint(EncapsulationType.VLAN))).path(new DefaultPath(pid, edgeNet, ScalarWeight.toWeight(edgeHops))).build();
    edgeIntentEgressVlan = PathIntent.builder().appId(APP_ID).selector(selector).treatment(vlanTreatment).priority(PRIORITY).constraints(ImmutableList.of(new EncapsulationConstraint(EncapsulationType.VLAN))).path(new DefaultPath(pid, edgeNet, ScalarWeight.toWeight(edgeHops))).build();
    edgeIntentVlan = PathIntent.builder().appId(APP_ID).selector(vlanSelector).treatment(vlanTreatment).priority(PRIORITY).constraints(ImmutableList.of(new EncapsulationConstraint(EncapsulationType.VLAN))).path(new DefaultPath(pid, edgeNet, ScalarWeight.toWeight(edgeHops))).build();
    singleHopIndirectIntentNoVlan = PathIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).priority(PRIORITY).constraints(ImmutableList.of(new EncapsulationConstraint(EncapsulationType.VLAN))).path(new DefaultPath(pid, singleHopIndirect, ScalarWeight.toWeight(singleHopIndirectHops))).build();
    singleHopIndirectIntentIngressVlan = PathIntent.builder().appId(APP_ID).selector(vlanSelector).treatment(treatment).priority(PRIORITY).constraints(ImmutableList.of(new EncapsulationConstraint(EncapsulationType.VLAN))).path(new DefaultPath(pid, singleHopIndirect, ScalarWeight.toWeight(singleHopIndirectHops))).build();
    singleHopIndirectIntentEgressVlan = PathIntent.builder().appId(APP_ID).selector(selector).treatment(vlanTreatment).priority(PRIORITY).constraints(ImmutableList.of(new EncapsulationConstraint(EncapsulationType.VLAN))).path(new DefaultPath(pid, singleHopIndirect, ScalarWeight.toWeight(singleHopIndirectHops))).build();
    singleHopIndirectIntentVlan = PathIntent.builder().appId(APP_ID).selector(vlanSelector).treatment(vlanTreatment).priority(PRIORITY).constraints(ImmutableList.of(new EncapsulationConstraint(EncapsulationType.VLAN))).path(new DefaultPath(pid, singleHopIndirect, ScalarWeight.toWeight(singleHopIndirectHops))).build();
    singleHopDirectIntentNoVlan = PathIntent.builder().appId(APP_ID).selector(selector).treatment(treatment).priority(PRIORITY).constraints(ImmutableList.of(new EncapsulationConstraint(EncapsulationType.VLAN))).path(new DefaultPath(pid, singleHopDirect, ScalarWeight.toWeight(singleHopDirectHops))).build();
    singleHopDirectIntentIngressVlan = PathIntent.builder().appId(APP_ID).selector(vlanSelector).treatment(treatment).priority(PRIORITY).constraints(ImmutableList.of(new EncapsulationConstraint(EncapsulationType.VLAN))).path(new DefaultPath(pid, singleHopDirect, ScalarWeight.toWeight(singleHopDirectHops))).build();
    singleHopDirectIntentEgressVlan = PathIntent.builder().appId(APP_ID).selector(selector).treatment(vlanTreatment).priority(PRIORITY).constraints(ImmutableList.of(new EncapsulationConstraint(EncapsulationType.VLAN))).path(new DefaultPath(pid, singleHopDirect, ScalarWeight.toWeight(singleHopDirectHops))).build();
    singleHopDirectIntentVlan = PathIntent.builder().appId(APP_ID).selector(vlanSelector).treatment(vlanTreatment).priority(PRIORITY).constraints(ImmutableList.of(new EncapsulationConstraint(EncapsulationType.VLAN))).path(new DefaultPath(pid, singleHopDirect, ScalarWeight.toWeight(singleHopDirectHops))).build();
    intentExtensionService = createMock(IntentExtensionService.class);
    intentExtensionService.registerCompiler(PathIntent.class, sut);
    intentExtensionService.unregisterCompiler(PathIntent.class);
    registrator = new IntentConfigurableRegistrator();
    registrator.extensionService = intentExtensionService;
    registrator.cfgService = new ComponentConfigAdapter();
    registrator.activate();
    sut.registrator = registrator;
    replay(coreService, intentExtensionService);
}
Also used : EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) ComponentConfigAdapter(org.onosproject.cfg.ComponentConfigAdapter) MockResourceService(org.onosproject.net.resource.MockResourceService) IntentExtensionService(org.onosproject.net.intent.IntentExtensionService) CoreService(org.onosproject.core.CoreService) DefaultPath(org.onosproject.net.DefaultPath) Before(org.junit.Before)

Example 8 with DefaultPath

use of org.onosproject.net.DefaultPath in project onos by opennetworkinglab.

the class OvsdbTunnelProviderTest method testTunnelAdded.

@Test
public void testTunnelAdded() {
    TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf("192.168.1.1"));
    TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf("192.168.1.3"));
    SparseAnnotations annotations = DefaultAnnotations.builder().set("bandwidth", "1024").build();
    List<Link> links = new ArrayList<Link>();
    links.add(link);
    TunnelDescription tunnel = new DefaultTunnelDescription(TunnelId.valueOf("1234"), src, dst, Tunnel.Type.VXLAN, new GroupId(0), this.provider.id(), TunnelName.tunnelName("tunnel12"), new DefaultPath(this.provider.id(), links, ScalarWeight.toWeight(0.3)), annotations);
    provider.tunnelAdded(tunnel);
    assertEquals(1, providerService.tunnelSet.size());
}
Also used : SparseAnnotations(org.onosproject.net.SparseAnnotations) TunnelEndPoint(org.onosproject.incubator.net.tunnel.TunnelEndPoint) IpTunnelEndPoint(org.onosproject.incubator.net.tunnel.IpTunnelEndPoint) ArrayList(java.util.ArrayList) DefaultTunnelDescription(org.onosproject.incubator.net.tunnel.DefaultTunnelDescription) TunnelDescription(org.onosproject.incubator.net.tunnel.TunnelDescription) DefaultTunnelDescription(org.onosproject.incubator.net.tunnel.DefaultTunnelDescription) DefaultPath(org.onosproject.net.DefaultPath) Link(org.onosproject.net.Link) DefaultLink(org.onosproject.net.DefaultLink) GroupId(org.onosproject.core.GroupId) Test(org.junit.Test)

Example 9 with DefaultPath

use of org.onosproject.net.DefaultPath in project onos by opennetworkinglab.

the class OvsdbTunnelProviderTest method testTunnelRemoved.

@Test
public void testTunnelRemoved() {
    TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf("192.168.1.1"));
    TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf("192.168.1.3"));
    SparseAnnotations annotations = DefaultAnnotations.builder().set("bandwidth", "1024").build();
    List<Link> links = new ArrayList<Link>();
    links.add(link);
    TunnelDescription tunnel = new DefaultTunnelDescription(TunnelId.valueOf("1234"), src, dst, Tunnel.Type.VXLAN, new GroupId(0), this.provider.id(), TunnelName.tunnelName("tunnel1"), new DefaultPath(this.provider.id(), links, ScalarWeight.toWeight(0.3)), annotations);
    provider.tunnelRemoved(tunnel);
    assertEquals(0, providerService.tunnelSet.size());
}
Also used : SparseAnnotations(org.onosproject.net.SparseAnnotations) TunnelEndPoint(org.onosproject.incubator.net.tunnel.TunnelEndPoint) IpTunnelEndPoint(org.onosproject.incubator.net.tunnel.IpTunnelEndPoint) ArrayList(java.util.ArrayList) DefaultTunnelDescription(org.onosproject.incubator.net.tunnel.DefaultTunnelDescription) TunnelDescription(org.onosproject.incubator.net.tunnel.TunnelDescription) DefaultTunnelDescription(org.onosproject.incubator.net.tunnel.DefaultTunnelDescription) DefaultPath(org.onosproject.net.DefaultPath) Link(org.onosproject.net.Link) DefaultLink(org.onosproject.net.DefaultLink) GroupId(org.onosproject.core.GroupId) Test(org.junit.Test)

Example 10 with DefaultPath

use of org.onosproject.net.DefaultPath in project onos by opennetworkinglab.

the class OpticalPathProvisionerTest method testSetupPath.

/**
 * Checks setupPath method works.
 */
@Test
public void testSetupPath() {
    Bandwidth bandwidth = Bandwidth.bps(100);
    Duration latency = Duration.ofMillis(10);
    List<Link> links = Stream.of(LINK1, LINK2, LINK3, LINK4, LINK5, LINK6).collect(Collectors.toList());
    Path path = new DefaultPath(PROVIDER_ID, links, new ScalarWeight(0));
    OpticalConnectivityId cid = target.setupPath(path, bandwidth, latency);
    assertNotNull(cid);
    // Checks intents are installed as expected
    assertEquals(1, intentService.submitted.size());
    assertEquals(OpticalConnectivityIntent.class, intentService.submitted.get(0).getClass());
    OpticalConnectivityIntent connIntent = (OpticalConnectivityIntent) intentService.submitted.get(0);
    assertEquals(CP31, connIntent.getSrc());
    assertEquals(CP52, connIntent.getDst());
}
Also used : DefaultPath(org.onosproject.net.DefaultPath) Path(org.onosproject.net.Path) OpticalConnectivityId(org.onosproject.newoptical.api.OpticalConnectivityId) Bandwidth(org.onlab.util.Bandwidth) OpticalConnectivityIntent(org.onosproject.net.intent.OpticalConnectivityIntent) Duration(java.time.Duration) DefaultPath(org.onosproject.net.DefaultPath) DefaultLink(org.onosproject.net.DefaultLink) Link(org.onosproject.net.Link) ScalarWeight(org.onlab.graph.ScalarWeight) Test(org.junit.Test)

Aggregations

DefaultPath (org.onosproject.net.DefaultPath)18 Link (org.onosproject.net.Link)9 Before (org.junit.Before)7 ArrayList (java.util.ArrayList)6 ResourceContext (org.onosproject.net.intent.ResourceContext)5 ScalarWeight (org.onlab.graph.ScalarWeight)4 CoreService (org.onosproject.core.CoreService)4 DisjointPath (org.onosproject.net.DisjointPath)4 Path (org.onosproject.net.Path)4 Test (org.junit.Test)3 Annotations (org.onosproject.net.Annotations)3 ConnectPoint (org.onosproject.net.ConnectPoint)3 DefaultAnnotations (org.onosproject.net.DefaultAnnotations)3 DefaultLink (org.onosproject.net.DefaultLink)3 EdgeLink (org.onosproject.net.EdgeLink)3 FlowRuleIntent (org.onosproject.net.intent.FlowRuleIntent)3 Intent (org.onosproject.net.intent.Intent)3 JsonNode (com.fasterxml.jackson.databind.JsonNode)2 ArrayNode (com.fasterxml.jackson.databind.node.ArrayNode)2 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)2