use of org.onosproject.net.intent.MultiPointToSinglePointIntent in project onos by opennetworkinglab.
the class VplsIntentTest method buildUniIntent.
/**
* Builds a unicast intent.
*
* @param key the key to identify the intent
* @param srcs the ingress connect points
* @param dst the egress connect point
* @param host the destination Host
* @return the generated multi-point to single-point intent
*/
private MultiPointToSinglePointIntent buildUniIntent(Key key, Set<FilteredConnectPoint> srcs, FilteredConnectPoint dst, Host host, EncapsulationType encap) {
MultiPointToSinglePointIntent.Builder intentBuilder;
TrafficSelector selector = DefaultTrafficSelector.builder().matchEthDst(host.mac()).build();
intentBuilder = MultiPointToSinglePointIntent.builder().appId(APPID).key(key).selector(selector).filteredIngressPoints(srcs).filteredEgressPoint(dst).constraints(VplsIntentUtility.PARTIAL_FAILURE_CONSTRAINT).priority(PRIORITY_OFFSET);
VplsIntentUtility.setEncap(intentBuilder, VplsIntentUtility.PARTIAL_FAILURE_CONSTRAINT, encap);
return intentBuilder.build();
}
use of org.onosproject.net.intent.MultiPointToSinglePointIntent in project onos by opennetworkinglab.
the class VplsIntentTest method generateVplsUni.
/**
* Generates a list of expected mp2sp intents for a given VPLS.
*
* @param fcPoints the filtered connect point
* @param hosts the hosts
* @param name the name of the VPLS
* @param encap the encapsulation type
* @return the list of expected mp2sp intents for the given VPLS
*/
private List<MultiPointToSinglePointIntent> generateVplsUni(Set<FilteredConnectPoint> fcPoints, Set<Host> hosts, String name, EncapsulationType encap) {
List<MultiPointToSinglePointIntent> intents = Lists.newArrayList();
hosts.forEach(host -> {
FilteredConnectPoint hostPoint = getHostPoint(host, fcPoints);
Set<FilteredConnectPoint> otherPoints = fcPoints.stream().filter(fcp -> !fcp.equals(hostPoint)).collect(Collectors.toSet());
Key uniKey = buildKey(VplsIntentUtility.PREFIX_UNICAST, host.location(), name, host.mac());
intents.add(buildUniIntent(uniKey, otherPoints, hostPoint, host, encap));
});
return intents;
}
use of org.onosproject.net.intent.MultiPointToSinglePointIntent in project onos by opennetworkinglab.
the class TopoIntentFilter method getIntents.
// Produces a list of intents that target all selected hosts, devices, links or connect points.
private List<Intent> getIntents(Set<Host> hosts, Set<Device> devices, Set<Link> links, Set<ConnectPoint> edgePoints, Iterable<Intent> sourceIntents) {
List<Intent> intents = new ArrayList<>();
if (hosts.isEmpty() && devices.isEmpty() && links.isEmpty()) {
return intents;
}
Set<OpticalConnectivityIntent> opticalIntents = new HashSet<>();
// Search through all intents and see if they are relevant to our search.
for (Intent intent : sourceIntents) {
if (intentService.getIntentState(intent.key()) == INSTALLED) {
boolean isRelevant = false;
if (intent instanceof HostToHostIntent) {
isRelevant = isIntentRelevantToHosts((HostToHostIntent) intent, hosts) && isIntentRelevantToDevices(intent, devices) && isIntentRelevantToLinks(intent, links);
} else if (intent instanceof PointToPointIntent) {
isRelevant = isIntentRelevant((PointToPointIntent) intent, edgePoints) && isIntentRelevantToDevices(intent, devices) && isIntentRelevantToLinks(intent, links);
} else if (intent instanceof MultiPointToSinglePointIntent) {
isRelevant = isIntentRelevant((MultiPointToSinglePointIntent) intent, edgePoints) && isIntentRelevantToDevices(intent, devices) && isIntentRelevantToLinks(intent, links);
} else if (intent instanceof OpticalConnectivityIntent) {
opticalIntents.add((OpticalConnectivityIntent) intent);
}
if (isRelevant) {
intents.add(intent);
}
}
}
// packet-level ones.
for (OpticalConnectivityIntent intent : opticalIntents) {
if (isIntentRelevant(intent, intents) && isIntentRelevantToDevices(intent, devices)) {
intents.add(intent);
}
}
return intents;
}
use of org.onosproject.net.intent.MultiPointToSinglePointIntent in project onos by opennetworkinglab.
the class VplsIntentUtility method buildUniIntent.
/**
* Builds a unicast intent.
*
* @param key key to identify the intent
* @param appId application ID for this Intent
* @param srcs the source Connect Points
* @param dst the destination Connect Point
* @param host destination Host
* @param encap the encapsulation type
* @param resourceGroup resource group for this Intent
* @return the generated multi-point to single-point intent
*/
static MultiPointToSinglePointIntent buildUniIntent(Key key, ApplicationId appId, Set<FilteredConnectPoint> srcs, FilteredConnectPoint dst, Host host, EncapsulationType encap, ResourceGroup resourceGroup) {
log.debug("Building unicast intent {} for destination {}", MP2SP, dst);
MultiPointToSinglePointIntent.Builder intentBuilder;
TrafficSelector selector = DefaultTrafficSelector.builder().matchEthDst(host.mac()).build();
intentBuilder = MultiPointToSinglePointIntent.builder().appId(appId).key(key).selector(selector).filteredIngressPoints(srcs).filteredEgressPoint(dst).constraints(PARTIAL_FAILURE_CONSTRAINT).priority(PRIORITY_OFFSET + PRIORITY_UNI).resourceGroup(resourceGroup);
setEncap(intentBuilder, PARTIAL_FAILURE_CONSTRAINT, encap);
return intentBuilder.build();
}
use of org.onosproject.net.intent.MultiPointToSinglePointIntent 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;
}
Aggregations