org.onosproject.net.Device Java Examples

The following examples show how to use org.onosproject.net.Device. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XmppDeviceProvider.java    From onos with Apache License 2.0 6 votes vote down vote up
private void connectDevice(XmppDeviceId xmppDeviceId) {
    DeviceId deviceId = DeviceId.deviceId(xmppDeviceId.id());
    String ipAddress = controller.getDevice(xmppDeviceId).getIpAddress().getAddress().getHostAddress();
    // Assumption: manufacturer is uniquely identified by domain part of JID
    String manufacturer = xmppDeviceId.getJid().getDomain();

    ChassisId cid = new ChassisId();

    SparseAnnotations annotations = DefaultAnnotations.builder()
            .set(AnnotationKeys.PROTOCOL, XMPP.toUpperCase())
            .set("IpAddress", ipAddress)
            .build();
    DeviceDescription deviceDescription = new DefaultDeviceDescription(
            deviceId.uri(),
            Device.Type.OTHER,
            manufacturer, HARDWARE_VERSION,
            SOFTWARE_VERSION, SERIAL_NUMBER,
            cid, true,
            annotations);

    if (deviceService.getDevice(deviceId) == null) {
        providerService.deviceConnected(deviceId, deviceDescription);
    }
}
 
Example #2
Source File: VtnManager.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public void onOvsDetected(Device device) {
    if (device == null) {
        log.error("The device is null");
        return;
    }
    if (!mastershipService.isLocalMaster(device.id())) {
        return;
    }
    // Create tunnel out flow rules
    applyTunnelOut(device, Objective.Operation.ADD);
    // apply L3 arp flows
    Iterable<RouterInterface> interfaces = routerInterfaceService
            .getRouterInterfaces();
    interfaces.forEach(routerInf -> {
        VirtualPort gwPort = virtualPortService.getPort(routerInf.portId());
        if (gwPort == null) {
            gwPort = VtnData.getPort(vPortStore, routerInf.portId());
        }
        applyL3ArpFlows(device.id(), gwPort, Objective.Operation.ADD);
    });
}
 
Example #3
Source File: Tl1DeviceProvider.java    From onos with Apache License 2.0 6 votes vote down vote up
private void connectDevice(Tl1Device device) {
    try {
        // Add device to TL1 controller
        DeviceId deviceId = DeviceId.deviceId(
                new URI(Tl1DeviceConfig.TL1, device.ip() + ":" + device.port(), null));

        if (controller.addDevice(deviceId, device)) {
            SparseAnnotations ann = DefaultAnnotations.builder()
                    .set(AnnotationKeys.PROTOCOL, Tl1DeviceConfig.TL1.toUpperCase())
                    .build();
            // Register device in the core with default parameters and mark it as unavailable
            DeviceDescription dd = new DefaultDeviceDescription(deviceId.uri(),
                                                                Device.Type.SWITCH,
                                                                UNKNOWN, UNKNOWN,
                                                                UNKNOWN, UNKNOWN,
                                                                new ChassisId(),
                                                                false, ann);
            providerService.deviceConnected(deviceId, dd);
        }
    } catch (URISyntaxException e) {
        log.error("Skipping device {}", device, e);
    }
}
 
Example #4
Source File: Topo2Jsonifier.java    From onos with Apache License 2.0 6 votes vote down vote up
private ObjectNode json(String ridStr, UiDevice device) {
    ObjectNode node = objectNode()
            .put("id", device.idAsString())
            .put("nodeType", DEVICE)
            .put("type", device.type())
            .put("online", deviceService.isAvailable(device.id()))
            .put("master", master(device.id()))
            .put("layer", device.layer());
    Device d = device.backingDevice();
    if (d != null) {
        addProps(node, d);
        addGeoGridLocation(node, d);
    }
    addMetaUi(node, ridStr, device.idAsString());

    return node;
}
 
