Search in sources :

Example 21 with NetconfDevice

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));
    }
}
Also used : NetconfException(org.onosproject.netconf.NetconfException) NetconfDevice(org.onosproject.netconf.NetconfDevice) DeviceId(org.onosproject.net.DeviceId) DriverHandler(org.onosproject.net.driver.DriverHandler) MastershipService(org.onosproject.mastership.MastershipService) NetconfController(org.onosproject.netconf.NetconfController)

Example 22 with NetconfDevice

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();
}
Also used : NetconfDevice(org.onosproject.netconf.NetconfDevice) NetconfController(org.onosproject.netconf.NetconfController)

Example 23 with NetconfDevice

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();
}
Also used : NetconfDevice(org.onosproject.netconf.NetconfDevice) NetconfController(org.onosproject.netconf.NetconfController)

Example 24 with NetconfDevice

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");
}
Also used : NetconfSession(org.onosproject.netconf.NetconfSession) NetconfException(org.onosproject.netconf.NetconfException) NetconfDevice(org.onosproject.netconf.NetconfDevice) Activate(org.osgi.service.component.annotations.Activate)

Example 25 with NetconfDevice

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();
}
Also used : NetconfDevice(org.onosproject.netconf.NetconfDevice) NetconfController(org.onosproject.netconf.NetconfController)

Aggregations

NetconfDevice (org.onosproject.netconf.NetconfDevice)37 NetconfController (org.onosproject.netconf.NetconfController)20 NetconfException (org.onosproject.netconf.NetconfException)13 DeviceId (org.onosproject.net.DeviceId)8 NetconfSession (org.onosproject.netconf.NetconfSession)6 Test (org.junit.Test)5 NetconfDeviceInfo (org.onosproject.netconf.NetconfDeviceInfo)5 ExecutionException (java.util.concurrent.ExecutionException)4 NetconfDeviceConfig (org.onosproject.netconf.config.NetconfDeviceConfig)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 TimeoutException (java.util.concurrent.TimeoutException)2 Lock (java.util.concurrent.locks.Lock)2 ReentrantLock (java.util.concurrent.locks.ReentrantLock)2 IpAddress (org.onlab.packet.IpAddress)2 MastershipService (org.onosproject.mastership.MastershipService)2 DefaultDeviceDescription (org.onosproject.net.device.DefaultDeviceDescription)2 DeviceDescription (org.onosproject.net.device.DeviceDescription)2 DefaultDriver (org.onosproject.net.driver.DefaultDriver)2 DefaultDriverData (org.onosproject.net.driver.DefaultDriverData)2 DriverHandler (org.onosproject.net.driver.DriverHandler)2