lldp discovery independent of OF

Change-Id: I720f727f6628e30e5d732e6d7bf742d1b7050812
diff --git a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/GossipDeviceStore.java b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/GossipDeviceStore.java
index d923075..12040dd 100644
--- a/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/GossipDeviceStore.java
+++ b/core/store/dist/src/main/java/org/onlab/onos/store/device/impl/GossipDeviceStore.java
@@ -41,6 +41,7 @@
 import org.onlab.onos.store.common.impl.Timestamped;
 import org.onlab.onos.store.serializers.KryoSerializer;
 import org.onlab.onos.store.serializers.DistributedStoreSerializers;
+import org.onlab.packet.ChassisId;
 import org.onlab.util.KryoPool;
 import org.onlab.util.NewConcurrentHashMap;
 import org.slf4j.Logger;
@@ -745,6 +746,7 @@
         String hwVersion = base.hwVersion();
         String swVersion = base.swVersion();
         String serialNumber = base.serialNumber();
+        ChassisId chassisId = base.chassisId();
         DefaultAnnotations annotations = DefaultAnnotations.builder().build();
         annotations = merge(annotations, base.annotations());
 
@@ -762,7 +764,8 @@
         }
 
         return new DefaultDevice(primary, deviceId , type, manufacturer,
-                            hwVersion, swVersion, serialNumber, annotations);
+                            hwVersion, swVersion, serialNumber,
+                            chassisId, annotations);
     }
 
     /**
diff --git a/core/store/dist/src/test/java/org/onlab/onos/store/device/impl/GossipDeviceStoreTest.java b/core/store/dist/src/test/java/org/onlab/onos/store/device/impl/GossipDeviceStoreTest.java
index 141f2b2..55fa1f4 100644
--- a/core/store/dist/src/test/java/org/onlab/onos/store/device/impl/GossipDeviceStoreTest.java
+++ b/core/store/dist/src/test/java/org/onlab/onos/store/device/impl/GossipDeviceStoreTest.java
@@ -53,6 +53,7 @@
 import org.onlab.onos.store.cluster.messaging.ClusterMessage;
 import org.onlab.onos.store.cluster.messaging.ClusterMessageHandler;
 import org.onlab.onos.store.cluster.messaging.MessageSubject;
+import org.onlab.packet.ChassisId;
 import org.onlab.packet.IpPrefix;
 
 import com.google.common.collect.Iterables;
@@ -74,6 +75,7 @@
     private static final String SW1 = "3.8.1";
     private static final String SW2 = "3.9.5";
     private static final String SN = "43311-12345";
+    private static final ChassisId CID = new ChassisId();
 
     private static final PortNumber P1 = PortNumber.portNumber(1);
     private static final PortNumber P2 = PortNumber.portNumber(2);
@@ -158,7 +160,7 @@
                            SparseAnnotations... annotations) {
         DeviceDescription description =
                 new DefaultDeviceDescription(deviceId.uri(), SWITCH, MFR,
-                        HW, swVersion, SN, annotations);
+                        HW, swVersion, SN, CID, annotations);
         reset(clusterCommunicator);
         try {
             expect(clusterCommunicator.broadcast(anyObject(ClusterMessage.class)))
@@ -175,7 +177,7 @@
                                     SparseAnnotations... annotations) {
         DeviceDescription description =
                 new DefaultDeviceDescription(deviceId.uri(), SWITCH, MFR,
-                        HW, swVersion, SN, annotations);
+                        HW, swVersion, SN, CID, annotations);
         deviceStore.createOrUpdateDevice(PIDA, deviceId, description);
     }
 
@@ -315,7 +317,7 @@
     public final void testCreateOrUpdateDevice() throws IOException {
         DeviceDescription description =
                 new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR,
-                        HW, SW1, SN);
+                        HW, SW1, SN, CID);
         Capture<ClusterMessage> bcast = new Capture<>();
 
         resetCommunicatorExpectingSingleBroadcast(bcast);
@@ -328,7 +330,7 @@
 
         DeviceDescription description2 =
                 new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR,
-                        HW, SW2, SN);
+                        HW, SW2, SN, CID);
         resetCommunicatorExpectingSingleBroadcast(bcast);
         DeviceEvent event2 = deviceStore.createOrUpdateDevice(PID, DID1, description2);
         assertEquals(DEVICE_UPDATED, event2.type());
@@ -346,7 +348,7 @@
         // add
         DeviceDescription description =
                 new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR,
-                        HW, SW1, SN, A2);
+                        HW, SW1, SN, CID, A2);
         Capture<ClusterMessage> bcast = new Capture<>();
 
         resetCommunicatorExpectingSingleBroadcast(bcast);
@@ -362,7 +364,7 @@
         // update from primary
         DeviceDescription description2 =
                 new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR,
-                        HW, SW2, SN, A1);
+                        HW, SW2, SN, CID, A1);
         resetCommunicatorExpectingSingleBroadcast(bcast);
 
         DeviceEvent event2 = deviceStore.createOrUpdateDevice(PID, DID1, description2);
@@ -392,7 +394,7 @@
         // But, Ancillary annotations will be in effect
         DeviceDescription description3 =
                 new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR,
-                        HW, SW1, SN, A2_2);
+                        HW, SW1, SN, CID, A2_2);
         resetCommunicatorExpectingSingleBroadcast(bcast);
 
         DeviceEvent event3 = deviceStore.createOrUpdateDevice(PIDA, DID1, description3);
@@ -775,7 +777,7 @@
 
         DeviceDescription description =
                 new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR,
-                        HW, SW1, SN);
+                        HW, SW1, SN, CID);
         deviceStore.setDelegate(checkAdd);
         deviceStore.createOrUpdateDevice(PID, DID1, description);
         assertTrue("Add event fired", addLatch.await(1, TimeUnit.SECONDS));
@@ -783,7 +785,7 @@
 
         DeviceDescription description2 =
                 new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR,
-                        HW, SW2, SN);
+                        HW, SW2, SN, CID);
         deviceStore.unsetDelegate(checkAdd);
         deviceStore.setDelegate(checkUpdate);
         deviceStore.createOrUpdateDevice(PID, DID1, description2);
diff --git a/core/store/hz/net/src/main/java/org/onlab/onos/store/device/impl/DistributedDeviceStore.java b/core/store/hz/net/src/main/java/org/onlab/onos/store/device/impl/DistributedDeviceStore.java
index 0016939..894ee21 100644
--- a/core/store/hz/net/src/main/java/org/onlab/onos/store/device/impl/DistributedDeviceStore.java
+++ b/core/store/hz/net/src/main/java/org/onlab/onos/store/device/impl/DistributedDeviceStore.java
@@ -169,7 +169,7 @@
         DefaultDevice device = new DefaultDevice(providerId, deviceId, desc.type(),
                                                  desc.manufacturer(),
                                                  desc.hwVersion(), desc.swVersion(),
-                                                 desc.serialNumber());
+                                                 desc.serialNumber(), desc.chassisId());
 
         synchronized (this) {
             final byte[] deviceIdBytes = serialize(deviceId);
@@ -193,7 +193,8 @@
                                                       desc.manufacturer(),
                                                       desc.hwVersion(),
                                                       desc.swVersion(),
-                                                      desc.serialNumber());
+                                                      desc.serialNumber(),
+                                                      desc.chassisId());
             synchronized (this) {
                 final byte[] deviceIdBytes = serialize(device.id());
                 rawDevices.put(deviceIdBytes, serialize(updated));
diff --git a/core/store/hz/net/src/test/java/org/onlab/onos/store/device/impl/DistributedDeviceStoreTest.java b/core/store/hz/net/src/test/java/org/onlab/onos/store/device/impl/DistributedDeviceStoreTest.java
index 7e2924b..43e3bcf 100644
--- a/core/store/hz/net/src/test/java/org/onlab/onos/store/device/impl/DistributedDeviceStoreTest.java
+++ b/core/store/hz/net/src/test/java/org/onlab/onos/store/device/impl/DistributedDeviceStoreTest.java
@@ -40,6 +40,7 @@
 import com.google.common.collect.Sets;
 import com.hazelcast.config.Config;
 import com.hazelcast.core.Hazelcast;
+import org.onlab.packet.ChassisId;
 
 /**
  * Test of the Hazelcast based distributed DeviceStore implementation.
@@ -54,6 +55,7 @@
     private static final String SW1 = "3.8.1";
     private static final String SW2 = "3.9.5";
     private static final String SN = "43311-12345";
+    private static final ChassisId CID = new ChassisId();
 
     private static final PortNumber P1 = PortNumber.portNumber(1);
     private static final PortNumber P2 = PortNumber.portNumber(2);
@@ -95,7 +97,7 @@
     private void putDevice(DeviceId deviceId, String swVersion) {
         DeviceDescription description =
                 new DefaultDeviceDescription(deviceId.uri(), SWITCH, MFR,
-                        HW, swVersion, SN);
+                        HW, swVersion, SN, CID);
         deviceStore.createOrUpdateDevice(PID, deviceId, description);
     }
 
@@ -154,14 +156,14 @@
     public final void testCreateOrUpdateDevice() {
         DeviceDescription description =
                 new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR,
-                        HW, SW1, SN);
+                        HW, SW1, SN, CID);
         DeviceEvent event = deviceStore.createOrUpdateDevice(PID, DID1, description);
         assertEquals(DEVICE_ADDED, event.type());
         assertDevice(DID1, SW1, event.subject());
 
         DeviceDescription description2 =
                 new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR,
-                        HW, SW2, SN);
+                        HW, SW2, SN, CID);
         DeviceEvent event2 = deviceStore.createOrUpdateDevice(PID, DID1, description2);
         assertEquals(DEVICE_UPDATED, event2.type());
         assertDevice(DID1, SW2, event2.subject());
@@ -362,7 +364,7 @@
 
         DeviceDescription description =
                 new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR,
-                        HW, SW1, SN);
+                        HW, SW1, SN, CID);
         deviceStore.setDelegate(checkAdd);
         deviceStore.createOrUpdateDevice(PID, DID1, description);
         assertTrue("Add event fired", addLatch.await(1, TimeUnit.SECONDS));
@@ -370,7 +372,7 @@
 
         DeviceDescription description2 =
                 new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR,
-                        HW, SW2, SN);
+                        HW, SW2, SN, CID);
         deviceStore.unsetDelegate(checkAdd);
         deviceStore.setDelegate(checkUpdate);
         deviceStore.createOrUpdateDevice(PID, DID1, description2);
diff --git a/core/store/serializers/src/main/java/org/onlab/onos/store/serializers/KryoPoolUtil.java b/core/store/serializers/src/main/java/org/onlab/onos/store/serializers/KryoPoolUtil.java
index b44c102..1d9d8dc 100644
--- a/core/store/serializers/src/main/java/org/onlab/onos/store/serializers/KryoPoolUtil.java
+++ b/core/store/serializers/src/main/java/org/onlab/onos/store/serializers/KryoPoolUtil.java
@@ -27,6 +27,7 @@
 import org.onlab.onos.net.link.DefaultLinkDescription;
 import org.onlab.onos.net.provider.ProviderId;
 import org.onlab.onos.store.Timestamp;
+import org.onlab.packet.ChassisId;
 import org.onlab.packet.IpAddress;
 import org.onlab.packet.IpPrefix;
 import org.onlab.util.KryoPool;
@@ -61,6 +62,7 @@
                     //
                     ControllerNode.State.class,
                     Device.Type.class,
+                    ChassisId.class,
                     DefaultAnnotations.class,
                     DefaultControllerNode.class,
                     DefaultDevice.class,
diff --git a/core/store/serializers/src/test/java/org/onlab/onos/store/serializers/KryoSerializerTest.java b/core/store/serializers/src/test/java/org/onlab/onos/store/serializers/KryoSerializerTest.java
index 58956d5..1939a7e 100644
--- a/core/store/serializers/src/test/java/org/onlab/onos/store/serializers/KryoSerializerTest.java
+++ b/core/store/serializers/src/test/java/org/onlab/onos/store/serializers/KryoSerializerTest.java
@@ -26,6 +26,7 @@
 import org.onlab.onos.net.PortNumber;
 import org.onlab.onos.net.SparseAnnotations;
 import org.onlab.onos.net.provider.ProviderId;
+import org.onlab.packet.ChassisId;
 import org.onlab.packet.IpAddress;
 import org.onlab.packet.IpPrefix;
 import org.onlab.util.KryoPool;
@@ -49,7 +50,9 @@
     private static final String SW1 = "3.8.1";
     private static final String SW2 = "3.9.5";
     private static final String SN = "43311-12345";
-    private static final Device DEV1 = new DefaultDevice(PID, DID1, Device.Type.SWITCH, MFR, HW, SW1, SN);
+    private static final ChassisId CID = new ChassisId();
+    private static final Device DEV1 = new DefaultDevice(PID, DID1, Device.Type.SWITCH, MFR, HW,
+                                                         SW1, SN, CID);
     private static final SparseAnnotations A1 = DefaultAnnotations.builder()
             .set("A1", "a1")
             .set("B1", "b1")
diff --git a/core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleDeviceStore.java b/core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleDeviceStore.java
index 514a22e..3fefbfd 100644
--- a/core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleDeviceStore.java
+++ b/core/store/trivial/src/main/java/org/onlab/onos/store/trivial/impl/SimpleDeviceStore.java
@@ -30,6 +30,7 @@
 import org.onlab.onos.net.device.PortDescription;
 import org.onlab.onos.net.provider.ProviderId;
 import org.onlab.onos.store.AbstractStore;
+import org.onlab.packet.ChassisId;
 import org.onlab.util.NewConcurrentHashMap;
 import org.slf4j.Logger;
 
@@ -404,6 +405,7 @@
         String hwVersion = base.hwVersion();
         String swVersion = base.swVersion();
         String serialNumber = base.serialNumber();
+        ChassisId chassisId = base.chassisId();
         DefaultAnnotations annotations = DefaultAnnotations.builder().build();
         annotations = merge(annotations, base.annotations());
 
@@ -421,7 +423,8 @@
         }
 
         return new DefaultDevice(primary, deviceId , type, manufacturer,
-                            hwVersion, swVersion, serialNumber, annotations);
+                            hwVersion, swVersion, serialNumber,
+                            chassisId, annotations);
     }
 
     /**
diff --git a/core/store/trivial/src/test/java/org/onlab/onos/store/trivial/impl/DefaultTopologyTest.java b/core/store/trivial/src/test/java/org/onlab/onos/store/trivial/impl/DefaultTopologyTest.java
index ef383c8..879f123 100644
--- a/core/store/trivial/src/test/java/org/onlab/onos/store/trivial/impl/DefaultTopologyTest.java
+++ b/core/store/trivial/src/test/java/org/onlab/onos/store/trivial/impl/DefaultTopologyTest.java
@@ -17,6 +17,7 @@
 import org.onlab.onos.net.topology.LinkWeight;
 import org.onlab.onos.net.topology.TopologyCluster;
 import org.onlab.onos.net.topology.TopologyEdge;
+import org.onlab.packet.ChassisId;
 
 import java.util.Set;
 
@@ -119,7 +120,7 @@
     // Crates a new device with the specified id
     public static Device device(String id) {
         return new DefaultDevice(PID, did(id), Device.Type.SWITCH,
-                                 "mfg", "1.0", "1.1", "1234");
+                                 "mfg", "1.0", "1.1", "1234", new ChassisId());
     }
 
     // Short-hand for producing a device id from a string
diff --git a/core/store/trivial/src/test/java/org/onlab/onos/store/trivial/impl/SimpleDeviceStoreTest.java b/core/store/trivial/src/test/java/org/onlab/onos/store/trivial/impl/SimpleDeviceStoreTest.java
index 146086a..8338a77 100644
--- a/core/store/trivial/src/test/java/org/onlab/onos/store/trivial/impl/SimpleDeviceStoreTest.java
+++ b/core/store/trivial/src/test/java/org/onlab/onos/store/trivial/impl/SimpleDeviceStoreTest.java
@@ -40,6 +40,7 @@
 
 import com.google.common.collect.Iterables;
 import com.google.common.collect.Sets;
+import org.onlab.packet.ChassisId;
 
 /**
  * Test of the simple DeviceStore implementation.
@@ -55,6 +56,7 @@
     private static final String SW1 = "3.8.1";
     private static final String SW2 = "3.9.5";
     private static final String SN = "43311-12345";
+    private static final ChassisId CID = new ChassisId();
 
     private static final PortNumber P1 = PortNumber.portNumber(1);
     private static final PortNumber P2 = PortNumber.portNumber(2);
@@ -107,7 +109,7 @@
                            SparseAnnotations... annotations) {
         DeviceDescription description =
                 new DefaultDeviceDescription(deviceId.uri(), SWITCH, MFR,
-                        HW, swVersion, SN, annotations);
+                        HW, swVersion, SN, CID, annotations);
         deviceStore.createOrUpdateDevice(PID, deviceId, description);
     }
 
@@ -115,7 +117,7 @@
                                     SparseAnnotations... annotations) {
         DeviceDescription description =
                 new DefaultDeviceDescription(deviceId.uri(), SWITCH, MFR,
-                        HW, swVersion, SN, annotations);
+                        HW, swVersion, SN, CID, annotations);
         deviceStore.createOrUpdateDevice(PIDA, deviceId, description);
     }
 
@@ -193,14 +195,14 @@
     public final void testCreateOrUpdateDevice() {
         DeviceDescription description =
                 new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR,
-                        HW, SW1, SN);
+                        HW, SW1, SN, CID);
         DeviceEvent event = deviceStore.createOrUpdateDevice(PID, DID1, description);
         assertEquals(DEVICE_ADDED, event.type());
         assertDevice(DID1, SW1, event.subject());
 
         DeviceDescription description2 =
                 new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR,
-                        HW, SW2, SN);
+                        HW, SW2, SN, CID);
         DeviceEvent event2 = deviceStore.createOrUpdateDevice(PID, DID1, description2);
         assertEquals(DEVICE_UPDATED, event2.type());
         assertDevice(DID1, SW2, event2.subject());
@@ -212,7 +214,7 @@
     public final void testCreateOrUpdateDeviceAncillary() {
         DeviceDescription description =
                 new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR,
-                        HW, SW1, SN, A2);
+                        HW, SW1, SN, CID, A2);
         DeviceEvent event = deviceStore.createOrUpdateDevice(PIDA, DID1, description);
         assertEquals(DEVICE_ADDED, event.type());
         assertDevice(DID1, SW1, event.subject());
@@ -222,7 +224,7 @@
 
         DeviceDescription description2 =
                 new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR,
-                        HW, SW2, SN, A1);
+                        HW, SW2, SN, CID, A1);
         DeviceEvent event2 = deviceStore.createOrUpdateDevice(PID, DID1, description2);
         assertEquals(DEVICE_UPDATED, event2.type());
         assertDevice(DID1, SW2, event2.subject());
@@ -238,7 +240,7 @@
         // But, Ancillary annotations will be in effect
         DeviceDescription description3 =
                 new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR,
-                        HW, SW1, SN, A2_2);
+                        HW, SW1, SN, CID, A2_2);
         DeviceEvent event3 = deviceStore.createOrUpdateDevice(PIDA, DID1, description3);
         assertEquals(DEVICE_UPDATED, event3.type());
         // basic information will be the one from Primary
@@ -508,7 +510,7 @@
 
         DeviceDescription description =
                 new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR,
-                        HW, SW1, SN);
+                        HW, SW1, SN, CID);
         deviceStore.setDelegate(checkAdd);
         deviceStore.createOrUpdateDevice(PID, DID1, description);
         assertTrue("Add event fired", addLatch.await(1, TimeUnit.SECONDS));
@@ -516,7 +518,7 @@
 
         DeviceDescription description2 =
                 new DefaultDeviceDescription(DID1.uri(), SWITCH, MFR,
-                        HW, SW2, SN);
+                        HW, SW2, SN, CID);
         deviceStore.unsetDelegate(checkAdd);
         deviceStore.setDelegate(checkUpdate);
         deviceStore.createOrUpdateDevice(PID, DID1, description2);