Remove OvsdbConfigurationService
[ovsdb.git] / openstack / net-virt / src / main / java / org / opendaylight / ovsdb / openstack / netvirt / impl / ConfigurationServiceImpl.java
index e3252f04c718bd7ff5bd1802988e7a280d02fc47..b6c157424105a2f0c225d903311e4ce2403a6d69 100644 (file)
@@ -9,31 +9,24 @@
  */
 package org.opendaylight.ovsdb.openstack.netvirt.impl;
 
+import com.google.common.collect.Maps;
 import java.net.InetAddress;
+import java.net.UnknownHostException;
 import java.util.Map;
 
 import org.apache.commons.lang3.tuple.ImmutablePair;
 import org.apache.commons.lang3.tuple.Pair;
-import org.opendaylight.ovsdb.lib.notation.Row;
 import org.opendaylight.ovsdb.openstack.netvirt.api.ConfigurationService;
 import org.opendaylight.ovsdb.openstack.netvirt.api.Constants;
-import org.opendaylight.ovsdb.openstack.netvirt.api.OvsdbConfigurationService;
-import org.opendaylight.ovsdb.schema.openvswitch.OpenVSwitch;
+import org.opendaylight.ovsdb.openstack.netvirt.api.OvsdbTables;
 import org.opendaylight.ovsdb.utils.config.ConfigProperties;
 import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.common.collect.Maps;
-
 public class ConfigurationServiceImpl implements ConfigurationService {
     static final Logger logger = LoggerFactory.getLogger(ConfigurationServiceImpl.class);
 
-    // Values set with dependency injection from OSGi
-    /* TODO SB_MIGRATION */
-    private volatile OvsdbConfigurationService ovsdbConfigurationService;
-    //private volatile MdsalConsumer mdsalConsumer;
-
     private String integrationBridgeName;
     private String networkBridgeName;
     private String externalBridgeName;
@@ -43,6 +36,10 @@ public class ConfigurationServiceImpl implements ConfigurationService {
     private String providerMappingsKey;
     private String providerMapping;
 
+    void init() {
+        logger.info(">>>>>> init {}", this.getClass());
+    }
+
     public ConfigurationServiceImpl() {
         tunnelEndpointKey = Constants.TUNNEL_ENDPOINT_KEY;
         integrationBridgeName = Constants.INTEGRATION_BRIDGE;
@@ -133,43 +130,16 @@ public class ConfigurationServiceImpl implements ConfigurationService {
 
     @Override
     public InetAddress getTunnelEndPoint(Node node) {
-        //InetAddress address = mdsalConsumer.getTunnelEndPoint(node);
-        /* TODO SB_MIGRATION */
         InetAddress address = null;
-        try {
-            Map<String, Row> ovsTable = ovsdbConfigurationService.getRows(node,
-                    ovsdbConfigurationService.getTableName(node, OpenVSwitch.class));
-
-            if (ovsTable == null) {
-                logger.error("OpenVSwitch table is null for Node {} ", node);
-                return null;
-            }
-
-            // While there is only one entry in the HashMap, we can't access it by index...
-            for (Row row : ovsTable.values()) {
-                OpenVSwitch ovsRow = ovsdbConfigurationService.getTypedRow(node, OpenVSwitch.class, row);
-                Map<String, String> configs = ovsRow.getOtherConfigColumn().getData();
-
-                if (configs == null) {
-                    logger.debug("OpenVSwitch table is null for Node {} ", node);
-                    continue;
-                }
-
-                String tunnelEndpoint = configs.get(tunnelEndpointKey);
-
-                if (tunnelEndpoint == null) {
-                    continue;
-                }
-
+        String tunnelEndpoint = MdsalUtils.getOtherConfig(node, OvsdbTables.OPENVSWITCH, tunnelEndpointKey);
+        if (tunnelEndpoint != null) {
+            try {
                 address = InetAddress.getByName(tunnelEndpoint);
-                logger.debug("Tunnel Endpoint for Node {} {}", node, address.getHostAddress());
-                break;
+            } catch (UnknownHostException e) {
+                logger.error("Error populating Tunnel Endpoint for Node {} ", node, e);
             }
+            logger.debug("Tunnel Endpoint for Node {} {}", node, address.getHostAddress());
         }
-        catch (Exception e) {
-            logger.error("Error populating Tunnel Endpoint for Node {} ", node, e);
-        }
-
         return address;
     }
 
@@ -180,11 +150,14 @@ public class ConfigurationServiceImpl implements ConfigurationService {
 
     @Override
     public String getDefaultGatewayMacAddress(Node node) {
-        /* TODO SB_MIGRATION */
-        final String l3gatewayForNode =
-            node != null ?
-            ConfigProperties.getProperty(this.getClass(), "ovsdb.l3gateway.mac." + node.getNodeId().getValue()) : null;
-        return l3gatewayForNode != null ?
-               l3gatewayForNode : ConfigProperties.getProperty(this.getClass(), "ovsdb.l3gateway.mac");
+        String l3gatewayForNode = null;
+        if (node != null) {
+            l3gatewayForNode = ConfigProperties.getProperty(this.getClass(),
+                    "ovsdb.l3gateway.mac." + node.getNodeId().getValue());
+            if (l3gatewayForNode == null) {
+                l3gatewayForNode = ConfigProperties.getProperty(this.getClass(), "ovsdb.l3gateway.mac");
+            }
+        }
+        return l3gatewayForNode;
     }
 }