use of org.onosproject.netconf.NetconfDevice in project onos by opennetworkinglab.
the class FujitsuVoltControllerConfig method setControllers.
@Override
public void setControllers(List<ControllerInfo> controllers) {
DriverHandler handler = handler();
NetconfController controller = handler.get(NetconfController.class);
MastershipService mastershipService = handler.get(MastershipService.class);
DeviceId ncdeviceId = handler.data().deviceId();
checkNotNull(controller, "Netconf controller is null");
if (mastershipService.isLocalMaster(ncdeviceId)) {
try {
NetconfDevice device = controller.getNetconfDevice(ncdeviceId);
String config = createVoltControllersConfig(XmlConfigParser.loadXml(getClass().getResourceAsStream(RESOURCE_XML)), RUNNING, MERGE, controllers);
device.getSession().editConfig(config.substring(config.indexOf(END_LICENSE_HEADER) + END_LICENSE_HEADER.length()));
} catch (NetconfException e) {
log.error("Cannot communicate to device {} , exception {}", ncdeviceId, e);
}
} else {
log.warn("I'm not master for {} please use master, {} to execute command", ncdeviceId, mastershipService.getMasterFor(ncdeviceId));
}
}
use of org.onosproject.netconf.NetconfDevice in project onos by opennetworkinglab.
the class ClientLineTerminalDeviceDiscovery method getNetconfSession.
/**
* Returns the NetconfSession with the device for which the method was called.
*
* @param deviceId device indetifier
*
* @return The netconf session or null
*/
private NetconfSession getNetconfSession(DeviceId deviceId) {
NetconfController controller = handler().get(NetconfController.class);
NetconfDevice ncdev = controller.getDevicesMap().get(deviceId);
if (ncdev == null) {
log.trace("No netconf device, returning null session");
return null;
}
return ncdev.getSession();
}
use of org.onosproject.netconf.NetconfDevice in project onos by opennetworkinglab.
the class OpenRoadmNetconfHandlerBehaviour method getNetconfSession.
/**
* Returns the NetconfSession with the device for which the method was called.
*
* @param deviceId device indetifier
*
* @return The netconf session or null
*/
protected NetconfSession getNetconfSession(DeviceId deviceId) {
NetconfController controller = handler().get(NetconfController.class);
NetconfDevice ncdev = controller.getDevicesMap().get(deviceId);
if (ncdev == null) {
log.trace("No netconf device, returning null session");
return null;
}
return ncdev.getSession();
}
use of org.onosproject.netconf.NetconfDevice in project onos by opennetworkinglab.
the class NetconfAlarmProvider method activate.
@Activate
public void activate() {
providerService = providerRegistry.register(this);
controller.getNetconfDevices().forEach(id -> {
NetconfDevice device = controller.getNetconfDevice(id);
if (device.isMasterSession()) {
NetconfSession session = device.getSession();
InternalNotificationListener listener = new InternalNotificationListener(device.getDeviceInfo());
try {
session.addDeviceOutputListener(listener);
} catch (NetconfException e) {
log.error("addDeviceOutputListener Error {} ", e.getMessage());
}
idNotificationListenerMap.put(id, listener);
}
});
controller.addDeviceListener(deviceListener);
log.info("NetconfAlarmProvider Started");
}
use of org.onosproject.netconf.NetconfDevice in project onos by opennetworkinglab.
the class CassiniTerminalDeviceDiscovery method getNetconfSession.
/**
* Returns the NetconfSession with the device for which the method was called.
*
* @param deviceId device indetifier
* @return The netconf session or null
*/
private NetconfSession getNetconfSession(DeviceId deviceId) {
NetconfController controller = handler().get(NetconfController.class);
NetconfDevice ncdev = controller.getDevicesMap().get(deviceId);
if (ncdev == null) {
log.trace("No netconf device, returning null session");
return null;
}
return ncdev.getSession();
}
Aggregations