Merge "Added Static Routing Northbound integration tests for all available REST APIs."
authorGiovanni Meo <gmeo@cisco.com>
Fri, 14 Jun 2013 11:00:23 +0000 (11:00 +0000)
committerGerrit Code Review <gerrit@opendaylight.org>
Fri, 14 Jun 2013 11:00:23 +0000 (11:00 +0000)
opendaylight/hosttracker_new/api/pom.xml
opendaylight/hosttracker_new/api/src/main/java/org/opendaylight/controller/hosttracker/IDevice.java
opendaylight/hosttracker_new/implementation/pom.xml
opendaylight/hosttracker_new/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/Activator.java
opendaylight/hosttracker_new/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/Device.java
opendaylight/hosttracker_new/implementation/src/main/java/org/opendaylight/controller/hosttracker/internal/DeviceManagerImpl.java
opendaylight/hosttracker_new/implementation/src/test/resources/logback.xml [new file with mode: 0644]

index a4c2f2e..6a98c71 100644 (file)
@@ -22,8 +22,8 @@
         <configuration>\r
           <instructions>\r
             <Export-Package>\r
-              org.opendaylight.controller.hosttracker_new,\r
-              org.opendaylight.controller.hosttracker_new.hostAware\r
+              org.opendaylight.controller.hosttracker,\r
+              org.opendaylight.controller.hosttracker.hostAware\r
             </Export-Package>\r
             <Import-Package>\r
               org.opendaylight.controller.sal.core,\r
index d9cd3f1..b2ba643 100644 (file)
@@ -35,6 +35,8 @@ package org.opendaylight.controller.hosttracker;
 
 import java.util.Date;
 
+import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector;
+
 /**
  * Represents an independent device on the network. A device consists of a set
  * of entities, and all the information known about a given device comes only
@@ -132,4 +134,6 @@ public interface IDevice {
      */
     public IEntityClass getEntityClass();
 
+    public HostNodeConnector toHostNodeConnector();
+
 }
index 0201fd8..804f5e3 100644 (file)
@@ -52,7 +52,7 @@
               org.opendaylight.controller.sal.packet.address,
               org.opendaylight.controller.switchmanager,
               org.opendaylight.controller.clustering.services,
-              org.opendaylight.controller.hosttracker_new.hostAware,
+              org.opendaylight.controller.hosttracker.hostAware,
               javax.xml.bind.annotation,
               javax.xml.bind,
               org.apache.felix.dm,
index 631a65a..2cf1c1d 100644 (file)
@@ -13,6 +13,7 @@ import java.util.Hashtable;
 
 import org.apache.felix.dm.Component;
 import org.opendaylight.controller.hosttracker.IDeviceService;
+import org.opendaylight.controller.hosttracker.IfIptoHost;
 import org.opendaylight.controller.sal.core.ComponentActivatorAbstractBase;
 import org.opendaylight.controller.sal.packet.IDataPacketService;
 import org.opendaylight.controller.sal.packet.IListenDataPacket;
