use of org.onosproject.net.domain.DomainId in project onos by opennetworkinglab.
the class DomainIdCompleter method complete.
@Override
public int complete(Session session, CommandLine commandLine, List<String> candidates) {
// Delegate string completer
StringsCompleter delegate = new StringsCompleter();
// Fetch our service and feed it's offerings to the string completer
DomainService service = AbstractShellCommand.get(DomainService.class);
Iterator<DomainId> it = service.getDomainIds().iterator();
SortedSet<String> strings = delegate.getStrings();
while (it.hasNext()) {
strings.add(it.next().id());
}
// Now let the completer do the work for figuring out what to offer.
return delegate.complete(session, commandLine, candidates);
}
use of org.onosproject.net.domain.DomainId in project onos by opennetworkinglab.
the class GetDomainsCommand method doExecute.
@Override
public void doExecute() {
DomainService domainService = AbstractShellCommand.get(DomainService.class);
Set<DomainId> domainIds = domainService.getDomainIds();
domainIds.forEach(domainId -> print("%s", domainId.id()));
}
use of org.onosproject.net.domain.DomainId in project onos by opennetworkinglab.
the class LinkCollectionCompiler method getDomainIntents.
/**
* Creates the domain intents that the {@link LinkCollectionIntent} contains.
*
* @param intent the link collection intent
* @param domainService the domain service
* @return the resulting list of domain intents
*/
protected List<Intent> getDomainIntents(LinkCollectionIntent intent, DomainService domainService) {
ImmutableList.Builder<Intent> intentList = ImmutableList.builder();
// TODO: support multi point to multi point
if (intent.filteredIngressPoints().size() != 1 || intent.filteredEgressPoints().size() != 1) {
log.warn("Multiple ingress or egress ports not supported!");
return intentList.build();
}
ImmutableList.Builder<Link> domainLinks = ImmutableList.builder();
// get the initial ingress connection point
FilteredConnectPoint ingress = intent.filteredIngressPoints().iterator().next();
FilteredConnectPoint egress;
DeviceId currentDevice = ingress.connectPoint().deviceId();
// the current domain (or LOCAL)
DomainId currentDomain = domainService.getDomain(currentDevice);
// if we entered a domain store the domain ingress
FilteredConnectPoint domainIngress = LOCAL.equals(currentDomain) ? null : ingress;
// this is necessary because a set is not sorted by default
for (int i = 0; i < intent.links().size(); i++) {
// find the next link
List<Link> nextLinks = getEgressLinks(intent.links(), currentDevice);
// no matching link exists
if (nextLinks.isEmpty()) {
throw new IntentCompilationException("No matching link starting at " + ingress.connectPoint().deviceId());
}
// get the first link
Link nextLink = nextLinks.get(0);
ingress = new FilteredConnectPoint(nextLink.src());
egress = new FilteredConnectPoint(nextLink.dst());
// query the domain for the domain of the link's destination
DomainId dstDomain = domainService.getDomain(egress.connectPoint().deviceId());
if (!currentDomain.equals(dstDomain)) {
// we are leaving the current domain or LOCAL
log.debug("Domain transition from {} to {}.", currentDomain, dstDomain);
if (!LOCAL.equals(currentDomain)) {
// add the domain intent to the intent list
intentList.add(createDomainP2PIntent(intent, domainIngress, ingress, domainLinks.build()));
// TODO: might end up with an unused builder
// reset domain links builder
domainLinks = ImmutableList.builder();
}
// update current domain (might be LOCAL)
currentDomain = dstDomain;
// update the domain's ingress
domainIngress = LOCAL.equals(currentDomain) ? null : egress;
} else {
if (!LOCAL.equals(currentDomain)) {
// we are staying in the same domain, store the traversed link
domainLinks.add(nextLink);
log.debug("{} belongs to the same domain.", egress.connectPoint().deviceId());
}
}
currentDevice = egress.connectPoint().deviceId();
}
// get the egress point
egress = intent.filteredEgressPoints().iterator().next();
// still inside a domain?
if (!LOCAL.equals(currentDomain) && currentDomain.equals(domainService.getDomain(egress.connectPoint().deviceId()))) {
// add intent
intentList.add(createDomainP2PIntent(intent, domainIngress, egress, domainLinks.build()));
}
return intentList.build();
}
Aggregations