/** * Creates a network element attributed to the specified provider. * * @param networkId network identifier * @param id device identifier */ public DefaultVirtualDevice(NetworkId networkId, DeviceId id) { super(PID, id, Type.VIRTUAL, VIRTUAL, VIRTUAL, VIRTUAL, VIRTUAL, new ChassisId(0)); this.networkId = networkId; }
@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); }
public void setChassisId(final ChassisId chassisId) { MacAddress chassisMac = MacAddress.valueOf(chassisId.value()); byte[] chassis = ArrayUtils.addAll(new byte[] {CHASSIS_TLV_SUBTYPE}, chassisMac.toBytes()); LLDPTLV chassisTLV = new LLDPTLV(); chassisTLV.setLength(CHASSIS_TLV_SIZE); chassisTLV.setType(CHASSIS_TLV_TYPE); chassisTLV.setValue(chassis); this.setChassisId(chassisTLV); }
/** * Constructs Dummy Device which only holds DeviceId. * * @param did device Id */ public DummyDevice(DeviceId did) { super(new ProviderId(did.uri().getScheme(), "PortCodec"), did, Type.SWITCH, "dummy", "0", "0", "0", new ChassisId(), DefaultAnnotations.EMPTY); } }
/** * {@inheritDoc} * * Note: ProviderId is not part of JSON representation. * Returned object will have random ProviderId set. */ @Override public Device decode(ObjectNode json, CodecContext context) { if (json == null || !json.isObject()) { return null; } DeviceId id = deviceId(json.get(ID).asText()); // TODO: add providerId to JSON if we need to recover them. ProviderId pid = new ProviderId(id.uri().getScheme(), "DeviceCodec"); Type type = Type.valueOf(json.get(TYPE).asText()); String mfr = json.get(MFR).asText(); String hw = json.get(HW).asText(); String sw = json.get(SW).asText(); String serial = json.get(SERIAL).asText(); ChassisId chassisId = new ChassisId(json.get(CHASSIS_ID).asText()); Annotations annotations = extractAnnotations(json, context); return new DefaultDevice(pid, id, type, mfr, hw, sw, serial, chassisId, annotations); } }
basic.map(BasicDeviceConfig::swVersion).orElse(unk), basic.map(BasicDeviceConfig::serial).orElse(unk), new ChassisId(), true); providerService.deviceConnected(did, desc);
@Override public void nodeAdded(OvsdbNodeId nodeId) { checkNotNull(nodeId, ISNOTNULL); DeviceId deviceId = DeviceId.deviceId(nodeId.toString()); URI uri = URI.create(nodeId.toString()); ChassisId cid = new ChassisId(); String ipAddress = nodeId.getIpAddress(); SparseAnnotations annotations = DefaultAnnotations.builder() .set("ipaddress", ipAddress).build(); DeviceDescription deviceDescription = new DefaultDeviceDescription( uri, Device.Type.CONTROLLER, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, cid, annotations); providerService.deviceConnected(deviceId, deviceDescription); }
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) .set(AnnotationKeys.PROTOCOL, REST.toUpperCase()) .build(); DeviceDescription deviceDescription = new DefaultDeviceDescription( deviceId.uri(), Device.Type.SWITCH, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, cid, annotations); nodeId.setActive(true); providerService.deviceConnected(deviceId, deviceDescription); addedDevices.add(deviceId); }
ChassisId cid = new ChassisId();
@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); }
@Override public void routerAdded(OspfRouter ospfRouter) { String routerId = ospfRouter.routerIp().toString(); log.info("Added device {}", routerId); DeviceId deviceId = DeviceId.deviceId(OspfRouterId.uri(ospfRouter.routerIp())); Device.Type deviceType = Device.Type.ROUTER; //If our routerType is Dr or Bdr type is PSEUDO if (ospfRouter.isDr()) { deviceType = Device.Type.ROUTER; } else { deviceType = Device.Type.VIRTUAL; } //deviceId = DeviceId.deviceId(routerDetails); ChassisId cId = new ChassisId(); DefaultAnnotations.Builder newBuilder = DefaultAnnotations.builder(); newBuilder.set(AnnotationKeys.TYPE, "l3"); newBuilder.set("routerId", routerId); DeviceDescription description = new DefaultDeviceDescription(OspfRouterId.uri(ospfRouter.routerIp()), deviceType, UNKNOWN, UNKNOWN, UNKNOWN, UNKNOWN, cId, newBuilder.build()); deviceProviderService.deviceConnected(deviceId, description); }
ChassisId cId = new ChassisId(dpid.value());