Search in sources :

Example 1 with SnmpDeviceConfig

use of org.onosproject.snmp.SnmpDeviceConfig in project onos by opennetworkinglab.

the class SnmpDeviceProvider method connectDevices.

// Method to register devices provided via net-cfg under devices/ tree
private void connectDevices() {
    Set<DeviceId> deviceSubjects = netCfgService.getSubjects(DeviceId.class, SnmpDeviceConfig.class);
    deviceSubjects.forEach(deviceId -> {
        SnmpDeviceConfig config = netCfgService.getConfig(deviceId, SnmpDeviceConfig.class);
        if (config.version() == SnmpConstants.version2c) {
            buildDevice(new DefaultSnmpDevice(config));
        } else if (config.version() == SnmpConstants.version3) {
            buildDevice(new DefaultSnmpv3Device(config));
        } else {
            throw new SnmpException(String.format("Invalid snmp version %d", config.version()));
        }
    });
}
Also used : DefaultSnmpDevice(org.onosproject.snmp.ctl.DefaultSnmpDevice) SnmpException(org.onosproject.snmp.SnmpException) DefaultSnmpv3Device(org.onosproject.snmp.ctl.DefaultSnmpv3Device) DeviceId(org.onosproject.net.DeviceId) SnmpDeviceConfig(org.onosproject.snmp.SnmpDeviceConfig)

Aggregations

DeviceId (org.onosproject.net.DeviceId)1 SnmpDeviceConfig (org.onosproject.snmp.SnmpDeviceConfig)1 SnmpException (org.onosproject.snmp.SnmpException)1 DefaultSnmpDevice (org.onosproject.snmp.ctl.DefaultSnmpDevice)1 DefaultSnmpv3Device (org.onosproject.snmp.ctl.DefaultSnmpv3Device)1