Search in sources :

Example 26 with DefaultDeviceDescription

use of org.onosproject.net.device.DefaultDeviceDescription in project onos by opennetworkinglab.

the class LispDeviceProvider method connectDevice.

/**
 * Adds a LISP router into device store.
 */
private void connectDevice(LispRouterId routerId) {
    DeviceId deviceId = getDeviceId(routerId.id().toString());
    Preconditions.checkNotNull(deviceId, IS_NULL_MSG);
    // formulate LISP router object
    ChassisId cid = new ChassisId();
    String ipAddress = routerId.id().toString();
    SparseAnnotations annotations = DefaultAnnotations.builder().set(IPADDRESS, ipAddress).set(AnnotationKeys.PROTOCOL, SCHEME_NAME.toUpperCase()).build();
    DeviceDescription deviceDescription = new DefaultDeviceDescription(deviceId.uri(), Device.Type.ROUTER, MANUFACTURER, HARDWARE_VERSION, SOFTWARE_VERSION, SERIAL_NUMBER, cid, false, annotations);
    if (deviceService.getDevice(deviceId) == null) {
        providerService.deviceConnected(deviceId, deviceDescription);
    }
    checkAndUpdateDevice(deviceId, deviceDescription);
}
Also used : SparseAnnotations(org.onosproject.net.SparseAnnotations) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) DeviceDescription(org.onosproject.net.device.DeviceDescription) ChassisId(org.onlab.packet.ChassisId) DeviceId(org.onosproject.net.DeviceId) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription)

Example 27 with DefaultDeviceDescription

use of org.onosproject.net.device.DefaultDeviceDescription in project onos by opennetworkinglab.

the class DeviceManagerTest method connectDevice.

private void connectDevice(DeviceId deviceId, String swVersion) {
    DeviceDescription description = new DefaultDeviceDescription(deviceId.uri(), SWITCH, MFR, HW, swVersion, SN, CID);
    providerService.deviceConnected(deviceId, description);
    assertNotNull("device should be found", service.getDevice(DID1));
}
Also used : DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) DeviceDescription(org.onosproject.net.device.DeviceDescription) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription)

Example 28 with DefaultDeviceDescription

use of org.onosproject.net.device.DefaultDeviceDescription in project onos by opennetworkinglab.

the class CienaWaveserverAiDeviceDescription method discoverDeviceDetails.

@Override
public DeviceDescription discoverDeviceDetails() {
    log.debug("Adding description for Waveserver Ai device");
    NetconfSession session = getNetconfSession();
    Device device = getDevice(handler().data().deviceId());
    try {
        XPath xp = XPathFactory.newInstance().newXPath();
        Node node = TEMPLATE_MANAGER.doRequest(session, "discoverDeviceDetails");
        String chassisId = xp.evaluate("waveserver-chassis/mac-addresses/chassis/base/text()", node);
        chassisId = chassisId.replace(":", "");
        SparseAnnotations annotationDevice = DefaultAnnotations.builder().set("name", xp.evaluate("waveserver-system/host-name/current-host-name/text()", node)).build();
        return new DefaultDeviceDescription(device.id().uri(), Device.Type.OTN, "Ciena", "WaverserverAi", xp.evaluate("waveserver-software/status/active-version/text()", node), xp.evaluate("waveserver-chassis/identification/serial-number/text()", node), new ChassisId(Long.valueOf(chassisId, 16)), (SparseAnnotations) annotationDevice);
    } catch (NetconfException | XPathExpressionException e) {
        log.error("Unable to retrieve device information for device {}, {}", device.chassisId(), e);
    }
    return new DefaultDeviceDescription(device.id().uri(), Device.Type.OTN, "Ciena", "WaverserverAi", "unknown", "unknown", device.chassisId());
}
Also used : NetconfSession(org.onosproject.netconf.NetconfSession) XPath(javax.xml.xpath.XPath) SparseAnnotations(org.onosproject.net.SparseAnnotations) ChassisId(org.onlab.packet.ChassisId) NetconfException(org.onosproject.netconf.NetconfException) Device(org.onosproject.net.Device) NetconfDevice(org.onosproject.netconf.NetconfDevice) XPathExpressionException(javax.xml.xpath.XPathExpressionException) Node(org.w3c.dom.Node) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription)

Example 29 with DefaultDeviceDescription

use of org.onosproject.net.device.DefaultDeviceDescription in project onos by opennetworkinglab.

