4 * Generated from: yang module name: opendaylight-sal-netconf-connector yang module local name: sal-netconf-connector
5 * Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
6 * Generated at: Mon Nov 18 09:44:16 CET 2013
8 * Do not modify this file unless it is present under src/main directory
10 package org.opendaylight.controller.config.yang.md.sal.connector.netconf;
12 import io.netty.channel.EventLoopGroup;
14 import java.net.InetAddress;
15 import java.net.InetSocketAddress;
17 import javax.net.ssl.SSLContext;
19 import org.opendaylight.controller.netconf.client.NetconfClientDispatcher;
20 import org.opendaylight.controller.sal.connect.netconf.NetconfDevice;
21 import org.osgi.framework.BundleContext;
23 import static com.google.common.base.Preconditions.*;
25 import com.google.common.base.Optional;
26 import com.google.common.net.InetAddresses;
31 public final class NetconfConnectorModule extends org.opendaylight.controller.config.yang.md.sal.connector.netconf.AbstractNetconfConnectorModule
34 private BundleContext bundleContext;
36 public NetconfConnectorModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
37 super(identifier, dependencyResolver);
40 public NetconfConnectorModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, NetconfConnectorModule oldModule, java.lang.AutoCloseable oldInstance) {
41 super(identifier, dependencyResolver, oldModule, oldInstance);
45 public void validate(){
47 checkState(getAddress() != null,"Address must be set.");
48 //checkState(getAddress().getIpv4Address() != null || getAddress().getIpv6Address() != null,"Address must be set.");
49 checkState(getPort() != null,"Port must be set.");
50 checkState(getDomRegistry() != null,"Dom Registry must be provided.");
55 public java.lang.AutoCloseable createInstance() {
57 getDomRegistryDependency();
58 NetconfDevice device = new NetconfDevice(getIdentifier().getInstanceName());
59 String addressValue = getAddress();
63 * Uncomment after Switch to IP Address
64 if(getAddress().getIpv4Address() != null) {
65 addressValue = getAddress().getIpv4Address().getValue();
67 addressValue = getAddress().getIpv6Address().getValue();
71 InetAddress addr = InetAddresses.forString(addressValue);
72 InetSocketAddress socketAddress = new InetSocketAddress(addr , getPort().intValue());
73 device.setSocketAddress(socketAddress);
75 EventLoopGroup bossGroup = getBossThreadGroupDependency();
76 EventLoopGroup workerGroup = getWorkerThreadGroupDependency();
77 Optional<SSLContext> maybeContext = Optional.absent();
78 NetconfClientDispatcher dispatcher = new NetconfClientDispatcher(maybeContext , bossGroup, workerGroup);
80 getDomRegistryDependency().registerProvider(device, bundleContext);
82 device.start(dispatcher);
86 public void setBundleContext(BundleContext bundleContext) {
87 this.bundleContext = bundleContext;