Example #5
Source File: ClusterViewMessageHandler.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public void process(ObjectNode payload) {

    String id = string(payload, ID);
    ClusterService cs = get(ClusterService.class);
    ControllerNode node = cs.getNode(new NodeId(id));

    ObjectNode data = objectNode();
    ArrayNode devices = arrayNode();
    List<Device> deviceList = populateDevices(node);

    data.put(ID, node.id().toString());
    data.put(IP, node.ip().toString());

    for (Device d : deviceList) {
        devices.add(deviceData(d));
    }

    data.set(DEVICES, devices);

    //TODO put more detail info to data

    ObjectNode rootNode = objectNode();
    rootNode.set(DETAILS, data);
    sendMessage(CLUSTER_DETAILS_RESP, rootNode);
}
 
Example #6
Source File: Srv6InsertCommand.java    From onos-p4-tutorial with Apache License 2.0 6 votes vote down vote up
@Override
protected void doExecute() {
    DeviceService deviceService = get(DeviceService.class);
    Srv6Component app = get(Srv6Component.class);

    Device device = deviceService.getDevice(DeviceId.deviceId(uri));
    if (device == null) {
        print("Device \"%s\" is not found", uri);
        return;
    }
    if (segments.size() == 0) {
        print("No segments listed");
        return;
    }
    List<Ip6Address> sids = segments.stream()
            .map(Ip6Address::valueOf)
            .collect(Collectors.toList());
    Ip6Address destIp = sids.get(sids.size() - 1);

    print("Installing path on device %s: %s",
            uri, sids.stream()
                     .map(IpAddress::toString)
                     .collect(Collectors.joining(", ")));
    app.insertSrv6InsertRule(device.id(), destIp, 128, sids);

}
 
Example #7
Source File: IsisTopologyProvider.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public void routerAdded(IsisRouter isisRouter) {
    String systemId = isisRouter.systemId();
    log.info("Added device {}", systemId);
    DeviceId deviceId = DeviceId.deviceId(IsisRouterId.uri(systemId));
    Device.Type deviceType = Device.Type.ROUTER;
    //If our routerType is Dr or Bdr type is PSEUDO
    if (isisRouter.isDis()) {
        deviceType = Device.Type.ROUTER;
    } else {
        deviceType = Device.Type.VIRTUAL;
    }
    ChassisId cId = new ChassisId();
    DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder();
    newBuilder.set(AnnotationKeys.TYPE, "L3");
    newBuilder.set("RouterId", systemId);
    DeviceDescription description =
            new DefaultDeviceDescription(IsisRouterId.uri(systemId), deviceType, UNKNOWN, UNKNOWN, UNKNOWN,
                                         UNKNOWN, cId, newBuilder.build());
    deviceProviderService.deviceConnected(deviceId, description);
    System.out.println("Device added: " + systemId);
}
 
Example #8
Source File: VirtualNetworkPacketManager.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Pushes packet intercept flow rules to the device.
 *
 * @param device  the device to push the rules to
 * @param request the packet request
 */
private void pushRule(Device device, PacketRequest request) {
    if (!device.type().equals(Device.Type.VIRTUAL)) {
        return;
    }

    ForwardingObjective forwarding = createBuilder(request)
            .add(new ObjectiveContext() {
                @Override
                public void onError(Objective objective, ObjectiveError error) {
                    log.warn("Failed to install packet request {} to {}: {}",
                             request, device.id(), error);
                }
            });

    objectiveService.forward(device.id(), forwarding);
}
 
Example #9
Source File: FlowsWebResource.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Gets all flow entries. Returns array of all flow rules in the system.
 *
 * @return 200 OK with a collection of flows
 * @onos.rsModel FlowEntries
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
public Response getFlows() {
    ObjectNode root = mapper().createObjectNode();
    ArrayNode flowsNode = root.putArray(FLOWS);
    FlowRuleService service = get(FlowRuleService.class);
    Iterable<Device> devices = get(DeviceService.class).getDevices();
    for (Device device : devices) {
        Iterable<FlowEntry> flowEntries = service.getFlowEntries(device.id());
        if (flowEntries != null) {
            for (FlowEntry entry : flowEntries) {
                flowsNode.add(codec(FlowEntry.class).encode(entry, this));
            }
        }
    }

    return ok(root).build();
}
 
