Search in sources :

Example 11 with SparseAnnotations

use of org.onosproject.net.SparseAnnotations in project onos by opennetworkinglab.

the class GossipDeviceStoreTest method assertAnnotationsEquals.

/**
 * Verifies that Annotations created by merging {@code annotations} is
 * equal to actual Annotations.
 *
 * @param actual Annotations to check
 * @param annotations
 */
private static void assertAnnotationsEquals(Annotations actual, SparseAnnotations... annotations) {
    SparseAnnotations expected = DefaultAnnotations.builder().build();
    for (SparseAnnotations a : annotations) {
        expected = DefaultAnnotations.union(expected, a);
    }
    assertEquals(expected.keys(), actual.keys());
    for (String key : expected.keys()) {
        assertEquals(expected.value(key), actual.value(key));
    }
}
Also used : SparseAnnotations(org.onosproject.net.SparseAnnotations)

Example 12 with SparseAnnotations

use of org.onosproject.net.SparseAnnotations in project onos by opennetworkinglab.

the class LumentumNetconfRoadmDiscovery method discoverDeviceDetails.

@Override
public DeviceDescription discoverDeviceDetails() {
    SparseAnnotations annotations = DefaultAnnotations.builder().build();
    log.debug("Lumentum NETCONF - starting discoverDeviceDetails");
    // Some defaults values
    String vendor = "Lumentum";
    String hwVersion = "not loaded";
    String swVersion = "not loaded";
    String serialNumber = "not loaded";
    String chassisData = "ne=1;chassis=10";
    ChassisId chassisId = null;
    DeviceId deviceId = handler().data().deviceId();
    NetconfSession session = getNetconfSession();
    if (session == null) {
        log.error("Lumentum NETCONF - session not found for {}", deviceId);
        return null;
    }
    // Retrieve system information from ietf-system
    StringBuilder systemRequestBuilder = new StringBuilder();
    systemRequestBuilder.append("<system-state xmlns=\"urn:ietf:params:xml:ns:yang:ietf-system\">");
    systemRequestBuilder.append("</system-state>");
    try {
        String reply = session.get(systemRequestBuilder.toString(), null);
        log.debug("Lumentum NETCONF - session.get reply {}", reply);
        XMLConfiguration xconf = (XMLConfiguration) XmlConfigParser.loadXmlString(reply);
        vendor = xconf.getString("data.system-state.platform.machine", vendor);
        swVersion = xconf.getString("data.system-state.platform.os-version", swVersion);
    } catch (NetconfException e) {
        log.error("Lumentum NETCONF error in session.get with filter <system-state>", e);
    }
    // Retrieve system information
    StringBuilder chassisRequestBuilder = new StringBuilder();
    chassisRequestBuilder.append("<chassis-list xmlns=\"http://www.lumentum.com/lumentum-ote-equipment\">");
    chassisRequestBuilder.append("</chassis-list>");
    try {
        String reply = session.get(chassisRequestBuilder.toString(), null);
        log.debug("Lumentum NETCONF - session.get reply {}", reply);
        XMLConfiguration xconf = (XMLConfiguration) XmlConfigParser.loadXmlString(reply);
        hwVersion = xconf.getString("data.chassis-list.chassis.state.loteq:hardware-rev", hwVersion);
        serialNumber = xconf.getString("data.chassis-list.chassis.state.loteq:serial-no", serialNumber);
        chassisData = xconf.getString("data.chassis-list.chassis.dn", chassisData);
        String[] parts = chassisData.split("chassis=");
        chassisId = new ChassisId(Long.valueOf(parts[1], 10));
    } catch (NetconfException e) {
        log.error("Lumentum NETCONF error in session.get", e);
    }
    // Upon connection of a new devices all pre-configured connections are removed
    // TODO consider a way to keep "external" FlowRules
    rpcRemoveAllConnections("1");
    rpcRemoveAllConnections("2");
    log.info("Lumentum ROADM20 - discovered details:");
    log.info("TYPE      {}", Device.Type.ROADM);
    log.info("VENDOR    {}", vendor);
    log.info("HWVERSION {}", hwVersion);
    log.info("SWVERSION {}", swVersion);
    log.info("SERIAL    {}", serialNumber);
    log.info("CHASSISID {}", chassisId);
    // Return the Device Description
    return new DefaultDeviceDescription(deviceId.uri(), Device.Type.ROADM, vendor, hwVersion, swVersion, serialNumber, chassisId, annotations);
}
Also used : SparseAnnotations(org.onosproject.net.SparseAnnotations) NetconfSession(org.onosproject.netconf.NetconfSession) ChassisId(org.onlab.packet.ChassisId) XMLConfiguration(org.apache.commons.configuration.XMLConfiguration) NetconfException(org.onosproject.netconf.NetconfException) DeviceId(org.onosproject.net.DeviceId) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription)

