Remove unused southbound config-lisp.yang 07/39507/1
authorLorand Jakab <lojakab@cisco.com>
Thu, 26 May 2016 09:00:09 +0000 (12:00 +0300)
committerLorand Jakab <lojakab@cisco.com>
Fri, 27 May 2016 04:54:07 +0000 (07:54 +0300)
While at it, move the bind-address configuration parameter from
config-lisp.yang to odl-lisp-sb-impl.yang. Removing unused code should
also help with coverage.

Change-Id: I43aa29b585d7111402e3429e6fb3c865f343cb99
Signed-off-by: Lorand Jakab <lojakab@cisco.com>
integrationtest/src/test/java/org/opendaylight/lispflowmapping/integrationtest/MappingServiceIntegrationTest.java
mappingservice/southbound/src/main/config/default-config.xml
mappingservice/southbound/src/main/java/org/opendaylight/controller/config/yang/config/lisp_sb/impl/LfmMappingServiceSbModule.java
mappingservice/southbound/src/main/java/org/opendaylight/lispflowmapping/southbound/LispSouthboundPlugin.java
mappingservice/southbound/src/main/java/org/opendaylight/yang/gen/v1/lispconfig/rev131107/LispConfigContextSetterImpl.java [deleted file]
mappingservice/southbound/src/main/java/org/opendaylight/yang/gen/v1/lispconfig/rev131107/LispConfigModule.java [deleted file]
mappingservice/southbound/src/main/java/org/opendaylight/yang/gen/v1/lispconfig/rev131107/LispConfigModuleFactory.java [deleted file]
mappingservice/southbound/src/main/yang/config-lisp.yang [deleted file]
mappingservice/southbound/src/main/yang/odl-lisp-sb-impl.yang