Example #10
Source File: DeviceCodec.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public ObjectNode encode(Device device, CodecContext context) {
    checkNotNull(device, "Device cannot be null");
    DeviceService service = context.getService(DeviceService.class);
    DriverService driveService = context.getService(DriverService.class);
    ObjectNode result = context.mapper().createObjectNode()
            .put(ID, device.id().toString())
            .put(TYPE, device.type().name())
            .put(AVAILABLE, service.isAvailable(device.id()))
            .put(ROLE, service.getRole(device.id()).toString())
            .put(MFR, device.manufacturer())
            .put(HW, device.hwVersion())
            .put(SW, device.swVersion())
            .put(SERIAL, device.serialNumber())
            .put(DRIVER, driveService.getDriver(device.id()).name())
            .put(CHASSIS_ID, device.chassisId().toString())
            .put(LAST_UPDATE, Long.toString(service.getLastUpdatedInstant(device.id())))
            .put(HUMAN_READABLE_LAST_UPDATE, service.localStatus(device.id()));
    return annotate(result, device, context);
}
 
Example #11
Source File: PacketManager.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Pushes packet intercept flow rules to the device.
 *
 * @param device  the device to push the rules to
 * @param request the packet request
 */
private void pushRule(Device device, PacketRequest request) {
    if (!device.type().equals(Device.Type.SWITCH)) {
        return;
    }

    if (!deviceService.isAvailable(device.id())) {
        return;
    }

    ForwardingObjective forwarding = createBuilder(request)
            .add(new ObjectiveContext() {
                @Override
                public void onError(Objective objective, ObjectiveError error) {
                    log.warn("Failed to install packet request {} to {}: {}",
                             request, device.id(), error);
                }
            });

    objectiveService.forward(device.id(), forwarding);
}
 
Example #12
Source File: StratumDeviceDescriptionDiscovery.java    From onos with Apache License 2.0 6 votes vote down vote up
@Override
public DeviceDescription discoverDeviceDetails() {
    final DeviceDescription p4Descr = p4runtime.discoverDeviceDetails();
    final DeviceDescription gnoiDescr = gnoi.discoverDeviceDetails();
    final DeviceDescription gnmiDescr = gnmi.discoverDeviceDetails();
    return new DefaultDeviceDescription(
            data().deviceId().uri(),
            Device.Type.SWITCH,
            data().driver().manufacturer(),
            data().driver().hwVersion(),
            data().driver().swVersion(),
            UNKNOWN,
            p4Descr.chassisId(),
            // Availability is mandated by P4Runtime.
            p4Descr.isDefaultAvailable(),
            DefaultAnnotations.builder()
                    .putAll(p4Descr.annotations())
                    .putAll(gnmiDescr.annotations())
                    .putAll(gnoiDescr.annotations())
                    .set(AnnotationKeys.PROTOCOL, format(
                            "%s, %s, %s",
                            p4Descr.annotations().value(AnnotationKeys.PROTOCOL),
                            gnmiDescr.annotations().value(AnnotationKeys.PROTOCOL),
                            gnoiDescr.annotations().value(AnnotationKeys.PROTOCOL)))
                    .build());
}
 
Example #13
Source File: VirtualNetworkDeviceManagerTest.java    From onos with Apache License 2.0 6 votes vote down vote up
/**
 * Tests querying for a device and available devices by device type.
 */
@Test
public void testGetDeviceType() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    manager.createVirtualDevice(virtualNetwork.id(), DID1);
    manager.createVirtualDevice(virtualNetwork.id(), DID2);

    DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class);

    // test the getDevices(Type) method.
    Iterator<Device> it = deviceService.getDevices(Device.Type.VIRTUAL).iterator();
    assertEquals("The device set size did not match.", 2, Iterators.size(it));
    Iterator<Device> it2 = deviceService.getDevices(Device.Type.SWITCH).iterator();
    assertEquals("The device set size did not match.", 0, Iterators.size(it2));

    // test the getAvailableDevices(Type) method.
    Iterator<Device> it3 = deviceService.getAvailableDevices(Device.Type.VIRTUAL).iterator();
    assertEquals("The device set size did not match.", 2, Iterators.size(it3));
}
 
