Search in sources :

Example 46 with ChassisId

use of org.onlab.packet.ChassisId in project onos by opennetworkinglab.

the class CfmMepManagerTest method setup.

@Before
public void setup() throws CfmConfigException {
    mepManager = new CfmMepManager();
    mepStore = new DistributedMepStore();
    storageService = new MockStorageService();
    ma1 = DefaultMaintenanceAssociation.builder(MANAME1, MDNAME1.getNameLength()).build();
    ma2 = DefaultMaintenanceAssociation.builder(MANAME2, MDNAME2.getNameLength()).build();
    TestUtils.setField(mepStore, "storageService", storageService);
    ((DistributedMepStore) mepStore).activate();
    TestUtils.setField(mepManager, "coreService", new TestCoreService());
    TestUtils.setField(mepManager, "deviceService", deviceService);
    TestUtils.setField(mepManager, "cfmMdService", mdService);
    TestUtils.setField(mepManager, "mepStore", mepStore);
    injectEventDispatcher(mepManager, new TestEventDispatcher());
    mepService = mepManager;
    mepManager.activate();
    mep1 = DefaultMep.builder(MEPID1, DEVICE_ID1, PortNumber.P0, Mep.MepDirection.UP_MEP, MDNAME1, MANAME1).build();
    mepStore.createUpdateMep(new MepKeyId(MDNAME1, MANAME1, MEPID1), mep1);
    mep11 = DefaultMep.builder(MEPID11, DEVICE_ID1, PortNumber.P0, Mep.MepDirection.UP_MEP, MDNAME1, MANAME1).build();
    mepStore.createUpdateMep(new MepKeyId(MDNAME1, MANAME1, MEPID11), mep11);
    mep12 = DefaultMep.builder(MEPID12, DEVICE_ID1, PortNumber.P0, Mep.MepDirection.UP_MEP, MDNAME2, MANAME2).build();
    mepStore.createUpdateMep(new MepKeyId(MDNAME2, MANAME2, MEPID12), mep12);
    mep2 = DefaultMep.builder(MEPID2, DEVICE_ID2, PortNumber.portNumber(2), Mep.MepDirection.UP_MEP, MDNAME1, MANAME1).build();
    mepStore.createUpdateMep(new MepKeyId(MDNAME1, MANAME1, MEPID2), mep2);
    mep21 = DefaultMep.builder(MEPID21, DEVICE_ID2, PortNumber.portNumber(2), Mep.MepDirection.UP_MEP, MDNAME1, MANAME1).build();
    mepStore.createUpdateMep(new MepKeyId(MDNAME1, MANAME1, MEPID21), mep21);
    mep22 = DefaultMep.builder(MEPID22, DEVICE_ID2, PortNumber.portNumber(2), Mep.MepDirection.UP_MEP, MDNAME2, MANAME2).build();
    mepStore.createUpdateMep(new MepKeyId(MDNAME2, MANAME2, MEPID22), mep22);
    device1 = new DefaultDevice(ProviderId.NONE, DEVICE_ID1, Device.Type.SWITCH, TEST_MFR, TEST_HW_VERSION, TEST_SW_VERSION, TEST_SN, new ChassisId(1), DefaultAnnotations.builder().set(AnnotationKeys.DRIVER, TEST_DRIVER).build());
    device2 = new DefaultDevice(ProviderId.NONE, DEVICE_ID2, Device.Type.SWITCH, TEST_MFR, TEST_HW_VERSION, TEST_SW_VERSION, TEST_SN, new ChassisId(2), DefaultAnnotations.builder().set(AnnotationKeys.DRIVER, TEST_DRIVER).build());
    AbstractProjectableModel.setDriverService(null, driverService);
    Map<Class<? extends Behaviour>, Class<? extends Behaviour>> behaviours = new HashMap<>();
    behaviours.put(DeviceDescriptionDiscovery.class, TestDeviceDiscoveryBehavior.class);
    behaviours.put(CfmMepProgrammable.class, TestCfmMepProgrammable.class);
    behaviours.put(SoamDmProgrammable.class, TestSoamDmProgrammable.class);
    testDriver = new DefaultDriver(TEST_DRIVER, new ArrayList<Driver>(), TEST_MFR, TEST_HW_VERSION, TEST_SW_VERSION, behaviours, new HashMap<>());
}
Also used : TestEventDispatcher(org.onosproject.common.event.impl.TestEventDispatcher) ChassisId(org.onlab.packet.ChassisId) Behaviour(org.onosproject.net.driver.Behaviour) HashMap(java.util.HashMap) DefaultDevice(org.onosproject.net.DefaultDevice) ArrayList(java.util.ArrayList) DefaultDriver(org.onosproject.net.driver.DefaultDriver) MepKeyId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepKeyId) Before(org.junit.Before)

Example 47 with ChassisId

use of org.onlab.packet.ChassisId in project onos by opennetworkinglab.

the class DeviceCodec method decode.

/**
 * {@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);
}
Also used : ProviderId(org.onosproject.net.provider.ProviderId) Type(org.onosproject.net.Device.Type) ChassisId(org.onlab.packet.ChassisId) DefaultAnnotations(org.onosproject.net.DefaultAnnotations) Annotations(org.onosproject.net.Annotations) DeviceId(org.onosproject.net.DeviceId) DefaultDevice(org.onosproject.net.DefaultDevice)

Example 48 with ChassisId

use of org.onlab.packet.ChassisId in project onos by opennetworkinglab.

the class PolatisDeviceDescription method discoverDeviceDetails.

/**
 * Discovers device details, for Polatis Snmp device by getting the system
 * information.
 *
 * @return device description
 */
@Override
public DeviceDescription discoverDeviceDetails() {
    DeviceService deviceService = checkNotNull(handler().get(DeviceService.class));
    DeviceId deviceId = handler().data().deviceId();
    Device device = deviceService.getDevice(deviceId);
    if (device == null) {
        return new DefaultDeviceDescription(deviceId.uri(), Device.Type.FIBER_SWITCH, DEFAULT_MANUFACTURER, DEFAULT_DESCRIPTION_DATA, DEFAULT_DESCRIPTION_DATA, DEFAULT_DESCRIPTION_DATA, new ChassisId());
    }
    String hardwareVersion = DEFAULT_DESCRIPTION_DATA;
    try {
        hardwareVersion = hardwareVersion();
    } catch (IOException e) {
        log.error("Error reading hardware version for device {} exception ", deviceId, e);
    }
    String softwareVersion = DEFAULT_DESCRIPTION_DATA;
    try {
        softwareVersion = softwareVersion();
    } catch (IOException e) {
        log.error("Error reading software version for device {} exception {}", deviceId, e);
    }
    String serialNumber = DEFAULT_DESCRIPTION_DATA;
    try {
        serialNumber = serialNumber();
    } catch (IOException e) {
        log.error("Error reading serial number for device {} exception {}", deviceId, e);
    }
    return new DefaultDeviceDescription(deviceId.uri(), Device.Type.FIBER_SWITCH, DEFAULT_MANUFACTURER, hardwareVersion, softwareVersion, serialNumber, device.chassisId(), (SparseAnnotations) device.annotations());
}
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) IOException(java.io.IOException)

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