use of org.onlab.packet.ChassisId in project onos by opennetworkinglab.
the class DevicePortStatsCommandTest method setUp.
@Before
public void setUp() {
devicePortStatsCommand = new DevicePortStatsCommand();
id1 = NetTestTools.did("d1");
DefaultDevice d1 = new DefaultDevice(NetTestTools.PID, id1, Device.Type.SWITCH, "test", "1.0", "1.0", "abacab", new ChassisId("c"), DefaultAnnotations.EMPTY);
devices.add(d1);
portStatistics = DefaultPortStatistics.builder().setDurationSec(1).setBytesReceived(10).setBytesSent(20).setDurationNano(30).setPacketsReceived(40).setPacketsSent(50).setPacketsRxDropped(60).setPacketsRxErrors(70).setPacketsTxDropped(80).setPacketsTxErrors(90).setPort(PortNumber.portNumber(81)).setDeviceId(id1).build();
portStatisticsList.add(portStatistics);
deviceService = createMock(DeviceService.class);
expect(deviceService.getPortStatistics(id1)).andReturn(portStatisticsList);
expect(deviceService.getPortDeltaStatistics(id1)).andReturn(portStatisticsList);
replay(deviceService);
}
use of org.onlab.packet.ChassisId in project onos by opennetworkinglab.
the class SimpleDeviceStore method composeDevice.
/**
* Returns a Device, merging description given from multiple Providers.
*
* @param deviceId device identifier
* @param providerDescs Collection of Descriptions from multiple providers
* @return Device instance
*/
private Device composeDevice(DeviceId deviceId, Map<ProviderId, DeviceDescriptions> providerDescs) {
checkArgument(!providerDescs.isEmpty(), "No Device descriptions supplied");
ProviderId primary = pickPrimaryPid(providerDescs);
DeviceDescriptions desc = providerDescs.get(primary);
final DeviceDescription base = desc.getDeviceDesc();
Type type = base.type();
String manufacturer = base.manufacturer();
String hwVersion = base.hwVersion();
String swVersion = base.swVersion();
String serialNumber = base.serialNumber();
ChassisId chassisId = base.chassisId();
DefaultAnnotations annotations = DefaultAnnotations.builder().build();
annotations = merge(annotations, base.annotations());
for (Entry<ProviderId, DeviceDescriptions> e : providerDescs.entrySet()) {
if (e.getKey().equals(primary)) {
continue;
}
// TODO: should keep track of Description timestamp
// and only merge conflicting keys when timestamp is newer
// Currently assuming there will never be a key conflict between
// providers
// annotation merging. not so efficient, should revisit later
annotations = merge(annotations, e.getValue().getDeviceDesc().annotations());
}
return new DefaultDevice(primary, deviceId, type, manufacturer, hwVersion, swVersion, serialNumber, chassisId, annotations);
}
use of org.onlab.packet.ChassisId in project onos by opennetworkinglab.
the class DeviceProtoTranslator method translate.
/**
* Translates gRPC DeviceDescription to {@link DeviceDescriptionProtoOuterClass}.
*
* @param deviceDescription gRPC message
* @return {@link DeviceDescriptionProtoOuterClass}
*/
public static DeviceDescription translate(DeviceDescriptionProto deviceDescription) {
URI uri = URI.create(deviceDescription.getDeviceUri());
Type type = translate(deviceDescription.getType());
String manufacturer = deviceDescription.getManufacturer();
String hwVersion = deviceDescription.getHwVersion();
String swVersion = deviceDescription.getSwVersion();
String serialNumber = deviceDescription.getSerialNumber();
ChassisId chassis = new ChassisId(deviceDescription.getChassisId());
boolean defaultAvailable = deviceDescription.getIsDefaultAvailable();
return new DefaultDeviceDescription(uri, type, manufacturer, hwVersion, swVersion, serialNumber, chassis, defaultAvailable, AnnotationsTranslator.asAnnotations(deviceDescription.getAnnotationsMap()));
}
use of org.onlab.packet.ChassisId in project onos by opennetworkinglab.
the class GossipDeviceStore method composeDevice.
/**
* Returns a Device, merging description given from multiple Providers.
*
* @param deviceId device identifier
* @param providerDescs Collection of Descriptions from multiple providers
* @return Device instance
*/
private Device composeDevice(DeviceId deviceId, Map<ProviderId, DeviceDescriptions> providerDescs) {
checkArgument(!providerDescs.isEmpty(), "No device descriptions supplied");
ProviderId primary = pickPrimaryPid(providerDescs);
DeviceDescriptions desc = providerDescs.get(primary);
final DeviceDescription base = desc.getDeviceDesc().value();
Type type = base.type();
String manufacturer = base.manufacturer();
String hwVersion = base.hwVersion();
String swVersion = base.swVersion();
String serialNumber = base.serialNumber();
ChassisId chassisId = base.chassisId();
DefaultAnnotations.Builder annotations = DefaultAnnotations.builder();
annotations.putAll(base.annotations());
for (Entry<ProviderId, DeviceDescriptions> e : providerDescs.entrySet()) {
if (e.getKey().equals(primary)) {
continue;
}
// Note: should keep track of Description timestamp in the future
// and only merge conflicting keys when timestamp is newer.
// Currently assuming there will never be a key conflict between
// providers
// annotation merging. not so efficient, should revisit later
annotations.putAll(e.getValue().getDeviceDesc().value().annotations());
}
return new DefaultDevice(primary, deviceId, type, manufacturer, hwVersion, swVersion, serialNumber, chassisId, annotations.buildCompressed());
}
use of org.onlab.packet.ChassisId in project onos by opennetworkinglab.
the class JuniperUtilsTest method testDeviceDescriptionParsedFromJunos15.
@Test
public void testDeviceDescriptionParsedFromJunos15() throws IOException {
HierarchicalConfiguration getSystemInfoResp = XmlConfigParser.loadXml(getClass().getResourceAsStream("/Junos_get-system-information_response_15.1.xml"));
String chassisText = CharStreams.toString(new InputStreamReader(getClass().getResourceAsStream("/Junos_get-chassis-mac-addresses_response_15.1.xml")));
DeviceDescription expected = new DefaultDeviceDescription(URI.create(DEVICE_ID), ROUTER, "JUNIPER", "mx240", "junos 15.1R5.5", "JN11AC665AFC", new ChassisId("8418889983c0"));
assertEquals(expected, JuniperUtils.parseJuniperDescription(deviceId, getSystemInfoResp, chassisText));
}
Aggregations