Example #14
Source File: SimpleDeviceStoreTest.java    From onos with Apache License 2.0 6 votes vote down vote up
@Test
public final void testGetDevices() {
    assertEquals("initialy empty", 0, Iterables.size(deviceStore.getDevices()));

    putDevice(DID1, SW1);
    putDevice(DID2, SW2);
    putDevice(DID1, SW1);

    assertEquals("expect 2 uniq devices",
            2, Iterables.size(deviceStore.getDevices()));

    Map<DeviceId, Device> devices = new HashMap<>();
    for (Device device : deviceStore.getDevices()) {
        devices.put(device.id(), device);
    }

    assertDevice(DID1, SW1, devices.get(DID1));
    assertDevice(DID2, SW2, devices.get(DID2));

    // add case for new node?
}
 
Example #15
Source File: DeviceManager.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public Iterable<Device> getDevices(Type type) {
    checkPermission(DEVICE_READ);
    Set<Device> results = new HashSet<>();
    Iterable<Device> devices = store.getDevices();
    if (devices != null) {
        devices.forEach(d -> {
            if (type.equals(d.type())) {
                results.add(d);
            }
        });
    }
    return results;
}
 
Example #16
Source File: VirtualNetworkDeviceManagerTest.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Tests the getDevices(), getAvailableDevices(), getDeviceCount(), getDevice(), and isAvailable() methods.
 */
@Test
public void testGetDevices() {
    manager.registerTenantId(TenantId.tenantId(tenantIdValue1));
    VirtualNetwork virtualNetwork = manager.createVirtualNetwork(TenantId.tenantId(tenantIdValue1));
    VirtualDevice device1 = manager.createVirtualDevice(virtualNetwork.id(), DID1);
    VirtualDevice device2 = manager.createVirtualDevice(virtualNetwork.id(), DID2);

    DeviceService deviceService = manager.get(virtualNetwork.id(), DeviceService.class);

    // test the getDevices() method
    Iterator<Device> it = deviceService.getDevices().iterator();
    assertEquals("The device set size did not match.", 2, Iterators.size(it));

    // test the getAvailableDevices() method
    Iterator<Device> it2 = deviceService.getAvailableDevices().iterator();
    assertEquals("The device set size did not match.", 2, Iterators.size(it2));

    // test the getDeviceCount() method
    assertEquals("The device set size did not match.", 2, deviceService.getDeviceCount());

    // test the getDevice() method
    assertEquals("The expect device did not match.", device1,
                 deviceService.getDevice(DID1));
    assertNotEquals("The expect device should not have matched.", device1,
                    deviceService.getDevice(DID2));

    // test the isAvailable() method
    assertTrue("The expect device availability did not match.",
               deviceService.isAvailable(DID1));
    assertFalse("The expect device availability did not match.",
                deviceService.isAvailable(DID3));
}
 
Example #17
Source File: FlowsListCommand.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Produces a JSON array of flows grouped by the each device.
 *
 * @param devices     collection of devices to group flow by
 * @param flows       collection of flows per each device
 * @return JSON array
 */
private JsonNode json(Iterable<Device> devices,
                      Map<Device, List<FlowEntry>> flows) {
    ObjectMapper mapper = new ObjectMapper();
    ArrayNode result = mapper.createArrayNode();
    for (Device device : devices) {
        result.add(json(mapper, device, flows.get(device)));
    }
    return result;
}
 
Example #18
Source File: DeviceViewMessageHandler.java    From onos with Apache License 2.0 5 votes vote down vote up
private String devicePipeconf(Device device) {
    PiPipeconfService service = get(PiPipeconfService.class);
    Optional<PiPipeconfId> pipeconfId = service.ofDevice(device.id());
    if (pipeconfId.isPresent()) {
        return pipeconfId.get().id();
    } else {
        return NONE;
    }
}
 
Example #19
Source File: VirtualNetworkPacketManager.java    From onos with Apache License 2.0 5 votes vote down vote up
private void localEmit(NetworkId networkId, OutboundPacket packet) {
    Device device = deviceService.getDevice(packet.sendThrough());
    if (device == null) {
        return;
    }
    VirtualPacketProvider packetProvider = providerService.provider();

    if (packetProvider != null) {
        packetProvider.emit(networkId, packet);
    }
}
 
