Search in sources :

Example 41 with ChassisId

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

Example 42 with ChassisId

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);
}
Also used : Pattern(java.util.regex.Pattern) ChassisId(org.onlab.packet.ChassisId) DefaultAnnotations(org.onosproject.net.DefaultAnnotations) Matcher(java.util.regex.Matcher) DeviceId(org.onosproject.net.DeviceId) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) DeviceService(org.onosproject.net.device.DeviceService) HierarchicalConfiguration(org.apache.commons.configuration.HierarchicalConfiguration)

Example 43 with ChassisId

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"));
}
Also used : NetconfSession(org.onosproject.netconf.NetconfSession) XMLConfiguration(org.apache.commons.configuration.XMLConfiguration) ChassisId(org.onlab.packet.ChassisId) NetconfException(org.onosproject.netconf.NetconfException) DeviceId(org.onosproject.net.DeviceId) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription)

Example 44 with ChassisId

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<>());
}
Also used : TestEventDispatcher(org.onosproject.common.event.impl.TestEventDispatcher) ChassisId(org.onlab.packet.ChassisId) Behaviour(org.onosproject.net.driver.Behaviour) HashMap(java.util.HashMap) DelayMeasurementEntry(org.onosproject.incubator.net.l2monitoring.soam.delay.DelayMeasurementEntry) DefaultDelayMeasurementEntry(org.onosproject.incubator.net.l2monitoring.soam.delay.DefaultDelayMeasurementEntry) DefaultDevice(org.onosproject.net.DefaultDevice) DefaultDriver(org.onosproject.net.driver.DefaultDriver) ArrayList(java.util.ArrayList) Before(org.junit.Before)

Example 45 with ChassisId

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());
    }
}
Also used : ChassisId(org.onlab.packet.ChassisId) Behaviour(org.onosproject.net.driver.Behaviour) HashMap(java.util.HashMap) DeviceId(org.onosproject.net.DeviceId) DefaultDevice(org.onosproject.net.DefaultDevice) Device(org.onosproject.net.Device) DefaultDevice(org.onosproject.net.DefaultDevice) Driver(org.onosproject.net.driver.Driver) DefaultDriver(org.onosproject.net.driver.DefaultDriver) DefaultDriver(org.onosproject.net.driver.DefaultDriver) DefaultMep(org.onosproject.incubator.net.l2monitoring.cfm.DefaultMep) Mep(org.onosproject.incubator.net.l2monitoring.cfm.Mep) CfmConfigException(org.onosproject.incubator.net.l2monitoring.cfm.service.CfmConfigException) MepId(org.onosproject.incubator.net.l2monitoring.cfm.identifier.MepId) 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