@Override public ObjectNode encode(Port port, CodecContext context) { checkNotNull(port, "Port cannot be null"); ObjectNode result = context.mapper().createObjectNode() .put(ELEMENT, port.element().id().toString()) .put(PORT_NAME, portName(port.number())) .put(IS_ENABLED, port.isEnabled()) .put(TYPE, port.type().toString().toLowerCase()) .put(PORT_SPEED, port.portSpeed()); return annotate(result, port, context); }
private void sendMouseData() { if (elementOfNote != null && elementOfNote instanceof Device) { DeviceId devId = (DeviceId) elementOfNote.id(); Set<Alarm> alarmsOnDevice = alarmService.getAlarms(devId); Highlights highlights = new Highlights(); addDeviceBadge(highlights, devId, alarmsOnDevice.size()); sendHighlights(highlights); } // Note: could also process Host, if available }
private boolean isBlacklisted(Port port) { return isBlacklisted(new ConnectPoint(port.element().id(), port.number())); }
private void printVlans(Port port) { DeviceService deviceService = get(DeviceService.class); DriverService driverService = get(DriverService.class); DeviceId deviceId = (DeviceId) port.element().id(); Device device = deviceService.getDevice(deviceId); if (!device.is(VlanQuery.class)) { // The relevant behavior is not supported by the device. print(NO_SUPPORT); return; } DriverHandler h = driverService.createHandler(deviceId); VlanQuery vlanQuery = h.behaviour(VlanQuery.class); try { Set<VlanId> vlanIds = vlanQuery.queryVlanIds(port.number()); if (vlanIds.isEmpty()) { print(VLAN_NOT_AVAILABLE); } else { print(AVAIL_VLANS, getRanges(vlanIds).toString()); } } catch (Exception e) { print(FAILURE + e.getMessage()); } }
private ConnectPoint staticPort(ConnectPoint connectPoint) { Port port = deviceService.getPort(connectPoint.deviceId(), connectPoint.port()); String staticPort = port.annotations().value(AnnotationKeys.STATIC_PORT); // FIXME: need a better way to match the port if (staticPort != null) { for (Port p : deviceService.getPorts(connectPoint.deviceId())) { if (staticPort.equals(p.number().name())) { return new ConnectPoint(p.element().id(), p.number()); } } } return null; }
private ConnectPoint staticPort(ConnectPoint connectPoint) { Port port = deviceService.getPort(connectPoint.deviceId(), connectPoint.port()); String staticPort = port.annotations().value(AnnotationKeys.STATIC_PORT); // FIXME: need a better way to match the port if (staticPort != null) { for (Port p : deviceService.getPorts(connectPoint.deviceId())) { if (staticPort.equals(p.number().name())) { return new ConnectPoint(p.element().id(), p.number()); } } } return null; }