Example #20
Source File: DeviceEventTest.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
@Test
public void withTime() {
    Device device = createDevice();
    Port port = new DefaultPort(device, PortNumber.portNumber(123), true);
    DeviceEvent event = new DeviceEvent(DeviceEvent.Type.DEVICE_ADDED,
            device, port, 123L);
    validateEvent(event, DeviceEvent.Type.DEVICE_ADDED, device, 123L);
    assertEquals("incorrect port", port, event.port());
}
 
Example #21
Source File: PceccSrTeBeHandler.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Returns PCEP client.
 *
 * @return PCEP client
 */
private PcepClient getPcepClient(DeviceId deviceId) {
    Device device = deviceService.getDevice(deviceId);

    // In future projections instead of annotations will be used to fetch LSR ID.
    String lsrId = device.annotations().value(LSR_ID);
    PcepClient pcc = clientController.getClient(PccId.pccId(IpAddress.valueOf(lsrId)));
    return pcc;
}
 
Example #22
Source File: EvpnManager.java    From onos with Apache License 2.0 5 votes vote down vote up
private Set<Host> getHostsByVpn(Device device, EvpnRoute route) {
    Set<Host> vpnHosts = Sets.newHashSet();
    Set<Host> hosts = hostService.getConnectedHosts(device.id());
    for (Host h : hosts) {
        String ifaceId = h.annotations().value(IFACEID);
        if (!vpnPortService.exists(VpnPortId.vpnPortId(ifaceId))) {
            continue;
        }

        VpnPort vpnPort = vpnPortService
                .getPort(VpnPortId.vpnPortId(ifaceId));
        VpnInstanceId vpnInstanceId = vpnPort.vpnInstanceId();

        VpnInstance vpnInstance = vpnInstanceService
                .getInstance(vpnInstanceId);

        List<VpnRouteTarget> expRt = route.exportRouteTarget();
        List<VpnRouteTarget> similar = new LinkedList<>(expRt);
        similar.retainAll(vpnInstance.getImportRouteTargets());
        //TODO: currently checking for RT comparison.
        //TODO: Need to check about RD comparison is really required.
        //if (route.routeDistinguisher()
        //.equals(vpnInstance.routeDistinguisher())) {
        if (!similar.isEmpty()) {
            vpnHosts.add(h);
        }
    }
    return vpnHosts;
}
 
Example #23
Source File: DomainManager.java    From onos with Apache License 2.0 5 votes vote down vote up
private DomainId getAnnotatedDomainId(Device device) {
    if (!device.annotations().keys().contains(DOMAIN_ID)) {
        return DomainId.LOCAL;
    } else {
        return DomainId.domainId(
                device.annotations().value(DOMAIN_ID));
    }
}
 
Example #24
Source File: LldpLinkProvider.java    From onos with Apache License 2.0 5 votes vote down vote up
/**
 * Updates discovery helper for specified device.
 *
 * Adds and starts a discovery helper for specified device if enabled,
 * calls {@link #removeDevice(DeviceId)} otherwise.
 *
 * @param device device to add
 * @return discovery helper if discovery is enabled for the device
 */
private Optional<LinkDiscovery> updateDevice(Device device) {
    if (device == null) {
        return Optional.empty();
    }
    if (!masterService.isLocalMaster(device.id())) {
        // Reset the last seen time for all links to this device
        // then stop discovery for this device
        List<LinkKey> updateLinks = new LinkedList<>();
        linkTimes.forEach((link, time) -> {
            if (link.dst().deviceId().equals(device.id())) {
                updateLinks.add(link);
            }
        });
        updateLinks.forEach(link -> linkTimes.remove(link));
        removeDevice(device.id());
        return Optional.empty();
    }
    if (rules.isSuppressed(device) || isBlacklisted(device.id())) {
        log.trace("LinkDiscovery from {} disabled by configuration", device.id());
        removeDevice(device.id());
        return Optional.empty();
    }

    LinkDiscovery ld = discoverers.computeIfAbsent(device.id(),
                                 did -> new LinkDiscovery(device.id(), context));
    if (ld.isStopped()) {
        ld.start();
    }
    return Optional.of(ld);
}
 
