Search in sources :

Example 61 with ConnectPoint

use of org.onosproject.net.ConnectPoint in project onos by opennetworkinglab.

the class AddTunnelCommand method doExecute.

@Override
protected void doExecute() {
    IntentDomainService service = get(IntentDomainService.class);
    ConnectPoint one = ConnectPoint.deviceConnectPoint(oneString);
    ConnectPoint two = ConnectPoint.deviceConnectPoint(twoString);
    TunnelPrimitive tunnel = new TunnelPrimitive(appId(), one, two);
    // get the first domain (there should only be one)
    final IntentDomainId domainId;
    try {
        domainId = service.getDomains().iterator().next().id();
    } catch (NoSuchElementException | NullPointerException e) {
        print("No domains found");
        return;
    }
    service.request(domainId, tunnel).forEach(r -> service.submit(domainId, r));
    print("Intent domain tunnel submitted:\n%s", tunnel);
}
Also used : TunnelPrimitive(org.onosproject.incubator.net.domain.TunnelPrimitive) IntentDomainId(org.onosproject.incubator.net.domain.IntentDomainId) IntentDomainService(org.onosproject.incubator.net.domain.IntentDomainService) ConnectPoint(org.onosproject.net.ConnectPoint) NoSuchElementException(java.util.NoSuchElementException)

Example 62 with ConnectPoint

use of org.onosproject.net.ConnectPoint in project onos by opennetworkinglab.

the class TestProtectionEndpointIntentCommand method output.

private FilteredConnectPoint output(DeviceId did, String portNumberStr, String vlanStr) {
    ConnectPoint cp = new ConnectPoint(did, PortNumber.fromString(portNumberStr));
    if (deviceService.getPort(cp) == null) {
        print("Unknown port: %s", cp);
    }
    if (vlanStr == null) {
        return new FilteredConnectPoint(cp);
    } else {
        VlanId vlan = VlanId.vlanId(vlanStr);
        TrafficSelector sel = DefaultTrafficSelector.builder().matchVlanId(vlan).build();
        return new FilteredConnectPoint(cp, sel);
    }
}
Also used : TrafficSelector(org.onosproject.net.flow.TrafficSelector) DefaultTrafficSelector(org.onosproject.net.flow.DefaultTrafficSelector) ConnectPoint(org.onosproject.net.ConnectPoint) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint) VlanId(org.onlab.packet.VlanId) FilteredConnectPoint(org.onosproject.net.FilteredConnectPoint)

Example 63 with ConnectPoint

use of org.onosproject.net.ConnectPoint in project onos by opennetworkinglab.

the class McastDeleteCommand method doExecute.

@Override
protected void doExecute() {
    MulticastRouteService mcastRouteManager = get(MulticastRouteService.class);
    if ("*".equals(sAddr) && "*".equals(gAddr)) {
        // Clear all routes
        mcastRouteManager.getRoutes().forEach(mcastRouteManager::remove);
        return;
    }
    McastRoute mRoute = new McastRoute(IpAddress.valueOf(sAddr), IpAddress.valueOf(gAddr), McastRoute.Type.STATIC);
    if (egressList == null) {
        mcastRouteManager.remove(mRoute);
        print(D_FORMAT_MAPPING, mRoute.type(), mRoute.group(), mRoute.source());
    } else {
        // check list for validity before we begin to delete.
        for (String egress : egressList) {
            ConnectPoint eCp = ConnectPoint.deviceConnectPoint(egress);
            mcastRouteManager.removeSink(mRoute, eCp);
        }
        print(U_FORMAT_MAPPING, mRoute.type(), mRoute.group(), mRoute.source());
    }
}
Also used : MulticastRouteService(org.onosproject.net.mcast.MulticastRouteService) McastRoute(org.onosproject.net.mcast.McastRoute) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 64 with ConnectPoint

use of org.onosproject.net.ConnectPoint in project onos by opennetworkinglab.

the class McastJoinCommand method doExecute.

