Search in sources :

Example 26 with ChassisId

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

Example 27 with ChassisId

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();
}
Also used : ChassisId(org.onlab.packet.ChassisId) EqualsTester(com.google.common.testing.EqualsTester) Test(org.junit.Test)

Example 28 with ChassisId

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());
}
Also used : ChassisId(org.onlab.packet.ChassisId) Test(org.junit.Test)

Example 29 with ChassisId

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;
    }
}
Also used : SparseAnnotations(org.onosproject.net.SparseAnnotations) ChassisId(org.onlab.packet.ChassisId) DeviceId(org.onosproject.net.DeviceId) Device(org.onosproject.net.Device) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) DeviceService(org.onosproject.net.device.DeviceService) JsonNode(com.fasterxml.jackson.databind.JsonNode)

Example 30 with ChassisId

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

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