05b69fc79a40d6049072f08c2686057eb58e7922
[netconf.git] / opendaylight / netconf / abstract-topology / src / main / java / org / opendaylight / netconf / topology / example / ExampleNodeManagerCallback.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. and others. All rights reserved.
3  *
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
7  */
8
9 package org.opendaylight.netconf.topology.example;
10
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.netconf.topology.NodeManagerCallback;
16 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
17 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeBuilder;
18 import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNodeFields;
19 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
20 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
21 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.NodeBuilder;
22
23 public class ExampleNodeManagerCallback implements NodeManagerCallback {
24
25     public ExampleNodeManagerCallback() {
26     }
27
28     @Nonnull
29     @Override public Node getInitialState(@Nonnull final NodeId nodeId,
30                                           @Nonnull final Node configNode) {
31         return new NodeBuilder().addAugmentation(NetconfNode.class,
32                 new NetconfNodeBuilder().setConnectionStatus(NetconfNodeFields.ConnectionStatus.Connecting).build()).build();
33     }
34
35     @Nonnull @Override public Node getFailedState(@Nonnull final NodeId nodeId,
36                                                   @Nonnull final Node configNode) {
37         return new NodeBuilder().addAugmentation(NetconfNode.class,
38                 new NetconfNodeBuilder().setConnectionStatus(NetconfNodeFields.ConnectionStatus.UnableToConnect).build()).build();
39     }
40
41     @Nonnull @Override public ListenableFuture<Node> onNodeCreated(@Nonnull final NodeId nodeId,
42                                                                    @Nonnull final Node configNode) {
43         return Futures.immediateFuture(new NodeBuilder().addAugmentation(NetconfNode.class,
44                 new NetconfNodeBuilder().setConnectionStatus(NetconfNodeFields.ConnectionStatus.Connected).build()).build());
45     }
46
47     @Nonnull @Override public ListenableFuture<Node> onNodeUpdated(@Nonnull final NodeId nodeId,
48                                                                    @Nonnull final Node configNode) {
49         // update magic
50         return Futures.immediateFuture(new NodeBuilder().addAugmentation(NetconfNode.class,
51                 new NetconfNodeBuilder().setConnectionStatus(NetconfNodeFields.ConnectionStatus.Connected).build()).build());
52     }
53
54     @Nonnull @Override public ListenableFuture<Void> onNodeDeleted(@Nonnull final NodeId nodeId) {
55         return Futures.immediateFuture(null);
56     }
57
58     @Nonnull
59     @Override
60     public ListenableFuture<Node> getCurrentStatusForNode(@Nonnull NodeId nodeId) {
61         return null;
62     }
63
64     @Override
65     public void onReceive(Object message, ActorRef sender) {
66
67     }
68
69     @Override
70     public void onRoleChanged(RoleChangeDTO roleChangeDTO) {
71
72     }
73 }