@@ -74,9 +75,11 @@ public class Activator extends ComponentActivatorAbstractBase {
             Dictionary<String, String> props = new Hashtable<String, String>();
             props.put("salListenerName", "devicemanager");
 
-            c.setInterface(new String[] { IDeviceService.class.getName(),
-                    IListenDataPacket.class.getName(),
-                    ITopologyManagerAware.class.getName() }, props);
+            c.setInterface(
+                    new String[] { IDeviceService.class.getName(),
+                            IfIptoHost.class.getName(),
+                            IListenDataPacket.class.getName(),
+                            ITopologyManagerAware.class.getName() }, props);
 
             c.add(createContainerServiceDependency(containerName)
                     .setService(ISwitchManager.class)
index 90911fe..50e77ec 100755 (executable)
@@ -33,6 +33,7 @@
 
 package org.opendaylight.controller.hosttracker.internal;
 
+import java.net.InetAddress;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.Collection;
@@ -51,6 +52,7 @@ import org.opendaylight.controller.hosttracker.IDeviceService.DeviceField;
 import org.opendaylight.controller.hosttracker.IEntityClass;
 import org.opendaylight.controller.hosttracker.SwitchPort;
 import org.opendaylight.controller.hosttracker.SwitchPort.ErrorStatus;
+import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector;
 import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.utils.HexEncode;
 import org.slf4j.Logger;
@@ -779,6 +781,28 @@ public class Device implements IDevice {
         return true;
     }
 
+    public HostNodeConnector toHostNodeConnector() {
+        Integer[] ipv4s = this.getIPv4Addresses();
+        try {
+            InetAddress ip = InetAddress.getByName(ipv4s[ipv4s.length - 1]
+                    .toString());
+            byte[] macAddr = macLongToByte(this.getMACAddress());
+            HostNodeConnector nc = new HostNodeConnector(macAddr, ip, null,
+                    (short) 0);
+            return nc;
+        } catch (Exception e) {
+            return null;
+        }
+    }
+
+    private byte[] macLongToByte(long mac) {
+        byte[] macAddr = new byte[6];
+        for (int i = 0; i < 6; i++) {
+            macAddr[5 - i] = (byte) (mac >> (8 * i));
+        }
+        return macAddr;
+    }
+
     @Override
     public String toString() {
         StringBuilder builder = new StringBuilder();
index 8435a94..bda1372 100755 (executable)
@@ -37,6 +37,7 @@ import static org.opendaylight.controller.hosttracker.internal.DeviceManagerImpl
 import static org.opendaylight.controller.hosttracker.internal.DeviceManagerImpl.DeviceUpdate.Change.CHANGE;
 import static org.opendaylight.controller.hosttracker.internal.DeviceManagerImpl.DeviceUpdate.Change.DELETE;
 
+import java.net.InetAddress;
 import java.util.ArrayList;
 import java.util.Calendar;
 import java.util.Collection;
@@ -54,6 +55,7 @@ import java.util.Queue;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.Executors;
+import java.util.concurrent.Future;
 import java.util.concurrent.ScheduledExecutorService;
 import java.util.concurrent.TimeUnit;
 
@@ -64,7 +66,9 @@ import org.opendaylight.controller.hosttracker.IDeviceService;
 import org.opendaylight.controller.hosttracker.IEntityClass;
 import org.opendaylight.controller.hosttracker.IEntityClassListener;
 import org.opendaylight.controller.hosttracker.IEntityClassifierService;
+import org.opendaylight.controller.hosttracker.IfIptoHost;
 import org.opendaylight.controller.hosttracker.SwitchPort;
+import org.opendaylight.controller.hosttracker.hostAware.HostNodeConnector;
 import org.opendaylight.controller.sal.core.Edge;
 import org.opendaylight.controller.sal.core.NodeConnector;
 import org.opendaylight.controller.sal.core.NodeConnector.NodeConnectorIDType;
@@ -79,6 +83,7 @@ import org.opendaylight.controller.sal.topology.TopoEdgeUpdate;
 import org.opendaylight.controller.sal.utils.ListenerDispatcher;
 import org.opendaylight.controller.sal.utils.MultiIterator;
 import org.opendaylight.controller.sal.utils.SingletonTask;
+import org.opendaylight.controller.sal.utils.Status;
 import org.opendaylight.controller.switchmanager.ISwitchManager;
 import org.opendaylight.controller.topologymanager.ITopologyManager;
 import org.opendaylight.controller.topologymanager.ITopologyManagerAware;
@@ -93,7 +98,7 @@ import org.slf4j.LoggerFactory;
  * @author readams
  */
 public class DeviceManagerImpl implements IDeviceService, IEntityClassListener,
-        IListenDataPacket, ITopologyManagerAware {
+        IListenDataPacket, ITopologyManagerAware, IfIptoHost {
     protected static Logger logger = LoggerFactory
             .getLogger(DeviceManagerImpl.class);
 
@@ -534,6 +539,18 @@ public class DeviceManagerImpl implements IDeviceService, IEntityClassListener,
     // IDeviceManagerService
     // *********************
 
+    void setSwitchManager(ISwitchManager s) {
+        logger.debug("SwitchManager set");
+        this.switchManager = s;
+    }
+
+    void unsetSwitchManager(ISwitchManager s) {
+        if (this.switchManager == s) {
+            logger.debug("SwitchManager removed!");
+            this.switchManager = null;
+        }
+    }
+
     @Override
     public IDevice getDevice(Long deviceKey) {
         return deviceMap.get(deviceKey);
@@ -2043,6 +2060,68 @@ public class DeviceManagerImpl implements IDeviceService, IEntityClassListener,
          */
     }
 
+    @Override
+    public HostNodeConnector hostFind(InetAddress networkAddress) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public HostNodeConnector hostQuery(InetAddress networkAddress) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Future<HostNodeConnector> discoverHost(InetAddress networkAddress) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public List<List<String>> getHostNetworkHierarchy(InetAddress hostAddress) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Set<HostNodeConnector> getAllHosts() {
+        Collection<Device> devices = Collections
+                .unmodifiableCollection(deviceMap.values());
+        Iterator<Device> i = devices.iterator();
+        Set<HostNodeConnector> nc = new HashSet<HostNodeConnector>();
+        while (i.hasNext()) {
+            Device device = i.next();
+            nc.add(device.toHostNodeConnector());
+        }
+        return nc;
+    }
+
+    @Override
+    public Set<HostNodeConnector> getActiveStaticHosts() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Set<HostNodeConnector> getInactiveStaticHosts() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Status addStaticHost(String networkAddress, String dataLayerAddress,
+            NodeConnector nc, String vlan) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    @Override
+    public Status removeStaticHost(String networkAddress) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
     /**
      * For testing: consolidate the store NOW
      */
diff --git a/opendaylight/hosttracker_new/implementation/src/test/resources/logback.xml b/opendaylight/hosttracker_new/implementation/src/test/resources/logback.xml
new file mode 100644 (file)
index 0000000..5fa21fe
--- /dev/null
@@ -0,0 +1,13 @@
+<configuration scan="true">\r
+\r
+  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">\r
+    <encoder>\r
+      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n\r
+      </pattern>\r
+    </encoder>\r
+  </appender>\r
+\r
+  <root level="error">\r
+    <appender-ref ref="STDOUT" />\r
+  </root>\r
+</configuration>\r