Search in sources :

Example 1 with NetconfProxyMessage

use of org.onosproject.netconf.NetconfProxyMessage in project onos by opennetworkinglab.

the class NetconfControllerImpl method pingDevice.

@Override
public <T> boolean pingDevice(DeviceId deviceId) {
    NetconfProxyMessage proxyMessage = new DefaultNetconfProxyMessage(NetconfProxyMessage.SubjectType.GET_DEVICE_CAPABILITIES_SET, deviceId, null, localNodeId);
    CompletableFuture<T> reply;
    if (deviceService.getRole(deviceId).equals(MastershipRole.MASTER)) {
        reply = handleProxyMessage(proxyMessage);
    } else {
        reply = relayMessageToMaster(proxyMessage);
    }
    try {
        T deviceCapabilities = reply.get();
        log.debug("Get device capabilities from device : {} -> {}", deviceId, deviceCapabilities);
    } catch (InterruptedException | ExecutionException e) {
        log.error("Error while getting device capabilities for device : {}", deviceId);
        log.error("Error details : ", e);
        return false;
    }
    return true;
}
Also used : NetconfProxyMessage(org.onosproject.netconf.NetconfProxyMessage) ExecutionException(java.util.concurrent.ExecutionException)

Example 2 with NetconfProxyMessage

use of org.onosproject.netconf.NetconfProxyMessage in project onos by opennetworkinglab.

the class NetconfSessionProxyImpl method startSubscription.

@Override
public void startSubscription(String filterSchema) throws NetconfException {
    NetconfProxyMessage proxyMessage = makeProxyMessage(NetconfProxyMessage.SubjectType.START_SUBSCRIPTION, filterSchema);
    executeAtMaster(proxyMessage);
}
Also used : NetconfProxyMessage(org.onosproject.netconf.NetconfProxyMessage)

Example 3 with NetconfProxyMessage

use of org.onosproject.netconf.NetconfProxyMessage in project onos by opennetworkinglab.

the class NetconfSessionProxyImpl method setOnosCapabilities.

@Override
public void setOnosCapabilities(Iterable<String> capabilities) {
    ArrayList<String> capabilitiesList = new ArrayList<>();
    capabilities.spliterator().forEachRemaining(c -> capabilitiesList.add(c));
    NetconfProxyMessage proxyMessage = new DefaultNetconfProxyMessage(NetconfProxyMessage.SubjectType.SET_ONOS_CAPABILITIES, deviceInfo.getDeviceId(), capabilitiesList, sessionNodeId);
    try {
        executeAtMaster(proxyMessage);
    } catch (NetconfException e) {
        log.error("Could not set onos capabilities : {}", e);
    }
}
Also used : NetconfException(org.onosproject.netconf.NetconfException) ArrayList(java.util.ArrayList) NetconfProxyMessage(org.onosproject.netconf.NetconfProxyMessage)

Example 4 with NetconfProxyMessage

use of org.onosproject.netconf.NetconfProxyMessage in project onos by opennetworkinglab.

the class NetconfSessionProxyImpl method endSubscription.

@Override
public void endSubscription() throws NetconfException {
    NetconfProxyMessage proxyMessage = makeProxyMessage(NetconfProxyMessage.SubjectType.END_SUBSCRIPTION, "");
    executeAtMaster(proxyMessage);
}
Also used : NetconfProxyMessage(org.onosproject.netconf.NetconfProxyMessage)

Example 5 with NetconfProxyMessage

use of org.onosproject.netconf.NetconfProxyMessage in project onos by opennetworkinglab.

the class NetconfControllerImpl method activate.

@Activate
public void activate(ComponentContext context) {
    cfgService.registerProperties(getClass());
    modified(context);
    Security.addProvider(new BouncyCastleProvider());
    clusterCommunicator.<NetconfProxyMessage>addSubscriber(SEND_REQUEST_SUBJECT_STRING, SERIALIZER::decode, this::handleProxyMessage, remoteRequestExecutor);
    clusterCommunicator.<NetconfProxyMessage>addSubscriber(SEND_REQUEST_SUBJECT_SET_STRING, SERIALIZER::decode, this::handleProxyMessage, remoteRequestExecutor);
    clusterCommunicator.<NetconfProxyMessage>addSubscriber(SEND_REPLY_SUBJECT_STRING, SERIALIZER::decode, this::handleProxyReplyMessage, remoteRequestExecutor);
    clusterCommunicator.<NetconfProxyMessage>addSubscriber(SEND_REPLY_SUBJECT_SET_STRING, SERIALIZER::decode, this::handleProxyReplyMessage, remoteRequestExecutor);
    localNodeId = Optional.ofNullable(clusterService.getLocalNode()).map(ControllerNode::id).orElseGet(() -> new NodeId("nullNodeId"));
    log.info("Started");
}
Also used : NodeId(org.onosproject.cluster.NodeId) ControllerNode(org.onosproject.cluster.ControllerNode) NetconfProxyMessage(org.onosproject.netconf.NetconfProxyMessage) BouncyCastleProvider(org.bouncycastle.jce.provider.BouncyCastleProvider) Activate(org.osgi.service.component.annotations.Activate)

Aggregations

NetconfProxyMessage (org.onosproject.netconf.NetconfProxyMessage)5 ArrayList (java.util.ArrayList)1 ExecutionException (java.util.concurrent.ExecutionException)1 BouncyCastleProvider (org.bouncycastle.jce.provider.BouncyCastleProvider)1 ControllerNode (org.onosproject.cluster.ControllerNode)1 NodeId (org.onosproject.cluster.NodeId)1 NetconfException (org.onosproject.netconf.NetconfException)1 Activate (org.osgi.service.component.annotations.Activate)1