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