use of org.onosproject.net.intent.SinglePointToMultiPointIntent in project onos by opennetworkinglab.
the class SimpleFabricForwarding method refresh.
private void refresh() {
log.debug("simple fabric forwarding refresh");
Map<Key, SinglePointToMultiPointIntent> newBctIntentsMap = Maps.newConcurrentMap();
Map<Key, MultiPointToSinglePointIntent> newUniIntentsMap = Maps.newConcurrentMap();
for (FabricNetwork fabricNetwork : simpleFabric.fabricNetworks()) {
// if fabricNetwork.isForward == false or number of interfaces() < 2, no Intents generated
for (SinglePointToMultiPointIntent intent : buildBrcIntents(fabricNetwork)) {
newBctIntentsMap.put(intent.key(), intent);
}
for (MultiPointToSinglePointIntent intent : buildUniIntents(fabricNetwork, hostsFromL2Network(fabricNetwork))) {
newUniIntentsMap.put(intent.key(), intent);
}
if (fabricNetwork.isDirty()) {
fabricNetwork.setDirty(false);
}
}
boolean bctUpdated = false;
for (SinglePointToMultiPointIntent intent : bctIntentsMap.values()) {
SinglePointToMultiPointIntent newIntent = newBctIntentsMap.get(intent.key());
if (newIntent == null) {
log.info("simple fabric forwarding withdraw broadcast intent: {}", intent.key().toString());
toBePurgedIntentKeys.add(intent.key());
intentService.withdraw(intent);
bctUpdated = true;
}
}
for (SinglePointToMultiPointIntent intent : newBctIntentsMap.values()) {
SinglePointToMultiPointIntent oldIntent = bctIntentsMap.get(intent.key());
if (oldIntent == null || !oldIntent.filteredEgressPoints().equals(intent.filteredEgressPoints()) || !oldIntent.filteredIngressPoint().equals(intent.filteredIngressPoint()) || !oldIntent.selector().equals(intent.selector()) || !oldIntent.treatment().equals(intent.treatment()) || !oldIntent.constraints().equals(intent.constraints())) {
log.info("simple fabric forwarding submit broadcast intent: {}", intent.key().toString());
toBePurgedIntentKeys.remove(intent.key());
intentService.submit(intent);
bctUpdated = true;
}
}
boolean uniUpdated = false;
for (MultiPointToSinglePointIntent intent : uniIntentsMap.values()) {
MultiPointToSinglePointIntent newIntent = newUniIntentsMap.get(intent.key());
if (newIntent == null) {
log.info("simple fabric forwarding withdraw unicast intent: {}", intent.key().toString());
toBePurgedIntentKeys.add(intent.key());
intentService.withdraw(intent);
uniUpdated = true;
}
}
for (MultiPointToSinglePointIntent intent : newUniIntentsMap.values()) {
MultiPointToSinglePointIntent oldIntent = uniIntentsMap.get(intent.key());
if (oldIntent == null || !oldIntent.filteredEgressPoint().equals(intent.filteredEgressPoint()) || !oldIntent.filteredIngressPoints().equals(intent.filteredIngressPoints()) || !oldIntent.selector().equals(intent.selector()) || !oldIntent.treatment().equals(intent.treatment()) || !oldIntent.constraints().equals(intent.constraints())) {
log.info("simple fabric forwarding submit unicast intent: {}", intent.key().toString());
toBePurgedIntentKeys.remove(intent.key());
intentService.submit(intent);
uniUpdated = true;
}
}
if (bctUpdated) {
bctIntentsMap = newBctIntentsMap;
}
if (uniUpdated) {
uniIntentsMap = newUniIntentsMap;
}
}
use of org.onosproject.net.intent.SinglePointToMultiPointIntent in project onos by opennetworkinglab.
the class VplsIntentUtility method buildBrcIntent.
/**
* Builds a broadcast intent.
*
* @param key key to identify the intent
* @param appId application ID for this Intent
* @param src the source connect point
* @param dsts the destination connect points
* @param encap the encapsulation type
* @param resourceGroup resource group for this Intent
* @return the generated single-point to multi-point intent
*/
static SinglePointToMultiPointIntent buildBrcIntent(Key key, ApplicationId appId, FilteredConnectPoint src, Set<FilteredConnectPoint> dsts, EncapsulationType encap, ResourceGroup resourceGroup) {
log.debug("Building broadcast intent {} for source {}", SP2MP, src);
SinglePointToMultiPointIntent.Builder intentBuilder;
TrafficSelector selector = DefaultTrafficSelector.builder().matchEthDst(MacAddress.BROADCAST).build();
intentBuilder = SinglePointToMultiPointIntent.builder().appId(appId).key(key).selector(selector).filteredIngressPoint(src).filteredEgressPoints(dsts).constraints(PARTIAL_FAILURE_CONSTRAINT).priority(PRIORITY_OFFSET + PRIORITY_BRC).resourceGroup(resourceGroup);
setEncap(intentBuilder, PARTIAL_FAILURE_CONSTRAINT, encap);
return intentBuilder.build();
}
use of org.onosproject.net.intent.SinglePointToMultiPointIntent in project onos by opennetworkinglab.
the class IntentsListCommand method detailsFormat.
/**
* Returns detailed information text about a specific intent.
*
* @param intent to print
* @param state of intent
* @return detailed information or "" if {@code state} was null
*/
private StringBuilder detailsFormat(Intent intent, IntentState state) {
StringBuilder builder = new StringBuilder();
if (state == null) {
return builder;
}
if (!intent.resources().isEmpty()) {
builder.append('\n').append(format(RESOURCES, intent.resources()));
}
if (intent instanceof ConnectivityIntent) {
ConnectivityIntent ci = (ConnectivityIntent) intent;
if (!ci.selector().criteria().isEmpty()) {
builder.append('\n').append(format(COMMON_SELECTOR, formatSelector(ci.selector())));
}
if (!ci.treatment().allInstructions().isEmpty()) {
builder.append('\n').append(format(TREATMENT, ci.treatment().allInstructions()));
}
if (ci.constraints() != null && !ci.constraints().isEmpty()) {
builder.append('\n').append(format(CONSTRAINTS, ci.constraints()));
}
}
if (intent instanceof HostToHostIntent) {
HostToHostIntent pi = (HostToHostIntent) intent;
builder.append('\n').append(format(SRC + HOST, pi.one()));
builder.append('\n').append(format(DST + HOST, pi.two()));
} else if (intent instanceof PointToPointIntent) {
PointToPointIntent pi = (PointToPointIntent) intent;
builder.append('\n').append(formatFilteredCps(Sets.newHashSet(pi.filteredIngressPoint()), INGRESS));
builder.append('\n').append(formatFilteredCps(Sets.newHashSet(pi.filteredEgressPoint()), EGRESS));
} else if (intent instanceof MultiPointToSinglePointIntent) {
MultiPointToSinglePointIntent pi = (MultiPointToSinglePointIntent) intent;
builder.append('\n').append(formatFilteredCps(pi.filteredIngressPoints(), INGRESS));
builder.append('\n').append(formatFilteredCps(Sets.newHashSet(pi.filteredEgressPoint()), EGRESS));
} else if (intent instanceof SinglePointToMultiPointIntent) {
SinglePointToMultiPointIntent pi = (SinglePointToMultiPointIntent) intent;
builder.append('\n').append(formatFilteredCps(Sets.newHashSet(pi.filteredIngressPoint()), INGRESS));
builder.append('\n').append(formatFilteredCps(pi.filteredEgressPoints(), EGRESS));
} else if (intent instanceof PathIntent) {
PathIntent pi = (PathIntent) intent;
builder.append(format("path=%s, cost=%f", pi.path().links(), pi.path().cost()));
} else if (intent instanceof LinkCollectionIntent) {
LinkCollectionIntent li = (LinkCollectionIntent) intent;
builder.append('\n').append(format("links=%s", li.links()));
builder.append('\n').append(format(CP, li.egressPoints()));
} else if (intent instanceof OpticalCircuitIntent) {
OpticalCircuitIntent ci = (OpticalCircuitIntent) intent;
builder.append('\n').append(format("src=%s, dst=%s", ci.getSrc(), ci.getDst()));
builder.append('\n').append(format("signal type=%s", ci.getSignalType()));
builder.append('\n').append(format("bidirectional=%s", ci.isBidirectional()));
} else if (intent instanceof OpticalConnectivityIntent) {
OpticalConnectivityIntent ci = (OpticalConnectivityIntent) intent;
builder.append('\n').append(format("src=%s, dst=%s", ci.getSrc(), ci.getDst()));
builder.append('\n').append(format("signal type=%s", ci.getSignalType()));
builder.append('\n').append(format("bidirectional=%s", ci.isBidirectional()));
builder.append('\n').append(format("ochSignal=%s", ci.ochSignal()));
} else if (intent instanceof OpticalOduIntent) {
OpticalOduIntent ci = (OpticalOduIntent) intent;
builder.append('\n').append(format("src=%s, dst=%s", ci.getSrc(), ci.getDst()));
builder.append('\n').append(format("signal type=%s", ci.getSignalType()));
builder.append('\n').append(format("bidirectional=%s", ci.isBidirectional()));
}
List<Intent> installable = service.getInstallableIntents(intent.key()).stream().filter(i -> contentFilter.filter(i)).collect(Collectors.toList());
if (showInstallable && installable != null && !installable.isEmpty()) {
builder.append('\n').append(format(INSTALLABLE, installable));
}
return builder;
}
use of org.onosproject.net.intent.SinglePointToMultiPointIntent in project onos by opennetworkinglab.
the class AddSinglePointToMultiPointIntentCommand method doExecute.
@Override
protected void doExecute() {
IntentService service = get(IntentService.class);
if (deviceStrings.length < 2) {
return;
}
String ingressDeviceString = deviceStrings[0];
ConnectPoint ingressPoint = ConnectPoint.deviceConnectPoint(ingressDeviceString);
Set<FilteredConnectPoint> egressPoints = new HashSet<>();
for (int index = 1; index < deviceStrings.length; index++) {
String egressDeviceString = deviceStrings[index];
ConnectPoint egress = ConnectPoint.deviceConnectPoint(egressDeviceString);
egressPoints.add(new FilteredConnectPoint(egress));
}
TrafficSelector selector = buildTrafficSelector();
TrafficTreatment treatment = buildTrafficTreatment();
List<Constraint> constraints = buildConstraints();
SinglePointToMultiPointIntent intent = SinglePointToMultiPointIntent.builder().appId(appId()).key(key()).selector(selector).treatment(treatment).filteredIngressPoint(new FilteredConnectPoint(ingressPoint)).filteredEgressPoints(egressPoints).constraints(constraints).priority(priority()).resourceGroup(resourceGroup()).build();
service.submit(intent);
print("Single point to multipoint intent submitted:\n%s", intent.toString());
}
use of org.onosproject.net.intent.SinglePointToMultiPointIntent in project onos by opennetworkinglab.
the class SinglePointToMultiPointIntentCompilerTest method testMultiEgressCompilation.
/**
* Tests multiple egress points that share a common path to the ingress
* point.
*/
@Test
public void testMultiEgressCompilation() {
FilteredConnectPoint ingress = new FilteredConnectPoint(new ConnectPoint(DID_1, PORT_1));
FilteredConnectPoint egressOne = new FilteredConnectPoint(new ConnectPoint(DID_3, PORT_2));
FilteredConnectPoint egressTwo = new FilteredConnectPoint(new ConnectPoint(DID_4, PORT_2));
FilteredConnectPoint egressThree = new FilteredConnectPoint(new ConnectPoint(DID_5, PORT_2));
Set<FilteredConnectPoint> egress = Sets.newHashSet(egressOne, egressTwo, egressThree);
SinglePointToMultiPointIntent intent = makeIntent(ingress, egress);
assertThat(intent, is(notNullValue()));
final String[] hops = { S2 };
SinglePointToMultiPointIntentCompiler compiler = makeCompiler(hops);
assertThat(compiler, is(notNullValue()));
List<Intent> result = compiler.compile(intent, null);
assertThat(result, is(notNullValue()));
assertThat(result, hasSize(1));
Intent resultIntent = result.get(0);
assertThat(resultIntent instanceof LinkCollectionIntent, is(true));
if (resultIntent instanceof LinkCollectionIntent) {
LinkCollectionIntent linkIntent = (LinkCollectionIntent) resultIntent;
assertThat(linkIntent.links(), hasSize(4));
assertThat(linkIntent.links(), linksHasPath(S1, S2));
assertThat(linkIntent.links(), linksHasPath(S2, S3));
assertThat(linkIntent.links(), linksHasPath(S2, S4));
assertThat(linkIntent.links(), linksHasPath(S2, S5));
}
assertThat("key is inherited", resultIntent.key(), is(intent.key()));
}
Aggregations