Example #1
0
  // Parses the given node with device data and supplies the device.
  private void parseDevice(JsonNode node) {
    URI uri = URI.create(get(node, "uri"));
    Device.Type type = Device.Type.valueOf(get(node, "type", "SWITCH"));
    String mfr = get(node, "mfr", UNKNOWN);
    String hw = get(node, "hw", UNKNOWN);
    String sw = get(node, "sw", UNKNOWN);
    String serial = get(node, "serial", UNKNOWN);
    ChassisId cid = new ChassisId(get(node, "mac", "000000000000"));
    SparseAnnotations annotations = annotations(node.get("annotations"));

    DeviceDescription desc =
        new DefaultDeviceDescription(uri, type, mfr, hw, sw, serial, cid, annotations);
    DeviceId deviceId = deviceId(uri);
    deviceProviderService.deviceConnected(deviceId, desc);

    JsonNode ports = node.get("ports");
    if (ports != null) {
      parsePorts(deviceId, ports);
    }
  }
Example #2
0
 private void deviceAdded(RestSBDevice nodeId) {
   Preconditions.checkNotNull(nodeId, ISNOTNULL);
   DeviceId deviceId = nodeId.deviceId();
   ChassisId cid = new ChassisId();
   String ipAddress = nodeId.ip().toString();
   SparseAnnotations annotations = DefaultAnnotations.builder().set(IPADDRESS, ipAddress).build();
   DeviceDescription deviceDescription =
       new DefaultDeviceDescription(
           deviceId.uri(),
           Device.Type.SWITCH,
           UNKNOWN,
           UNKNOWN,
           UNKNOWN,
           UNKNOWN,
           cid,
           annotations);
   providerService.deviceConnected(deviceId, deviceDescription);
   nodeId.setActive(true);
   controller.addDevice(nodeId);
 }