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);
}
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);
}
}
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());
}
}
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);
}
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());
}
Aggregations