the class CienaWaveserverAiDeviceDescriptionTest method testDiscoverDeviceDetails.

@Test
public void testDiscoverDeviceDetails() {
    XPath xp = XPathFactory.newInstance().newXPath();
    SparseAnnotations expectAnnotation = DefaultAnnotations.builder().set("hostname", "hostnameWaveServer").build();
    DefaultDeviceDescription expectResult = new DefaultDeviceDescription(mockDeviceId.uri(), Device.Type.OTN, "Ciena", "WaverserverAi", "waveserver-1.1.0.302", "M000", new ChassisId(0L), expectAnnotation);
    try {
        Node node = doRequest("/response/discoverDeviceDetails.xml", "/rpc-reply/data");
        SparseAnnotations annotationDevice = DefaultAnnotations.builder().set("hostname", xp.evaluate("waveserver-system/host-name/current-host-name/text()", node)).build();
        DefaultDeviceDescription result = new DefaultDeviceDescription(mockDeviceId.uri(), Device.Type.OTN, "Ciena", "WaverserverAi", xp.evaluate("waveserver-software/status/active-version/text()", node), xp.evaluate("waveserver-chassis/identification/serial-number/text()", node), new ChassisId(0L), annotationDevice);
        assertEquals(expectResult, result);
    } catch (XPathExpressionException e) {
        e.printStackTrace();
    }
}
Also used : XPath(javax.xml.xpath.XPath) SparseAnnotations(org.onosproject.net.SparseAnnotations) ChassisId(org.onlab.packet.ChassisId) XPathExpressionException(javax.xml.xpath.XPathExpressionException) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) Node(org.w3c.dom.Node) Test(org.junit.Test)

Example 30 with DefaultDeviceDescription

use of org.onosproject.net.device.DefaultDeviceDescription in project onos by opennetworkinglab.

the class CiscoIosDeviceDescription method discoverDeviceDetails.

@Override
public DeviceDescription discoverDeviceDetails() {
    NetconfController controller = checkNotNull(handler().get(NetconfController.class));
    NetconfSession session = controller.getDevicesMap().get(handler().data().deviceId()).getSession();
    try {
        version = session.get(showVersionRequestBuilder());
    } catch (NetconfException e) {
        throw new IllegalStateException(new NetconfException("Failed to retrieve version info.", e));
    }
    String[] details = TextBlockParserCisco.parseCiscoIosDeviceDetails(version);
    DeviceService deviceService = checkNotNull(handler().get(DeviceService.class));
    DeviceId deviceId = handler().data().deviceId();
    Device device = deviceService.getDevice(deviceId);
    return new DefaultDeviceDescription(device.id().uri(), Device.Type.SWITCH, details[0], details[1], details[2], details[3], device.chassisId());
}
Also used : NetconfSession(org.onosproject.netconf.NetconfSession) NetconfException(org.onosproject.netconf.NetconfException) DeviceId(org.onosproject.net.DeviceId) Device(org.onosproject.net.Device) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription) DeviceService(org.onosproject.net.device.DeviceService) NetconfController(org.onosproject.netconf.NetconfController)

Aggregations

DefaultDeviceDescription (org.onosproject.net.device.DefaultDeviceDescription)52 ChassisId (org.onlab.packet.ChassisId)33 DeviceDescription (org.onosproject.net.device.DeviceDescription)26 DeviceId (org.onosproject.net.DeviceId)24 Device (org.onosproject.net.Device)20 SparseAnnotations (org.onosproject.net.SparseAnnotations)14 DeviceService (org.onosproject.net.device.DeviceService)11 NetconfException (org.onosproject.netconf.NetconfException)11 NetconfSession (org.onosproject.netconf.NetconfSession)11 Test (org.junit.Test)9 DefaultAnnotations (org.onosproject.net.DefaultAnnotations)8 XMLConfiguration (org.apache.commons.configuration.XMLConfiguration)6 DeviceDescriptionDiscovery (org.onosproject.net.device.DeviceDescriptionDiscovery)6 DeviceEvent (org.onosproject.net.device.DeviceEvent)6 HierarchicalConfiguration (org.apache.commons.configuration.HierarchicalConfiguration)5 NetconfDevice (org.onosproject.netconf.NetconfDevice)5 List (java.util.List)4 BiFunction (java.util.function.BiFunction)4 Function (java.util.function.Function)4 XPath (javax.xml.xpath.XPath)4