use of org.onlab.packet.ChassisId 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);
}
use of org.onlab.packet.ChassisId 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());
}
use of org.onlab.packet.ChassisId 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();
}
}
use of org.onlab.packet.ChassisId 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.onlab.packet.ChassisId in project onos by opennetworkinglab.
the class LumentumWaveReadyDiscovery method discoverDeviceDetails.
@Override
public DeviceDescription discoverDeviceDetails() {
DeviceId deviceId = handler().data().deviceId();
Tl1Controller ctrl = checkNotNull(handler().get(Tl1Controller.class));
// Something reasonable, unavailable by default
DeviceDescription defaultDescription = new DefaultDeviceDescription(deviceId.uri(), Device.Type.OTN, LUMENTUM, WAVEREADY, SWVERSION, SERIAL, new ChassisId(), false, DefaultAnnotations.EMPTY);
Optional<Tl1Device> device = ctrl.getDevice(deviceId);
if (!device.isPresent()) {
return defaultDescription;
}
// Login
Tl1Command loginCmd = DefaultTl1Command.builder().withVerb(ACT).withModifier(USER).withAid(device.get().username()).withCtag(100).withParameters(device.get().password()).build();
Future<String> login = ctrl.sendMsg(deviceId, loginCmd);
try {
String loginResponse = login.get(TIMEOUT, TimeUnit.MILLISECONDS);
if (loginResponse.contains("Access denied")) {
log.error("Access denied: {}", loginResponse);
return defaultDescription;
}
} catch (InterruptedException | ExecutionException | TimeoutException e) {
log.error("Login failed", e);
return defaultDescription;
}
// Fetch device description
Tl1Command ddCmd = DefaultTl1Command.builder().withVerb(RTRV).withModifier(NETYPE).withCtag(101).build();
Future<String> dd = ctrl.sendMsg(deviceId, ddCmd);
try {
String ddResponse = dd.get(TIMEOUT, TimeUnit.MILLISECONDS);
return new DefaultDeviceDescription(defaultDescription, true, extractAnnotations(ddResponse));
} catch (InterruptedException | ExecutionException | TimeoutException e) {
log.error("Device description not found", e);
return defaultDescription;
}
}
Aggregations