Merge "UT for ovsdb.southbound transact package"
[netvirt.git] / openstack / net-virt / src / main / java / org / opendaylight / ovsdb / openstack / netvirt / LBaaSPoolHandler.java
index 66493fa788d38781474363a3f13416fbd1f144b0..93b4ce626ecabb3b93fd2269bed9d627f8c08c1c 100755 (executable)
@@ -1,11 +1,9 @@
 /*
- * Copyright (C) 2014 SDN Hub, LLC.
+ * Copyright (c) 2014, 2015 SDN Hub, LLC. 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
- *
- * Authors : Srini Seetharaman
  */
 
 package org.opendaylight.ovsdb.openstack.netvirt;
@@ -14,14 +12,14 @@ import java.net.HttpURLConnection;
 import java.util.List;
 import java.util.Map;
 
-import org.opendaylight.neutron.spi.INeutronLoadBalancerCRUD;
-import org.opendaylight.neutron.spi.INeutronLoadBalancerPoolAware;
-import org.opendaylight.neutron.spi.INeutronNetworkCRUD;
-import org.opendaylight.neutron.spi.INeutronPortCRUD;
-import org.opendaylight.neutron.spi.INeutronSubnetCRUD;
-import org.opendaylight.neutron.spi.NeutronLoadBalancer;
-import org.opendaylight.neutron.spi.NeutronLoadBalancerPool;
-import org.opendaylight.neutron.spi.NeutronLoadBalancerPoolMember;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancer;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerPool;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.NeutronLoadBalancerPoolMember;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronLoadBalancerCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronNetworkCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronPortCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.crud.INeutronSubnetCRUD;
+import org.opendaylight.ovsdb.openstack.netvirt.translator.iaware.INeutronLoadBalancerPoolAware;
 import org.opendaylight.ovsdb.openstack.netvirt.api.Action;
 import org.opendaylight.ovsdb.openstack.netvirt.api.EventDispatcher;
 import org.opendaylight.ovsdb.openstack.netvirt.api.LoadBalancerConfiguration;
@@ -29,7 +27,7 @@ import org.opendaylight.ovsdb.openstack.netvirt.api.LoadBalancerProvider;
 import org.opendaylight.ovsdb.openstack.netvirt.api.NodeCacheManager;
 import org.opendaylight.ovsdb.utils.servicehelper.ServiceHelper;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
-import org.osgi.framework.BundleContext;
+
 import org.osgi.framework.ServiceReference;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -86,11 +84,11 @@ public class LBaaSPoolHandler extends AbstractHandler
         List<LoadBalancerConfiguration> lbConfigList = extractLBConfiguration(neutronLBPool);
         final List<Node> nodes = nodeCacheManager.getBridgeNodes();
         if (lbConfigList == null) {
-            LOG.debug("Neutron LB configuration invalid for pool {} ", neutronLBPool.getLoadBalancerPoolID());
+            LOG.debug("Neutron LB configuration invalid for pool {} ", neutronLBPool.getID());
         } else if (lbConfigList.size() == 0) {
-            LOG.debug("No Neutron LB VIP not created yet for pool {} ", neutronLBPool.getLoadBalancerPoolID());
+            LOG.debug("No Neutron LB VIP not created yet for pool {} ", neutronLBPool.getID());
         } else if (nodes.isEmpty()) {
-            LOG.debug("Noop with LB pool {} creation because no nodes available.", neutronLBPool.getLoadBalancerPoolID());
+            LOG.debug("Noop with LB pool {} creation because no nodes available.", neutronLBPool.getID());
         } else {
             for (LoadBalancerConfiguration lbConfig: lbConfigList) {
                 if (!lbConfig.isValid()) {
@@ -141,11 +139,11 @@ public class LBaaSPoolHandler extends AbstractHandler
         List<LoadBalancerConfiguration> lbConfigList = extractLBConfiguration(neutronLBPool);
         final List<Node> nodes = nodeCacheManager.getBridgeNodes();
         if (lbConfigList == null) {
-            LOG.debug("Neutron LB configuration invalid for pool {} ", neutronLBPool.getLoadBalancerPoolID());
+            LOG.debug("Neutron LB configuration invalid for pool {} ", neutronLBPool.getID());
         } else if (lbConfigList.size() == 0) {
-            LOG.debug("No Neutron LB VIP not created yet for pool {} ", neutronLBPool.getLoadBalancerPoolID());
+            LOG.debug("No Neutron LB VIP not created yet for pool {} ", neutronLBPool.getID());
         } else if (nodes.isEmpty()) {
-            LOG.debug("Noop with LB pool {} deletion because no nodes available.", neutronLBPool.getLoadBalancerPoolID());
+            LOG.debug("Noop with LB pool {} deletion because no nodes available.", neutronLBPool.getID());
         } else {
             for (LoadBalancerConfiguration lbConfig: lbConfigList) {
                 if (!lbConfig.isValid()) {
@@ -196,6 +194,8 @@ public class LBaaSPoolHandler extends AbstractHandler
     /**
      * Useful utility for extracting the loadbalancer instance. With
      * each LB pool, we allow multiple VIP and LB to be instantiated.
+     * @param neutronLBPool Neutron load balancer pool object
+     * @return list of loadbalancer configuration of pool members
      */
     public List<LoadBalancerConfiguration> extractLBConfiguration(NeutronLoadBalancerPool neutronLBPool) {
         String poolProtocol = neutronLBPool.getLoadBalancerPoolProtocol();
@@ -241,7 +241,7 @@ public class LBaaSPoolHandler extends AbstractHandler
                 memberSubnetID = neutronLBPoolMember.getPoolMemberSubnetID();
                 if (memberSubnetID != null && memberAdminStateIsUp != null &&
                         memberSubnetID.equals(loadBalancerSubnetID) && memberAdminStateIsUp) {
-                    memberID = neutronLBPoolMember.getPoolMemberID();
+                    memberID = neutronLBPoolMember.getID();
                     memberIP = neutronLBPoolMember.getPoolMemberAddress();
                     memberPort = neutronLBPoolMember.getPoolMemberProtoPort();
                     if (memberID == null || memberIP == null || memberPort == null) {
@@ -265,15 +265,14 @@ public class LBaaSPoolHandler extends AbstractHandler
     }
 
     @Override
-    public void setDependencies(BundleContext bundleContext, ServiceReference serviceReference) {
+    public void setDependencies(ServiceReference serviceReference) {
         loadBalancerProvider =
                 (LoadBalancerProvider) ServiceHelper.getGlobalInstance(LoadBalancerProvider.class, this);
         nodeCacheManager =
                 (NodeCacheManager) ServiceHelper.getGlobalInstance(NodeCacheManager.class, this);
         eventDispatcher =
                 (EventDispatcher) ServiceHelper.getGlobalInstance(EventDispatcher.class, this);
-        eventDispatcher.eventHandlerAdded(
-                bundleContext.getServiceReference(INeutronLoadBalancerPoolAware.class.getName()), this);
+        eventDispatcher.eventHandlerAdded(serviceReference, this);
     }
 
     @Override