Search in sources :

Example 36 with ChassisId

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);
}
Also used : ChassisId(org.onlab.packet.ChassisId) DefaultDevice(org.onosproject.net.DefaultDevice) DeviceService(org.onosproject.net.device.DeviceService) Before(org.junit.Before)

Example 37 with ChassisId

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);
}
Also used : ProviderId(org.onosproject.net.provider.ProviderId) DeviceDescription(org.onosproject.net.device.DeviceDescription) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) Type(org.onosproject.net.Device.Type) ChassisId(org.onlab.packet.ChassisId) DefaultAnnotations(org.onosproject.net.DefaultAnnotations) DefaultDevice(org.onosproject.net.DefaultDevice)

Example 38 with ChassisId

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()));
}
Also used : Type(org.onosproject.net.Device.Type) ChassisId(org.onlab.packet.ChassisId) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) URI(java.net.URI)

Example 39 with ChassisId

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());
}
Also used : ProviderId(org.onosproject.net.provider.ProviderId) DeviceDescription(org.onosproject.net.device.DeviceDescription) Type(org.onosproject.net.Device.Type) ChassisId(org.onlab.packet.ChassisId) DefaultAnnotations(org.onosproject.net.DefaultAnnotations) DefaultDevice(org.onosproject.net.DefaultDevice)

Example 40 with ChassisId

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));
}
Also used : DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) DeviceDescription(org.onosproject.net.device.DeviceDescription) ChassisId(org.onlab.packet.ChassisId) InputStreamReader(java.io.InputStreamReader) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) HierarchicalConfiguration(org.apache.commons.configuration.HierarchicalConfiguration) Test(org.junit.Test)

Aggregations

ChassisId (org.onlab.packet.ChassisId)48 DefaultDeviceDescription (org.onosproject.net.device.DefaultDeviceDescription)32 DeviceId (org.onosproject.net.DeviceId)24 Device (org.onosproject.net.Device)19 DefaultDevice (org.onosproject.net.DefaultDevice)13 DeviceDescription (org.onosproject.net.device.DeviceDescription)12 DefaultAnnotations (org.onosproject.net.DefaultAnnotations)11 DeviceService (org.onosproject.net.device.DeviceService)11 Test (org.junit.Test)10 SparseAnnotations (org.onosproject.net.SparseAnnotations)10 NetconfException (org.onosproject.netconf.NetconfException)10 NetconfSession (org.onosproject.netconf.NetconfSession)10 XMLConfiguration (org.apache.commons.configuration.XMLConfiguration)6 Type (org.onosproject.net.Device.Type)6 ProviderId (org.onosproject.net.provider.ProviderId)6 JsonNode (com.fasterxml.jackson.databind.JsonNode)5 ArrayList (java.util.ArrayList)5 NetconfDevice (org.onosproject.netconf.NetconfDevice)5 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 IOException (java.io.IOException)4