Example #25
Source File: AdvaTerminalDeviceDiscovery.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public DeviceDescription discoverDeviceDetails() {
    return new DefaultDeviceDescription(handler().data().deviceId().uri(),
                                        Device.Type.TERMINAL_DEVICE,
                                        "ADVA",
                                        "FSP3000C",
                                        "3.1",
                                        "",
                                        new ChassisId("1"));
}
 
Example #26
Source File: RoadmPortViewMessageHandler.java    From onos with Apache License 2.0 5 votes vote down vote up
private String getPostFecBer(DeviceId deviceId, PortNumber portNumber) {
    Device device = deviceService.getDevice(deviceId);
    if (device == null || !device.is(BitErrorRateState.class)) {
        return RoadmUtil.UNKNOWN;
    }
    BitErrorRateState bitErrorRateState = device.as(BitErrorRateState.class);
    Optional<Double> postFecBer = bitErrorRateState.getPostFecBer(deviceId, portNumber);
    Double postFecBerVal = null;
    if (postFecBer.isPresent()) {
        postFecBerVal = postFecBer.orElse(Double.MIN_VALUE);
    }
    return RoadmUtil.objectToString(postFecBerVal, RoadmUtil.UNKNOWN);
}
 
Example #27
Source File: LinkDiscoveryAristaImpl.java    From onos with Apache License 2.0 5 votes vote down vote up
private Optional<Device> findRemoteDeviceByChassisId(DeviceService deviceService, String remoteChassisIdString) {
    String forMacTmp = remoteChassisIdString
            .replace(".", "")
            .replaceAll("(.{2})", "$1:")
            .trim()
            .substring(0, 17);
    MacAddress mac = MacAddress.valueOf(forMacTmp);
    Supplier<Stream<Device>> deviceStream = () ->
            StreamSupport.stream(deviceService.getAvailableDevices().spliterator(), false);
    Optional<Device> remoteDeviceOptional = deviceStream.get()
            .filter(device -> device.chassisId() != null
                    && MacAddress.valueOf(device.chassisId().value()).equals(mac))
            .findAny();

    if (remoteDeviceOptional.isPresent()) {
        log.debug("remoteDevice found by chassis id: {}", forMacTmp);
        return remoteDeviceOptional;
    } else {
        remoteDeviceOptional = deviceStream.get().filter(device ->
            Tools.stream(deviceService.getPorts(device.id()))
                    .anyMatch(port -> port.annotations().keys().contains(AnnotationKeys.PORT_MAC)
                            && MacAddress.valueOf(port.annotations().value(AnnotationKeys.PORT_MAC))
                    .equals(mac)))
                .findAny();
        if (remoteDeviceOptional.isPresent()) {
            log.debug("remoteDevice found by port mac: {}", forMacTmp);
            return remoteDeviceOptional;
        } else {
            return Optional.empty();
        }
    }
}
 
Example #28
Source File: RolesCommand.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
protected void doExecute() {
    DeviceService deviceService = get(DeviceService.class);
    MastershipService roleService = get(MastershipService.class);

    if (outputJson()) {
        print("%s", json(roleService, getSortedDevices(deviceService)));
    } else {
        for (Device d : getSortedDevices(deviceService)) {
            DeviceId did = d.id();
            printRoles(roleService, did);
        }
    }
}
 
Example #29
Source File: OFSwitchManager.java    From onos with Apache License 2.0 5 votes vote down vote up
private Set<DeviceId> devices(NetworkId networkId) {
    Set<DeviceId> deviceIds = virtualNetService.getVirtualDevices(networkId)
            .stream()
            .map(Device::id)
            .collect(Collectors.toSet());
    return ImmutableSet.copyOf(deviceIds);
}
 
Example #30
Source File: PacketManager.java    From onos with Apache License 2.0 5 votes vote down vote up
@Override
public void requestPackets(PacketRequest request) {
    DeviceId deviceid = request.deviceId().orElse(null);

    if (deviceid != null) {
        Device device = deviceService.getDevice(deviceid);

        if (device != null) {
            pushRule(deviceService.getDevice(deviceid), request);
        }
    } else {
        pushToAllDevices(request);
    }
}