Example 13 with SparseAnnotations

use of org.onosproject.net.SparseAnnotations in project onos by opennetworkinglab.

the class LumentumRoadmDiscovery method getPorts.

private List<PortDescription> getPorts() {
    try {
        snmp = new LumentumSnmpDevice(handler().data().deviceId());
    } catch (IOException e) {
        log.error("Failed to connect to device: ", e);
        return Collections.emptyList();
    }
    List<PortDescription> ports = Lists.newLinkedList();
    OID[] oids = { new OID(CTRL_PORT_STATE + "1"), new OID(CTRL_PORT_STATE + "2") };
    for (OID oid : oids) {
        for (TreeEvent event : snmp.get(oid)) {
            if (event != null) {
                VariableBinding[] varBindings = event.getVariableBindings();
                for (VariableBinding varBinding : varBindings) {
                    if (varBinding.getVariable().toInt() == 1) {
                        int portNumber = varBinding.getOid().removeLast();
                        int portDirection = varBinding.getOid().removeLast();
                        SparseAnnotations ann = DefaultAnnotations.builder().set(AnnotationKeys.PORT_NAME, portDirection + "-" + portNumber).build();
                        PortDescription p = omsPortDescription(PortNumber.portNumber(ports.size() + 1L), true, LumentumSnmpDevice.START_CENTER_FREQ, LumentumSnmpDevice.END_CENTER_FREQ, LumentumSnmpDevice.CHANNEL_SPACING.frequency(), ann);
                        ports.add(p);
                    }
                }
            }
        }
    }
    // Create LINE IN and LINE OUT ports as these are not reported through SNMP
    SparseAnnotations annLineIn = DefaultAnnotations.builder().set(AnnotationKeys.PORT_NAME, "LINE IN").build();
    ports.add(omsPortDescription(PortNumber.portNumber(ports.size() + 1L), true, LumentumSnmpDevice.START_CENTER_FREQ, LumentumSnmpDevice.END_CENTER_FREQ, LumentumSnmpDevice.CHANNEL_SPACING.frequency(), annLineIn));
    SparseAnnotations annLineOut = DefaultAnnotations.builder().set(AnnotationKeys.PORT_NAME, "LINE OUT").build();
    ports.add(omsPortDescription(PortNumber.portNumber(ports.size() + 1L), true, LumentumSnmpDevice.START_CENTER_FREQ, LumentumSnmpDevice.END_CENTER_FREQ, LumentumSnmpDevice.CHANNEL_SPACING.frequency(), annLineOut));
    return ports;
}
Also used : TreeEvent(org.snmp4j.util.TreeEvent) SparseAnnotations(org.onosproject.net.SparseAnnotations) OmsPortHelper.omsPortDescription(org.onosproject.net.optical.device.OmsPortHelper.omsPortDescription) PortDescription(org.onosproject.net.device.PortDescription) IOException(java.io.IOException) OID(org.snmp4j.smi.OID) VariableBinding(org.snmp4j.smi.VariableBinding)

Example 14 with SparseAnnotations

use of org.onosproject.net.SparseAnnotations in project onos by opennetworkinglab.

the class XmppDeviceProvider method connectDevice.

