use of org.onlab.packet.ChassisId in project onos by opennetworkinglab.
the class RestDeviceProvider method getDesc.
private DeviceDescription getDesc(RestSBDevice restSBDev) {
DeviceId deviceId = restSBDev.deviceId();
Driver driver = getDriver(restSBDev);
if (restSBDev.isProxy()) {
if (driver != null && driver.hasBehaviour(DevicesDiscovery.class)) {
// Creates the driver to communicate with the server
DevicesDiscovery devicesDiscovery = devicesDiscovery(restSBDev, driver);
return devicesDiscovery.deviceDetails(deviceId);
} else {
log.warn("Driver not found for {}", restSBDev);
return null;
}
} else if (driver != null && driver.hasBehaviour(DeviceDescriptionDiscovery.class)) {
DriverHandler h = driverService.createHandler(deviceId);
DeviceDescriptionDiscovery deviceDiscovery = h.behaviour(DeviceDescriptionDiscovery.class);
return deviceDiscovery.discoverDeviceDetails();
}
ChassisId cid = new ChassisId();
String ipAddress = restSBDev.ip().toString();
SparseAnnotations annotations = DefaultAnnotations.builder().set(IPADDRESS, ipAddress).set(AnnotationKeys.PROTOCOL, REST.toUpperCase()).build();
String manufacturer = UNKNOWN;
String hwVersion = UNKNOWN;
String swVersion = UNKNOWN;
String serialNumber = UNKNOWN;
Device device = deviceService.getDevice(deviceId);
if (device != null) {
manufacturer = device.manufacturer();
hwVersion = device.hwVersion();
swVersion = device.swVersion();
serialNumber = device.serialNumber();
}
return new DefaultDeviceDescription(deviceId.uri(), Device.Type.SWITCH, manufacturer, hwVersion, swVersion, serialNumber, cid, annotations);
}
use of org.onlab.packet.ChassisId 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.onlab.packet.ChassisId in project onos by opennetworkinglab.
the class TerminalDeviceDiscovery method discoverDeviceDetails.
/**
* Returns a DeviceDescription with Device info.
*
* @return DeviceDescription or null
*
* //CHECKSTYLE:OFF
* <pre>{@code
* <data>
* <components xmlns="http://openconfig.net/yang/platform">
* <component>
* <state>
* <name>FIRMWARE</name>
* <type>oc-platform-types:OPERATING_SYSTEM</type>
* <description>CTTC METRO-HAUL Emulated OpenConfig TerminalDevice</description>
* <version>0.0.1</version>
* </state>
* </component>
* </components>
* </data>
*}</pre>
* //CHECKSTYLE:ON
*/
@Override
public DeviceDescription discoverDeviceDetails() {
log.info("TerminalDeviceDiscovery::discoverDeviceDetails device {}", did());
boolean defaultAvailable = true;
SparseAnnotations annotations = DefaultAnnotations.builder().build();
// Other option "OTHER", we use ROADM for now
org.onosproject.net.Device.Type type = Device.Type.TERMINAL_DEVICE;
// Some defaults
String vendor = "NOVENDOR";
String hwVersion = "0.2.1";
String swVersion = "0.2.1";
String serialNumber = "0xCAFEBEEF";
String chassisId = "128";
// Get the session,
NetconfSession session = getNetconfSession(did());
if (session != null) {
try {
String reply = session.get(getDeviceDetailsBuilder());
// <rpc-reply> as root node
XMLConfiguration xconf = (XMLConfiguration) XmlConfigParser.loadXmlString(reply);
vendor = xconf.getString("data/components/component/state/mfg-name", vendor);
serialNumber = xconf.getString("data/components/component/state/serial-no", serialNumber);
// Requires OpenConfig >= 2018
swVersion = xconf.getString("data/components/component/state/software-version", swVersion);
hwVersion = xconf.getString("data/components/component/state/hardware-version", hwVersion);
} catch (Exception e) {
throw new IllegalStateException(new NetconfException("Failed to retrieve version info.", e));
}
} else {
log.info("TerminalDeviceDiscovery::discoverDeviceDetails - No netconf session for {}", did());
}
log.info("VENDOR {}", vendor);
log.info("HWVERSION {}", hwVersion);
log.info("SWVERSION {}", swVersion);
log.info("SERIAL {}", serialNumber);
log.info("CHASSISID {}", chassisId);
ChassisId cid = new ChassisId(Long.valueOf(chassisId, 10));
return new DefaultDeviceDescription(did().uri(), type, vendor, hwVersion, swVersion, serialNumber, cid, defaultAvailable, annotations);
}
use of org.onlab.packet.ChassisId in project onos by opennetworkinglab.
the class HostLocationProviderTest method removeHostByDeviceRemove.
@Test
public void removeHostByDeviceRemove() {
provider.modified(CTX_FOR_REMOVE);
testProcessor.process(new TestArpPacketContext(DEV1));
testProcessor.process(new TestNaPacketContext(DEV4));
Device device = new DefaultDevice(ProviderId.NONE, deviceId(DEV1), SWITCH, "m", "h", "s", "n", new ChassisId(0L));
deviceService.listener.event(new DeviceEvent(DEVICE_REMOVED, device));
assertEquals("incorrect remove count", 2, providerService.locationRemoveCount);
device = new DefaultDevice(ProviderId.NONE, deviceId(DEV4), SWITCH, "m", "h", "s", "n", new ChassisId(0L));
deviceService.listener.event(new DeviceEvent(DEVICE_REMOVED, device));
assertEquals("incorrect remove count", 3, providerService.locationRemoveCount);
}
use of org.onlab.packet.ChassisId in project onos by opennetworkinglab.
the class HostLocationProviderTest method removeHostByDeviceOffline.
@Test
public void removeHostByDeviceOffline() {
provider.modified(CTX_FOR_REMOVE);
testProcessor.process(new TestArpPacketContext(DEV1));
testProcessor.process(new TestArpPacketContext(DEV4));
Device device = new DefaultDevice(ProviderId.NONE, deviceId(DEV1), SWITCH, "m", "h", "s", "n", new ChassisId(0L));
deviceService.listener.event(new DeviceEvent(DEVICE_AVAILABILITY_CHANGED, device));
assertEquals("incorrect remove count", 2, providerService.locationRemoveCount);
device = new DefaultDevice(ProviderId.NONE, deviceId(DEV4), SWITCH, "m", "h", "s", "n", new ChassisId(0L));
deviceService.listener.event(new DeviceEvent(DEVICE_AVAILABILITY_CHANGED, device));
assertEquals("incorrect remove count", 3, providerService.locationRemoveCount);
}
Aggregations