use of org.onlab.packet.ChassisId in project onos by opennetworkinglab.
the class JuniperUtilsTest method testDeviceDescriptionParsedFromJunos19.
@Test
public void testDeviceDescriptionParsedFromJunos19() throws IOException {
HierarchicalConfiguration getSystemInfoResp = XmlConfigParser.loadXml(getClass().getResourceAsStream("/Junos_get-system-information_response_19.2.xml"));
String chassisText = CharStreams.toString(new InputStreamReader(getClass().getResourceAsStream("/Junos_get-chassis-mac-addresses_response_19.2.xml")));
DeviceDescription expected = new DefaultDeviceDescription(URI.create(DEVICE_ID), ROUTER, "JUNIPER", "acx6360-or", "junos 19.2I-20190228_dev_common.0.2316", "DX004", new ChassisId("f4b52f1f81c0"));
assertEquals(expected, JuniperUtils.parseJuniperDescription(deviceId, getSystemInfoResp, chassisText));
}
use of org.onlab.packet.ChassisId in project onos by opennetworkinglab.
the class PolatisDeviceDescription method parseProductInformation.
private DeviceDescription parseProductInformation() {
DeviceService devsvc = checkNotNull(handler().get(DeviceService.class));
DeviceId devID = handler().data().deviceId();
String reply = netconfGet(handler(), getProdInfoFilter());
subscribe(handler());
HierarchicalConfiguration cfg = configAt(reply, KEY_DATA_PRODINF);
String hw = cfg.getString(KEY_HWVERSION);
String numInputPorts = "0";
String numOutputPorts = "0";
if (!hw.equals("")) {
Pattern patternSize = Pattern.compile("\\d+x[\\dC]+");
Matcher matcher = patternSize.matcher(hw);
if (matcher.find()) {
String switchSize = matcher.group();
log.debug("Got switch size: " + switchSize);
Pattern patternNumber = Pattern.compile("[\\dC]+");
matcher = patternNumber.matcher(switchSize);
if (matcher.find()) {
numInputPorts = matcher.group();
log.debug("numInputPorts=" + numInputPorts);
if (matcher.find()) {
if (!matcher.group().equals("CC")) {
numOutputPorts = matcher.group();
}
}
log.debug("numOutputPorts=" + numOutputPorts);
}
}
} else {
log.warn("Unable to determine type of Polatis switch " + devID.toString());
}
DefaultAnnotations annotations = DefaultAnnotations.builder().set(KEY_INPUTPORTS, numInputPorts).set(KEY_OUTPUTPORTS, numOutputPorts).build();
return new DefaultDeviceDescription(devID.uri(), FIBER_SWITCH, cfg.getString(KEY_MANUFACTURER), cfg.getString(KEY_HWVERSION), cfg.getString(KEY_SWVERSION), cfg.getString(KEY_SERIALNUMBER), new ChassisId(cfg.getString(KEY_SERIALNUMBER)), true, annotations);
}
use of org.onlab.packet.ChassisId in project onos by opennetworkinglab.
the class NokiaOpenConfigDeviceDiscovery method discoverDeviceDetails.
@Override
public DeviceDescription discoverDeviceDetails() {
DeviceId did = data().deviceId();
NetconfSession ns = getNetconfSessionAndLogin(did, USER_NAME, PASSWORD);
if (ns == null) {
log.error("DiscoverDeviceDetails called with null session for {}", did);
return null;
}
log.info("Discovering device details {}", handler().data().deviceId());
String hwVersion = "1830", swVersion = "OpenAgent";
try {
String reply = ns.requestSync(buildGetSystemSoftwareRpc());
XMLConfiguration cfg = (XMLConfiguration) XmlConfigParser.loadXmlString(getDataOfRpcReply(reply));
hwVersion = cfg.getString("components.component.state.description");
swVersion = cfg.getString("components.component.state.version");
} catch (NetconfException e) {
log.error("Error discovering device details on {}", data().deviceId(), e);
}
return new DefaultDeviceDescription(handler().data().deviceId().uri(), Device.Type.ROADM_OTN, "NOKIA", hwVersion, swVersion, "", new ChassisId("1"));
}
use of org.onlab.packet.ChassisId in project onos by opennetworkinglab.
the class SoamManagerTest method setup.
@Before
public void setup() throws CfmConfigException, SoamConfigException {
soamManager = new SoamManager();
TestUtils.setField(soamManager, "coreService", new TestCoreService());
TestUtils.setField(soamManager, "cfmMepService", mepService);
TestUtils.setField(soamManager, "deviceService", deviceService);
injectEventDispatcher(soamManager, new TestEventDispatcher());
soamService = soamManager;
soamManager.activate();
DelayMeasurementEntry dmEntry1 = DefaultDelayMeasurementEntry.builder(DMID101, DelayMeasurementCreate.DmType.DM1DMTX, DelayMeasurementCreate.Version.Y17312011, MepId.valueOf((short) 11), Mep.Priority.PRIO5).build();
DelayMeasurementEntry dmEntry2 = DefaultDelayMeasurementEntry.builder(DMID102, DelayMeasurementCreate.DmType.DM1DMTX, DelayMeasurementCreate.Version.Y17312011, MepId.valueOf((short) 11), Mep.Priority.PRIO6).build();
mep1 = DefaultMepEntry.builder(MEPID1, DEVICE_ID1, PortNumber.P0, Mep.MepDirection.UP_MEP, MDNAME1, MANAME1).addToDelayMeasurementList(dmEntry1).addToDelayMeasurementList(dmEntry2).buildEntry();
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());
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 CfmMepManagerTest method testCreateMepBehaviorNotSupported.
@Test
public void testCreateMepBehaviorNotSupported() throws CfmConfigException {
final DeviceId deviceId3 = DeviceId.deviceId("netconf:3.2.3.4:830");
Map<Class<? extends Behaviour>, Class<? extends Behaviour>> behaviours = new HashMap<>();
behaviours.put(DeviceDescriptionDiscovery.class, TestDeviceDiscoveryBehavior.class);
Driver testDriver3 = new DefaultDriver(TEST_DRIVER_3, new ArrayList<Driver>(), TEST_MFR, TEST_HW_VERSION, TEST_SW_3, behaviours, new HashMap<>());
Device device3 = new DefaultDevice(ProviderId.NONE, deviceId3, Device.Type.SWITCH, TEST_MFR, TEST_HW_VERSION, TEST_SW_3, TEST_SN, new ChassisId(2), DefaultAnnotations.builder().set(AnnotationKeys.DRIVER, TEST_DRIVER_3).build());
expect(mdService.getMaintenanceAssociation(MDNAME1, MANAME1)).andReturn(Optional.ofNullable(ma1)).anyTimes();
replay(mdService);
expect(deviceService.getDevice(deviceId3)).andReturn(device3).anyTimes();
replay(deviceService);
expect(driverService.getDriver(deviceId3)).andReturn(testDriver3).anyTimes();
replay(driverService);
MepId mepId3 = MepId.valueOf((short) 3);
Mep mep3 = DefaultMep.builder(mepId3, deviceId3, PortNumber.portNumber(1), Mep.MepDirection.UP_MEP, MDNAME1, MANAME1).build();
try {
mepManager.createMep(MDNAME1, MANAME1, mep3);
fail("Expecting CfmConfigException because driver does not support behavior");
} catch (CfmConfigException e) {
assertEquals("Device netconf:3.2.3.4:830 does not support " + "CfmMepProgrammable behaviour.", e.getMessage());
}
}
Aggregations