@Override
protected void doExecute() {
    MulticastRouteService mcastRouteManager = get(MulticastRouteService.class);
    McastRoute mRoute = new McastRoute(IpAddress.valueOf(sAddr), IpAddress.valueOf(gAddr), McastRoute.Type.STATIC);
    mcastRouteManager.add(mRoute);
    if (ingressPort != null) {
        ConnectPoint ingress = ConnectPoint.deviceConnectPoint(ingressPort);
        mcastRouteManager.addSource(mRoute, ingress);
    }
    if (ports != null) {
        for (String egCP : ports) {
            ConnectPoint egress = ConnectPoint.deviceConnectPoint(egCP);
            mcastRouteManager.addSink(mRoute, egress);
        }
    }
    printMcastRoute(mRoute);
}
Also used : MulticastRouteService(org.onosproject.net.mcast.MulticastRouteService) McastRoute(org.onosproject.net.mcast.McastRoute) ConnectPoint(org.onosproject.net.ConnectPoint)

Example 65 with ConnectPoint

use of org.onosproject.net.ConnectPoint in project onos by opennetworkinglab.

the class PeerConnectPointCompleter method choices.

@Override
protected List<String> choices() {
    DeviceService deviceService = getService(DeviceService.class);
    LinkService linkService = getService(LinkService.class);
    Optional<ConnectPoint> port = Arrays.asList(commandLine.getArguments()).stream().filter(s -> s.contains(":") && s.contains("/")).map(s -> {
        try {
            return deviceConnectPoint(s);
        } catch (IllegalArgumentException e) {
            // silently ill-formed String
            return null;
        }
    }).filter(Objects::nonNull).filter(cp -> deviceService.getPort(cp) != null).findFirst();
    if (!port.isPresent()) {
        // no candidate
        return Collections.emptyList();
    }
    final ConnectPoint cp = port.get();
    return linkService.getLinks(cp).stream().flatMap(l -> Stream.of(l.src(), l.dst())).filter(peer -> !cp.equals(peer)).distinct().map(ConnectPoint::toString).collect(Collectors.toList());
}
Also used : Arrays(java.util.Arrays) DefaultServiceDirectory.getService(org.onlab.osgi.DefaultServiceDirectory.getService) DeviceService(org.onosproject.net.device.DeviceService) ConnectPoint.deviceConnectPoint(org.onosproject.net.ConnectPoint.deviceConnectPoint) Collectors(java.util.stream.Collectors) ConnectPoint(org.onosproject.net.ConnectPoint) Objects(java.util.Objects) AbstractChoicesCompleter(org.onosproject.cli.AbstractChoicesCompleter) List(java.util.List) Stream(java.util.stream.Stream) Service(org.apache.karaf.shell.api.action.lifecycle.Service) LinkService(org.onosproject.net.link.LinkService) Optional(java.util.Optional) Collections(java.util.Collections) DeviceService(org.onosproject.net.device.DeviceService) Objects(java.util.Objects) LinkService(org.onosproject.net.link.LinkService) ConnectPoint.deviceConnectPoint(org.onosproject.net.ConnectPoint.deviceConnectPoint) ConnectPoint(org.onosproject.net.ConnectPoint)

Aggregations

ConnectPoint (org.onosproject.net.ConnectPoint)536 Test (org.junit.Test)149 DeviceId (org.onosproject.net.DeviceId)125 FilteredConnectPoint (org.onosproject.net.FilteredConnectPoint)91 Link (org.onosproject.net.Link)88 Set (java.util.Set)86 PortNumber (org.onosproject.net.PortNumber)86 TrafficTreatment (org.onosproject.net.flow.TrafficTreatment)83 VlanId (org.onlab.packet.VlanId)78 TrafficSelector (org.onosproject.net.flow.TrafficSelector)75 DefaultTrafficTreatment (org.onosproject.net.flow.DefaultTrafficTreatment)72 Logger (org.slf4j.Logger)71 Port (org.onosproject.net.Port)70 List (java.util.List)69 Ethernet (org.onlab.packet.Ethernet)69 DeviceService (org.onosproject.net.device.DeviceService)67 Collectors (java.util.stream.Collectors)66 MacAddress (org.onlab.packet.MacAddress)64 DefaultTrafficSelector (org.onosproject.net.flow.DefaultTrafficSelector)64 Intent (org.onosproject.net.intent.Intent)62