index 3435ec2ca9766ecf5e057d29433b66a36a2ce0d9..887cf0efda3758408a6ad37ea025361d145b1d54 100644 (file)
@@ -2179,7 +2179,7 @@ public class MappingServiceIntegrationTest extends AbstractMdsalTestBase {
         try {
             socket = new DatagramSocket(new InetSocketAddress(ourAddress, port));
         } catch (SocketException e) {
-            e.printStackTrace();
+            LOG.error("Can't initize socket for {}", ourAddress, e);
             fail();
         }
         return socket;
index 83b7778bf6ee0c7da1596657804d1d31f97cbe48..2c9cc25207881242316029e11f17b5f0f481082e 100644 (file)
@@ -14,6 +14,7 @@
             prefix:lisp-sb-impl
           </type>
           <name>lisp-sb-impl-default</name>
+          <bind-address>0.0.0.0</bind-address>
 
           <rpc-registry>
             <type xmlns:binding="urn:opendaylight:params:xml:ns:yang:controller:md:sal:binding">
index 4d0abfc54468e40460c3ea2acf7692c79a1da4de..e7ac3d1fd0809ed2d1e913a00a08f0064d8c7b8d 100644 (file)
@@ -37,6 +37,7 @@ public class LfmMappingServiceSbModule extends org.opendaylight.controller.confi
         sbPlugin.setNotificationPublishService(getNotificationPublishServiceDependency());
         sbPlugin.setRpcRegistryDependency(getRpcRegistryDependency());
         sbPlugin.setDataBroker(getDataBrokerDependency());
+        sbPlugin.setLispAddress(getBindAddress());
         sbPlugin.init();
 
         return sbPlugin;
index d278c34bc986cf1abbec4edb798b0ab3693147f9..0251bf4ad693682b27a69f4288a2272e12571e35 100644 (file)
@@ -11,6 +11,7 @@ package org.opendaylight.lispflowmapping.southbound;
 import static io.netty.buffer.Unpooled.wrappedBuffer;
 
 import com.google.common.base.Preconditions;
+
 import io.netty.bootstrap.Bootstrap;
 import io.netty.buffer.ByteBuf;
 import io.netty.buffer.ByteBufUtil;
@@ -21,11 +22,13 @@ import io.netty.channel.nio.NioEventLoopGroup;
 import io.netty.channel.socket.DatagramPacket;
 import io.netty.channel.socket.nio.NioDatagramChannel;
 import io.netty.util.concurrent.DefaultThreadFactory;
+
 import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.UnknownHostException;
 import java.nio.ByteBuffer;
 import java.util.concurrent.ThreadFactory;
+
 import org.opendaylight.controller.md.sal.binding.api.DataBroker;
 import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
 import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
@@ -56,6 +59,8 @@ public class LispSouthboundPlugin implements IConfigLispSouthboundPlugin, AutoCl
     private RpcRegistration<OdlLispSbService> sbRpcRegistration;
     private NioDatagramChannel xtrChannel;
     private LispSouthboundStats statistics = new LispSouthboundStats();
+    private Bootstrap bootstrap = new Bootstrap();
+    private Bootstrap xtrBootstrap = new Bootstrap();
     private ThreadFactory threadFactory = new DefaultThreadFactory("lisp-sb");
     private EventLoopGroup eventLoopGroup = new NioEventLoopGroup(0, threadFactory);
     private DataBroker dataBroker;
@@ -76,6 +81,14 @@ public class LispSouthboundPlugin implements IConfigLispSouthboundPlugin, AutoCl
             lispXtrSouthboundHandler = new LispXtrSouthboundHandler();
             lispXtrSouthboundHandler.setNotificationProvider(this.notificationPublishService);
 
+            bootstrap.group(eventLoopGroup);
+            bootstrap.channel(NioDatagramChannel.class);
+            bootstrap.handler(lispSouthboundHandler);
+
+            xtrBootstrap.group(eventLoopGroup);
+            xtrBootstrap.channel(NioDatagramChannel.class);
+            xtrBootstrap.handler(lispXtrSouthboundHandler);
+
             start();
             startXtr();
 
@@ -85,11 +98,8 @@ public class LispSouthboundPlugin implements IConfigLispSouthboundPlugin, AutoCl
 
     private void start() {
         try {
-            Bootstrap bootstrap = new Bootstrap();
-            bootstrap.group(eventLoopGroup);
-            bootstrap.channel(NioDatagramChannel.class);
-            bootstrap.handler(lispSouthboundHandler);
             channel = (NioDatagramChannel) bootstrap.bind(bindingAddress, LispMessage.PORT_NUM).sync().channel();
+            LOG.debug("Binding LISP UDP listening socket to {}:{}", bindingAddress, LispMessage.PORT_NUM);
         } catch (Exception e) {
             LOG.error("Failed to open main socket ", e);
         }
@@ -98,11 +108,8 @@ public class LispSouthboundPlugin implements IConfigLispSouthboundPlugin, AutoCl
     private void startXtr() {
         if (listenOnXtrPort) {
             try {
-                Bootstrap xtrBootstrap = new Bootstrap();
-                xtrBootstrap.group(eventLoopGroup);
-                xtrBootstrap.channel(NioDatagramChannel.class);
-                xtrBootstrap.handler(lispXtrSouthboundHandler);
                 xtrChannel = (NioDatagramChannel) xtrBootstrap.bind(bindingAddress, xtrPort).sync().channel();
+                LOG.debug("Binding LISP xTR UDP listening socket to {}:{}", bindingAddress, xtrPort);
             } catch (Exception e) {
                 LOG.error("Failed to open xTR socket ", e);
             }
@@ -152,7 +159,6 @@ public class LispSouthboundPlugin implements IConfigLispSouthboundPlugin, AutoCl
     private void unloadActions() {
         lispSouthboundHandler = null;
         lispXtrSouthboundHandler = null;
-        bindingAddress = "0.0.0.0";
 
         stop();
         stopXtr();
@@ -218,11 +224,13 @@ public class LispSouthboundPlugin implements IConfigLispSouthboundPlugin, AutoCl
             } else {
                 LOG.debug("Setting LISP binding address to {}", address);
                 bindingAddress = address;
-                try {
-                    restart();
-                    restartXtr();
-                } catch (Exception e) {
-                    LOG.error("Failed to set LISP binding address: ", e);
+                if (channel != null) {
+                    try {
+                        restart();
+                        restartXtr();
+                    } catch (Exception e) {
+                        LOG.error("Failed to set LISP binding address: ", e);
+                    }
                 }
             }
         }
diff --git a/mappingservice/southbound/src/main/java/org/opendaylight/yang/gen/v1/lispconfig/rev131107/LispConfigContextSetterImpl.java b/mappingservice/southbound/src/main/java/org/opendaylight/yang/gen/v1/lispconfig/rev131107/LispConfigContextSetterImpl.java
deleted file mode 100644 (file)
index 3c4ed9f..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Copyright (c) 2014 Contextream, Inc. and others.  All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yang.gen.v1.lispconfig.rev131107;
-
-import java.io.Closeable;
-import java.io.IOException;
-
-import org.opendaylight.lispflowmapping.type.sbplugin.IConfigLispSouthboundPlugin;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.FrameworkUtil;
-
-public class LispConfigContextSetterImpl implements Closeable {
-
-    public void updateContext(LispConfigModule module) {
-        BundleContext bundleContext = FrameworkUtil.getBundle(this.getClass()).getBundleContext();
-        IConfigLispSouthboundPlugin service = (IConfigLispSouthboundPlugin) bundleContext
-                .getService(bundleContext.getServiceReference(IConfigLispSouthboundPlugin.class.getName()));
-        service.setLispAddress(module.getBindAddress());
-    }
-
-    @Override
-    public void close() throws IOException {
-    }
-}
diff --git a/mappingservice/southbound/src/main/java/org/opendaylight/yang/gen/v1/lispconfig/rev131107/LispConfigModule.java b/mappingservice/southbound/src/main/java/org/opendaylight/yang/gen/v1/lispconfig/rev131107/LispConfigModule.java
deleted file mode 100644 (file)
index 62124a0..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-package org.opendaylight.yang.gen.v1.lispconfig.rev131107;
-
-import java.net.Inet4Address;
-import java.net.UnknownHostException;
-
-import org.opendaylight.controller.config.api.JmxAttributeValidationException;
-
-/**
-* Actual state of lisp configuration.
-*/
-public class LispConfigModule extends org.opendaylight.yang.gen.v1.lispconfig.rev131107.AbstractLispConfigModule {
-    public LispConfigModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver) {
-        super(identifier, dependencyResolver);
-    }
-
-    public LispConfigModule(org.opendaylight.controller.config.api.ModuleIdentifier identifier, org.opendaylight.controller.config.api.DependencyResolver dependencyResolver, org.opendaylight.yang.gen.v1.lispconfig.rev131107.LispConfigModule oldModule, java.lang.AutoCloseable oldInstance) {
-        super(identifier, dependencyResolver, oldModule, oldInstance);
-    }
-
-    @Override
-    public void customValidation() {
-        super.customValidation();
-        try {
-            Inet4Address.getByName(getBindAddress());
-        } catch (UnknownHostException e) {
-            throw new JmxAttributeValidationException("LISP bind address is not a valid ipv4 address: " + getBindAddress(), bindAddressJmxAttribute);
-        }
-    }
-
-    @Override
-    public java.lang.AutoCloseable createInstance() {
-        LispConfigContextSetterImpl setter = new LispConfigContextSetterImpl();
-        setter.updateContext(this);
-        return setter;
-    }
-
-}
diff --git a/mappingservice/southbound/src/main/java/org/opendaylight/yang/gen/v1/lispconfig/rev131107/LispConfigModuleFactory.java b/mappingservice/southbound/src/main/java/org/opendaylight/yang/gen/v1/lispconfig/rev131107/LispConfigModuleFactory.java
deleted file mode 100644 (file)
index 0d14eb5..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-/*
-* Generated file
-*
-* Generated from: yang module name: config-lisp yang module local name: lispconfig
-* Generated by: org.opendaylight.controller.config.yangjmxgenerator.plugin.JMXGenerator
-* Generated at: Thu Sep 24 15:15:47 CEST 2015
-*
-* Do not modify this file unless it is present under src/main directory
-*/
-package org.opendaylight.yang.gen.v1.lispconfig.rev131107;
-public class LispConfigModuleFactory extends org.opendaylight.yang.gen.v1.lispconfig.rev131107.AbstractLispConfigModuleFactory {
-
-}
diff --git a/mappingservice/southbound/src/main/yang/config-lisp.yang b/mappingservice/southbound/src/main/yang/config-lisp.yang
deleted file mode 100644 (file)
index b01524d..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-module config-lisp {
-    yang-version 1;
-    namespace "lispconfig";
-    prefix "lispconfig";
-
-    import config { prefix config; revision-date 2013-04-05; }
-    import rpc-context { prefix rpcx; revision-date 2013-06-17; }
-
-    organization "Contextream, Inc.";
-
-    description
-        "This module contains the base YANG definitions for lisp configuration.";
-
-    revision "2013-11-07" {
-        description
-            "Initial revision.";
-    }
-
-    identity lispconfig {
-        description
-            "Actual state of lisp configuration.";
-        base config:module-type;
-        config:java-name-prefix LispConfig;
-    }
-
-    identity lispconfig-rpc;
-
-    augment "/config:modules/config:module/config:configuration" {
-        case lispconfig {
-            when "/config:modules/config:module/config:type = 'lispconfig'";
-
-            leaf bind-address {
-                               type string;
-               mandatory true;
-            }
-        }
-    }
-
-
-    augment "/config:modules/config:module/config:state" {
-        case lispconfig {
-            when "/config:modules/config:module/config:type = 'lispconfig'";
-
-            rpcx:rpc-context-instance "lispconfig-rpc";
-
-        }
-    }
-
-    //rpc rpcmethodexample {
-    //    input {
-     //       uses rpcx:rpc-context-ref {
-      //          refine context-instance {
-       //             rpcx:rpc-context-instance lispconfig-rpc;
-        //        }
-         //   }
-       // }
-  //  }
-
-}
-
index 893c9e19c6ff5bd1ef31f6e57ce79b7d860aa958..bcffac366adea6d3f085998413e85afb800e2e39 100644 (file)
@@ -1,64 +1,69 @@
 module odl-lisp-sb-impl {
 
-  yang-version 1;
-  namespace "urn:opendaylight:params:xml:ns:yang:controller:config:lisp-sb:impl";
-  prefix "lisp-sb-impl";
+    yang-version 1;
+    namespace "urn:opendaylight:params:xml:ns:yang:controller:config:lisp-sb:impl";
+    prefix "lisp-sb-impl";
 
-  import config { prefix config; revision-date 2013-04-05; }
-  import rpc-context { prefix rpcx; revision-date 2013-06-17; }
-  import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; }
-  import opendaylight-sal-binding-broker-impl { prefix sal-broker; revision-date 2013-10-28; }
-  import odl-lisp-sb { prefix lisp-sb; revision-date 2015-09-04; }
-  import odl-mappingservice-dao { prefix ms-dao; revision-date 2015-10-07; }
+    import config { prefix config; revision-date 2013-04-05; }
+    import rpc-context { prefix rpcx; revision-date 2013-06-17; }
+    import opendaylight-md-sal-binding { prefix mdsal; revision-date 2013-10-28; }
+    import opendaylight-sal-binding-broker-impl { prefix sal-broker; revision-date 2013-10-28; }
+    import odl-lisp-sb { prefix lisp-sb; revision-date 2015-09-04; }
+    import odl-mappingservice-dao { prefix ms-dao; revision-date 2015-10-07; }
 
-  description
-      "This module contains the base YANG definitions for
-      mappingservice southbound plugin implementation.";
+    description
+        "This module contains the base YANG definitions for
+        mappingservice southbound plugin implementation.";
 
-  revision "2015-05-17" {
-      description
-          "Initial revision.";
-  }
+    revision "2015-05-17" {
+        description
+            "Initial revision.";
+    }
 
-  identity lisp-sb-impl {
-      base config:module-type;
-      config:provided-service lisp-sb:lisp-sb;
-      config:java-name-prefix LfmMappingServiceSb;
-  }
+    identity lisp-sb-impl {
+        base config:module-type;
+        config:provided-service lisp-sb:lisp-sb;
+        config:java-name-prefix LfmMappingServiceSb;
+    }
 
 
-  // Augments the 'configuration' choice node under modules/module.
-  augment "/config:modules/config:module/config:configuration" {
-    case lisp-sb-impl {
-      when "/config:modules/config:module/config:type = 'lisp-sb-impl'";
+    // Augments the 'configuration' choice node under modules/module.
+    augment "/config:modules/config:module/config:configuration" {
+        case lisp-sb-impl {
+            when "/config:modules/config:module/config:type = 'lisp-sb-impl'";
 
-      container notification-publish-service {
-          uses config:service-ref {
-              refine type {
-                  mandatory true;
-                  config:required-identity sal-broker:binding-new-notification-publish-service;
-              }
-          }
-      }
+            container notification-publish-service {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity sal-broker:binding-new-notification-publish-service;
+                    }
+                }
+            }
 
-      container rpc-registry {
-        uses config:service-ref {
-          refine type {
-              mandatory true;
-              config:required-identity mdsal:binding-rpc-registry;
-          }
-        }
-      }
+            container rpc-registry {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity mdsal:binding-rpc-registry;
+                    }
+                }
+            }
 
-      container data-broker {
-          uses config:service-ref {
-              refine type {
-                  mandatory true;
-                  config:required-identity mdsal:binding-async-data-broker;
-              }
-          }
-      }
+            container data-broker {
+                uses config:service-ref {
+                    refine type {
+                        mandatory true;
+                        config:required-identity mdsal:binding-async-data-broker;
+                    }
+                }
+            }
 
+            leaf bind-address {
+                type string;
+                mandatory true;
+            }
+
+        }
     }
-  }
 }