2 * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
4 * This program and the accompanying materials are made available under the
5 * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6 * and is available at http://www.eclipse.org/legal/epl-v10.html
9 package org.opendaylight.netconf.topology.example;
11 import akka.actor.ActorRef;
12 import com.google.common.util.concurrent.Futures;
13 import com.google.common.util.concurrent.ListenableFuture;
14 import javax.annotation.Nonnull;
15 import org.opendaylight.controller.md.sal.dom.api.DOMNotification;
16 import org.opendaylight.controller.md.sal.dom.api.DOMRpcService;
17 import org.opendaylight.netconf.sal.connect.netconf.listener.NetconfSessionPreferences;
18 import org.opendaylight.netconf.topology.NodeManagerCallback;
19 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
20 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder;
21 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeFields;
22 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
23 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
24 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder;
25 import org.opendaylight.yangtools.yang.model.api.SchemaContext;
27 public class ExampleNodeManagerCallback implements NodeManagerCallback {
29 public ExampleNodeManagerCallback() {
33 @Override public Node getInitialState(@Nonnull final NodeId nodeId,
34 @Nonnull final Node configNode) {
35 return new NodeBuilder().addAugmentation(NetconfNode.class,
36 new NetconfNodeBuilder().setConnectionStatus(NetconfNodeFields.ConnectionStatus.Connecting).build()).build();
39 @Nonnull @Override public Node getFailedState(@Nonnull final NodeId nodeId,
40 @Nonnull final Node configNode) {
41 return new NodeBuilder().addAugmentation(NetconfNode.class,
42 new NetconfNodeBuilder().setConnectionStatus(NetconfNodeFields.ConnectionStatus.UnableToConnect).build()).build();
45 @Nonnull @Override public ListenableFuture<Node> onNodeCreated(@Nonnull final NodeId nodeId,
46 @Nonnull final Node configNode) {
47 return Futures.immediateFuture(new NodeBuilder().addAugmentation(NetconfNode.class,
48 new NetconfNodeBuilder().setConnectionStatus(NetconfNodeFields.ConnectionStatus.Connected).build()).build());
51 @Nonnull @Override public ListenableFuture<Node> onNodeUpdated(@Nonnull final NodeId nodeId,
52 @Nonnull final Node configNode) {
54 return Futures.immediateFuture(new NodeBuilder().addAugmentation(NetconfNode.class,
55 new NetconfNodeBuilder().setConnectionStatus(NetconfNodeFields.ConnectionStatus.Connected).build()).build());
58 @Nonnull @Override public ListenableFuture<Void> onNodeDeleted(@Nonnull final NodeId nodeId) {
59 return Futures.immediateFuture(null);
64 public ListenableFuture<Node> getCurrentStatusForNode(@Nonnull NodeId nodeId) {
69 public void onReceive(Object message, ActorRef sender) {
74 public void onRoleChanged(RoleChangeDTO roleChangeDTO) {
79 public void onDeviceConnected(SchemaContext remoteSchemaContext, NetconfSessionPreferences netconfSessionPreferences, DOMRpcService deviceRpc) {
84 public void onDeviceDisconnected() {
89 public void onDeviceFailed(Throwable throwable) {
94 public void onNotification(DOMNotification domNotification) {