use of org.onlab.packet.ChassisId in project onos by opennetworkinglab.
the class TopologySimulator method createDevice.
/**
* Creates simulated device.
*
* @param id device identifier
* @param chassisId chassis identifier number
* @param type device type
* @param hw hardware revision
* @param sw software revision
* @param portCount number of device ports
*/
public void createDevice(DeviceId id, int chassisId, Device.Type type, String hw, String sw, int portCount) {
DeviceDescription desc = new DefaultDeviceDescription(id.uri(), type, "ONF", hw, sw, "1234", new ChassisId(chassisId), DefaultAnnotations.builder().set(AnnotationKeys.NAME, "Switch " + chassisId).build());
deviceIds.add(id);
mastershipAdminService.setRoleSync(localNode, id, MASTER);
deviceProviderService.deviceConnected(id, desc);
deviceProviderService.updatePorts(id, buildPorts(portCount));
}
use of org.onlab.packet.ChassisId in project onos by opennetworkinglab.
the class DefaultPortTest method testEquality.
@Test
public void testEquality() {
Device device = new DefaultDevice(PID, DID1, SWITCH, "m", "h", "s", "n", new ChassisId());
Port p1 = new DefaultPort(device, portNumber(1), true, COPPER, SP1);
Port p2 = new DefaultPort(device, portNumber(1), true, COPPER, SP1);
Port p3 = new DefaultPort(device, portNumber(2), true, FIBER, SP1);
Port p4 = new DefaultPort(device, portNumber(2), true, FIBER, SP1);
Port p5 = new DefaultPort(device, portNumber(1), false);
new EqualsTester().addEqualityGroup(p1, p2).addEqualityGroup(p3, p4).addEqualityGroup(p5).testEquals();
}
use of org.onlab.packet.ChassisId in project onos by opennetworkinglab.
the class DefaultPortTest method basics.
@Test
public void basics() {
Device device = new DefaultDevice(PID, DID1, SWITCH, "m", "h", "s", "n", new ChassisId());
Port port = new DefaultPort(device, portNumber(1), true, FIBER, SP1);
assertEquals("incorrect element", device, port.element());
assertEquals("incorrect number", portNumber(1), port.number());
assertEquals("incorrect state", true, port.isEnabled());
assertEquals("incorrect speed", SP1, port.portSpeed());
assertEquals("incorrect type", FIBER, port.type());
}
use of org.onlab.packet.ChassisId in project onos by opennetworkinglab.
the class DeviceDescriptionDiscoveryAristaImpl method discoverDeviceDetails.
@Override
public DeviceDescription discoverDeviceDetails() {
try {
Optional<JsonNode> result = AristaUtils.retrieveCommandResult(handler(), SHOW_VERSION);
if (!result.isPresent()) {
return null;
}
JsonNode jsonNode = result.get().get(AristaUtils.RESULT_START_INDEX);
String hwVer = jsonNode.get(MODEL_NAME).asText(UNKNOWN);
String swVer = jsonNode.get(SW_VERSION).asText(UNKNOWN);
String serialNum = jsonNode.get(SERIAL_NUMBER).asText(UNKNOWN);
String systemMacAddress = jsonNode.get(SYSTEM_MAC_ADDRESS).asText("").replace(":", "");
DeviceId deviceId = checkNotNull(handler().data().deviceId());
DeviceService deviceService = checkNotNull(handler().get(DeviceService.class));
Device device = deviceService.getDevice(deviceId);
ChassisId chassisId = systemMacAddress.isEmpty() ? new ChassisId() : new ChassisId(systemMacAddress);
log.debug("systemMacAddress: {}", systemMacAddress);
SparseAnnotations annotations = device == null ? DefaultAnnotations.builder().build() : (SparseAnnotations) device.annotations();
return new DefaultDeviceDescription(deviceId.uri(), Device.Type.SWITCH, MANUFACTURER, hwVer, swVer, serialNum, chassisId, annotations);
} catch (Exception e) {
log.error("Exception occurred because of {}, trace: {}", e, e.getStackTrace());
return null;
}
}
use of org.onlab.packet.ChassisId in project onos by opennetworkinglab.
the class TapiDeviceDescriptionDiscovery method discoverDeviceDetails.
@Override
public DeviceDescription discoverDeviceDetails() {
log.debug("Getting device description");
DeviceService deviceService = checkNotNull(handler().get(DeviceService.class));
DeviceId deviceId = handler().data().deviceId();
Device device = deviceService.getDevice(deviceId);
if (device == null) {
// TODO need to obtain from the device.
return new DefaultDeviceDescription(deviceId.uri(), Device.Type.OLS, "Tapi", "0", "2.1", "Unknown", new ChassisId(), DefaultAnnotations.builder().set("protocol", "REST").build());
} else {
return new DefaultDeviceDescription(device.id().uri(), Device.Type.OLS, device.manufacturer(), device.hwVersion(), device.swVersion(), device.serialNumber(), device.chassisId());
}
}
Aggregations