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<>());
}
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);
}
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());
}
Aggregations