private void connectDevice(XmppDeviceId xmppDeviceId) {
    DeviceId deviceId = DeviceId.deviceId(xmppDeviceId.id());
    String ipAddress = controller.getDevice(xmppDeviceId).getIpAddress().getAddress().getHostAddress();
    // Assumption: manufacturer is uniquely identified by domain part of JID
    String manufacturer = xmppDeviceId.getJid().getDomain();
    ChassisId cid = new ChassisId();
    SparseAnnotations annotations = DefaultAnnotations.builder().set(AnnotationKeys.PROTOCOL, XMPP.toUpperCase()).set("IpAddress", ipAddress).build();
    DeviceDescription deviceDescription = new DefaultDeviceDescription(deviceId.uri(), Device.Type.OTHER, manufacturer, HARDWARE_VERSION, SOFTWARE_VERSION, SERIAL_NUMBER, cid, true, annotations);
    if (deviceService.getDevice(deviceId) == null) {
        providerService.deviceConnected(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) XmppDeviceId(org.onosproject.xmpp.core.XmppDeviceId) DeviceId(org.onosproject.net.DeviceId) DefaultDeviceDescription(org.onosproject.net.device.DefaultDeviceDescription)

Example 15 with SparseAnnotations

use of org.onosproject.net.SparseAnnotations in project onos by opennetworkinglab.

the class OvsdbTunnelProviderTest method testTunnelRemoved.

@Test
public void testTunnelRemoved() {
    TunnelEndPoint src = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf("192.168.1.1"));
    TunnelEndPoint dst = IpTunnelEndPoint.ipTunnelPoint(IpAddress.valueOf("192.168.1.3"));
    SparseAnnotations annotations = DefaultAnnotations.builder().set("bandwidth", "1024").build();
    List<Link> links = new ArrayList<Link>();
    links.add(link);
    TunnelDescription tunnel = new DefaultTunnelDescription(TunnelId.valueOf("1234"), src, dst, Tunnel.Type.VXLAN, new GroupId(0), this.provider.id(), TunnelName.tunnelName("tunnel1"), new DefaultPath(this.provider.id(), links, ScalarWeight.toWeight(0.3)), annotations);
    provider.tunnelRemoved(tunnel);
    assertEquals(0, providerService.tunnelSet.size());
}
Also used : SparseAnnotations(org.onosproject.net.SparseAnnotations) TunnelEndPoint(org.onosproject.incubator.net.tunnel.TunnelEndPoint) IpTunnelEndPoint(org.onosproject.incubator.net.tunnel.IpTunnelEndPoint) ArrayList(java.util.ArrayList) DefaultTunnelDescription(org.onosproject.incubator.net.tunnel.DefaultTunnelDescription) TunnelDescription(org.onosproject.incubator.net.tunnel.TunnelDescription) DefaultTunnelDescription(org.onosproject.incubator.net.tunnel.DefaultTunnelDescription) DefaultPath(org.onosproject.net.DefaultPath) Link(org.onosproject.net.Link) DefaultLink(org.onosproject.net.DefaultLink) GroupId(org.onosproject.core.GroupId) Test(org.junit.Test)

Aggregations

SparseAnnotations (org.onosproject.net.SparseAnnotations)30 DefaultDeviceDescription (org.onosproject.net.device.DefaultDeviceDescription)12 ChassisId (org.onlab.packet.ChassisId)10 DeviceId (org.onosproject.net.DeviceId)8 Device (org.onosproject.net.Device)6 Test (org.junit.Test)5 DefaultTunnelDescription (org.onosproject.incubator.net.tunnel.DefaultTunnelDescription)4 TunnelDescription (org.onosproject.incubator.net.tunnel.TunnelDescription)4 DeviceDescription (org.onosproject.net.device.DeviceDescription)4 PortDescription (org.onosproject.net.device.PortDescription)4 NetconfException (org.onosproject.netconf.NetconfException)4 NetconfSession (org.onosproject.netconf.NetconfSession)4 XMLConfiguration (org.apache.commons.configuration.XMLConfiguration)3 GroupId (org.onosproject.core.GroupId)3 IpTunnelEndPoint (org.onosproject.incubator.net.tunnel.IpTunnelEndPoint)3 TunnelEndPoint (org.onosproject.incubator.net.tunnel.TunnelEndPoint)3 TunnelId (org.onosproject.incubator.net.tunnel.TunnelId)3 Link (org.onosproject.net.Link)3 PortNumber (org.onosproject.net.PortNumber)3 NetconfDevice (org.onosproject.netconf.NetconfDevice)3