@Test public void testSameSwitchDifferentPortsIntentCompilation() { ConnectPoint src = new ConnectPoint(deviceId("1"), portNumber(1)); ConnectPoint dst = new ConnectPoint(deviceId("1"), portNumber(2)); MplsIntent intent = MplsIntent.builder() .appId(APP_ID) .selector(selector) .treatment(treatment) .ingressPoint(src) .ingressLabel(Optional.empty()) .egressPoint(dst) .egressLabel(Optional.empty()) .build(); String[] hops = {"1"}; MplsIntentCompiler sut = makeCompiler(hops); List<Intent> compiled = sut.compile(intent, null); assertThat(compiled, hasSize(1)); assertThat(compiled.get(0), is(instanceOf(MplsPathIntent.class))); Path path = ((MplsPathIntent) compiled.get(0)).path(); assertThat(path.links(), hasSize(2)); Link firstLink = path.links().get(0); assertThat(firstLink, is(createEdgeLink(src, true))); Link secondLink = path.links().get(1); assertThat(secondLink, is(createEdgeLink(dst, false))); }
@Override public List<Intent> compile(MplsIntent intent, List<Intent> installable) { ConnectPoint ingressPoint = intent.ingressPoint(); ConnectPoint egressPoint = intent.egressPoint(); if (ingressPoint.deviceId().equals(egressPoint.deviceId())) { List<Link> links = asList(createEdgeLink(ingressPoint, true), createEdgeLink(egressPoint, false)); return asList(createPathIntent(new DefaultPath(PID, links, DEFAULT_COST), intent)); } List<Link> links = new ArrayList<>(); Path path = getPath(intent, ingressPoint.deviceId(), egressPoint.deviceId()); links.add(createEdgeLink(ingressPoint, true)); links.addAll(path.links()); links.add(createEdgeLink(egressPoint, false)); return asList(createPathIntent(new DefaultPath(PID, links, path.cost(), path.annotations()), intent)); }
MplsIntentCompiler extends ConnectivityIntentCompiler<MplsIntent> { @Override public List<Intent> compile(MplsIntent intent, List<Intent> installable) { ConnectPoint ingressPoint = intent.ingressPoint(); ConnectPoint egressPoint = intent.egressPoint(); if (ingressPoint.deviceId().equals(egressPoint.deviceId())) { List<Link> links = asList(createEdgeLink(ingressPoint, true), createEdgeLink(egressPoint, false)); return asList(createPathIntent(new DefaultPath(PID, links, DEFAULT_COST), intent)); } List<Link> links = new ArrayList<>(); Path path = getPath(intent, ingressPoint.deviceId(), egressPoint.deviceId()); links.add(createEdgeLink(ingressPoint, true)); links.addAll(path.links()); links.add(createEdgeLink(egressPoint, false)); return asList(createPathIntent(new DefaultPath(PID, links, path.cost(), path.annotations()), intent)); } }
MplsIntentCompiler extends ConnectivityIntentCompiler<MplsIntent> { @Override public List<Intent> compile(MplsIntent intent, List<Intent> installable) { ConnectPoint ingressPoint = intent.ingressPoint(); ConnectPoint egressPoint = intent.egressPoint(); if (ingressPoint.deviceId().equals(egressPoint.deviceId())) { List<Link> links = asList(createEdgeLink(ingressPoint, true), createEdgeLink(egressPoint, false)); return asList(createPathIntent(new DefaultPath(PID, links, DEFAULT_COST), intent)); } List<Link> links = new ArrayList<>(); Path path = getPath(intent, ingressPoint.deviceId(), egressPoint.deviceId()); links.add(createEdgeLink(ingressPoint, true)); links.addAll(path.links()); links.add(createEdgeLink(egressPoint, false)); return asList(createPathIntent(new DefaultPath(PID, links, path.cost(), path.annotations()), intent)); }  }
MplsIntentCompiler extends ConnectivityIntentCompiler<MplsIntent> { @Override public List<Intent> compile(MplsIntent intent, List<Intent> installable) { ConnectPoint ingressPoint = intent.ingressPoint(); ConnectPoint egressPoint = intent.egressPoint(); if (ingressPoint.deviceId().equals(egressPoint.deviceId())) { List<Link> links = asList(createEdgeLink(ingressPoint, true), createEdgeLink(egressPoint, false)); return asList(createPathIntent(new DefaultPath(PID, links, DEFAULT_COST), intent)); } List<Link> links = new ArrayList<>(); Path path = getPath(intent, ingressPoint.deviceId(), egressPoint.deviceId()); links.add(createEdgeLink(ingressPoint, true)); links.addAll(path.links()); links.add(createEdgeLink(egressPoint, false)); return asList(createPathIntent(new DefaultPath(PID, links, path.cost(), path.annotations()), intent)); }  @Activate void activate(); @Deactivate void deactivate(); @Override List<Intent> compile(MplsIntent intent, List<Intent> installable); }
MplsIntentCompiler extends ConnectivityIntentCompiler<MplsIntent> { @Override public List<Intent> compile(MplsIntent intent, List<Intent> installable) { ConnectPoint ingressPoint = intent.ingressPoint(); ConnectPoint egressPoint = intent.egressPoint(); if (ingressPoint.deviceId().equals(egressPoint.deviceId())) { List<Link> links = asList(createEdgeLink(ingressPoint, true), createEdgeLink(egressPoint, false)); return asList(createPathIntent(new DefaultPath(PID, links, DEFAULT_COST), intent)); } List<Link> links = new ArrayList<>(); Path path = getPath(intent, ingressPoint.deviceId(), egressPoint.deviceId()); links.add(createEdgeLink(ingressPoint, true)); links.addAll(path.links()); links.add(createEdgeLink(egressPoint, false)); return asList(createPathIntent(new DefaultPath(PID, links, path.cost(), path.annotations()), intent)); }  @Activate void activate(); @Deactivate void deactivate(); @Override List<Intent> compile(MplsIntent intent, List<Intent> installable); static final int DEFAULT_COST; }