Search in sources :

Example 1 with DomainId

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);
}
Also used : DomainId(org.onosproject.net.domain.DomainId) StringsCompleter(org.apache.karaf.shell.support.completers.StringsCompleter) DomainService(org.onosproject.net.domain.DomainService)

Example 2 with DomainId

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()));
}
Also used : DomainId(org.onosproject.net.domain.DomainId) DomainService(org.onosproject.net.domain.DomainService)

Example 3 with DomainId

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();
}
Also used : DomainId(org.onosproject.net.domain.DomainId) ImmutableList(com.google.common.collect.ImmutableList) DeviceId(org.onosproject.net.DeviceId) DomainPointToPointIntent(org.onosproject.net.domain.DomainPointToPointIntent) Intent(org.onosproject.net.intent.Intent) LinkCollectionIntent(org.onosproject.net.intent.LinkCollectionIntent) IntentCompilationException(org.onosproject.net.intent.IntentCompilationException) Link(org.onosproject.net.Link) ConnectPoint(org.onosproject.net.ConnectPoint) DomainConstraint(org.onosproject.net.intent.constraint.DomainConstraint) EncapsulationConstraint(org.onosproject.net.intent.constraint.EncapsulationConstraint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Aggregations

DomainId (org.onosproject.net.domain.DomainId)3 DomainService (org.onosproject.net.domain.DomainService)2 ImmutableList (com.google.common.collect.ImmutableList)1 StringsCompleter (org.apache.karaf.shell.support.completers.StringsCompleter)1 ConnectPoint (org.onosproject.net.ConnectPoint)1 DeviceId (org.onosproject.net.DeviceId)1 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)1 Link (org.onosproject.net.Link)1 DomainPointToPointIntent (org.onosproject.net.domain.DomainPointToPointIntent)1 Intent (org.onosproject.net.intent.Intent)1 IntentCompilationException (org.onosproject.net.intent.IntentCompilationException)1 LinkCollectionIntent (org.onosproject.net.intent.LinkCollectionIntent)1 DomainConstraint (org.onosproject.net.intent.constraint.DomainConstraint)1 EncapsulationConstraint (org.onosproject.net.intent.constraint.EncapsulationConstraint)1