Introduced HOST_AUX_MOVED event

Additionally,
- Fixed an issue in DistributedHostStore that didn't copy innverVlan, tpid and suspend bit correctly in some cases
- Clarified javadoc of getConnectedHosts

Change-Id: I56c93eea878a24a6588ceecdbeac75c1747ae8cc
diff --git a/core/api/src/main/java/org/onosproject/net/host/DefaultHostDescription.java b/core/api/src/main/java/org/onosproject/net/host/DefaultHostDescription.java
index c83c2c1..74fa9f4 100644
--- a/core/api/src/main/java/org/onosproject/net/host/DefaultHostDescription.java
+++ b/core/api/src/main/java/org/onosproject/net/host/DefaultHostDescription.java
@@ -18,6 +18,7 @@
 import java.util.Collections;
 import java.util.Comparator;
 import java.util.HashSet;
+import java.util.Objects;
 import java.util.Set;
 
 import org.onlab.packet.EthType;
@@ -31,7 +32,6 @@
 import com.google.common.collect.ImmutableSet;
 
 import static com.google.common.base.MoreObjects.toStringHelper;
-import com.google.common.base.Objects;
 
 /**
  * Default implementation of an immutable host description.
@@ -42,6 +42,7 @@
     private final MacAddress mac;
     private final VlanId vlan;
     private final Set<HostLocation> locations;
+    private final Set<HostLocation> auxLocations;
     private final Set<IpAddress> ip;
     private final VlanId innerVlan;
     private final EthType tpid;
@@ -157,10 +158,31 @@
     public DefaultHostDescription(MacAddress mac, VlanId vlan, Set<HostLocation> locations,
                                   Set<IpAddress> ip, VlanId innerVlan, EthType tpid,
                                   boolean configured, SparseAnnotations... annotations) {
+        this(mac, vlan, locations, null, ip, innerVlan, tpid, configured, annotations);
+    }
+
+    /**
+     * Creates a host description using the supplied information.
+     *
+     * @param mac          host MAC address
+     * @param vlan         host VLAN identifier
+     * @param locations    host locations
+     * @param auxLocations  set of auxiliary locations, or null if unspecified
+     * @param ip           host IP address
+     * @param innerVlan    host inner VLAN identifier
+     * @param tpid         outer TPID of a host
+     * @param configured   true if configured via NetworkConfiguration
+     * @param annotations  optional key/value annotations map
+     */
+    public DefaultHostDescription(MacAddress mac, VlanId vlan,
+                                  Set<HostLocation> locations, Set<HostLocation> auxLocations,
+                                  Set<IpAddress> ip, VlanId innerVlan, EthType tpid,
+                                  boolean configured, SparseAnnotations... annotations) {
         super(annotations);
         this.mac = mac;
         this.vlan = vlan;
         this.locations = new HashSet<>(locations);
+        this.auxLocations = (auxLocations != null) ? new HashSet<>(auxLocations) : null;
         this.ip = new HashSet<>(ip);
         this.innerVlan = innerVlan;
         this.tpid = tpid;
@@ -212,6 +234,11 @@
     }
 
     @Override
+    public Set<HostLocation> auxLocations() {
+        return auxLocations;
+    }
+
+    @Override
     public Set<IpAddress> ipAddress() {
         return ip;
     }
@@ -237,6 +264,7 @@
                 .add("mac", mac)
                 .add("vlan", vlan)
                 .add("locations", locations)
+                .add("auxLocations", auxLocations)
                 .add("ipAddress", ip)
                 .add("configured", configured)
                 .add("innerVlanId", innerVlan)
@@ -246,7 +274,7 @@
 
     @Override
     public int hashCode() {
-        return Objects.hashCode(super.hashCode(), mac, vlan, locations, ip);
+        return Objects.hash(super.hashCode(), mac, vlan, locations, auxLocations, ip);
     }
 
     @Override
@@ -256,12 +284,13 @@
                 return false;
             }
             DefaultHostDescription that = (DefaultHostDescription) object;
-            return Objects.equal(this.mac, that.mac)
-                    && Objects.equal(this.vlan, that.vlan)
-                    && Objects.equal(this.locations, that.locations)
-                    && Objects.equal(this.ip, that.ip)
-                    && Objects.equal(this.innerVlan, that.innerVlan)
-                    && Objects.equal(this.tpid, that.tpid);
+            return Objects.equals(this.mac, that.mac)
+                    && Objects.equals(this.vlan, that.vlan)
+                    && Objects.equals(this.locations, that.locations)
+                    && Objects.equals(this.auxLocations, that.auxLocations)
+                    && Objects.equals(this.ip, that.ip)
+                    && Objects.equals(this.innerVlan, that.innerVlan)
+                    && Objects.equals(this.tpid, that.tpid);
         }
         return false;
     }
diff --git a/core/api/src/main/java/org/onosproject/net/host/HostDescription.java b/core/api/src/main/java/org/onosproject/net/host/HostDescription.java
index 543836e..322b57d 100644
--- a/core/api/src/main/java/org/onosproject/net/host/HostDescription.java
+++ b/core/api/src/main/java/org/onosproject/net/host/HostDescription.java
@@ -76,6 +76,13 @@
     Set<HostLocation> locations();
 
     /**
+     * Returns host auxiliary locations, which could be useful for app operations in addition to the attach points.
+     *
+     * @return auxiliary locations, or null if unspecified
+     */
+    Set<HostLocation> auxLocations();
+
+    /**
      * Returns the IP address associated with this host's MAC.
      *
      * @return host IP address
diff --git a/core/api/src/main/java/org/onosproject/net/host/HostEvent.java b/core/api/src/main/java/org/onosproject/net/host/HostEvent.java
index 0fecf2b..132ac11 100644
--- a/core/api/src/main/java/org/onosproject/net/host/HostEvent.java
+++ b/core/api/src/main/java/org/onosproject/net/host/HostEvent.java
@@ -56,7 +56,11 @@
         /**
          * Signifies that host state in non offending state.
          */
-        HOST_UNSUSPENDED
+        HOST_UNSUSPENDED,
+        /**
+         * Signifies that host auxiliary location has changed.
+         */
+        HOST_AUX_MOVED
     }
 
     private Host prevSubject;
@@ -94,7 +98,7 @@
      */
     public HostEvent(Type type, Host host, Host prevSubject) {
         super(type, host);
-        if (type == Type.HOST_MOVED || type == Type.HOST_UPDATED) {
+        if (type == Type.HOST_MOVED || type == Type.HOST_UPDATED || type == Type.HOST_AUX_MOVED) {
             this.prevSubject = prevSubject;
         }
     }
diff --git a/core/api/src/main/java/org/onosproject/net/host/HostService.java b/core/api/src/main/java/org/onosproject/net/host/HostService.java
index 55532bc..349f6db 100644
--- a/core/api/src/main/java/org/onosproject/net/host/HostService.java
+++ b/core/api/src/main/java/org/onosproject/net/host/HostService.java
@@ -81,8 +81,7 @@
     // TODO: consider adding Host getHostByIp(IpAddress ip, VlanId vlan);
 
     /**
-     * Returns the set of hosts whose most recent location is the specified
-     * connection point.
+     * Returns the set of hosts that attach to the specified connection point.
      *
      * @param connectPoint connection point
      * @return set of hosts connected to the connection point
@@ -90,8 +89,7 @@
     Set<Host> getConnectedHosts(ConnectPoint connectPoint);
 
     /**
-     * Returns the set of hosts whose most recent location is the specified
-     * infrastructure device.
+     * Returns the set of hosts that attach to the specified device.
      *
      * @param deviceId device identifier
      * @return set of hosts connected to the device
diff --git a/core/api/src/main/java/org/onosproject/net/host/HostStore.java b/core/api/src/main/java/org/onosproject/net/host/HostStore.java
index 6d6eb11..b6b27b5 100644
--- a/core/api/src/main/java/org/onosproject/net/host/HostStore.java
+++ b/core/api/src/main/java/org/onosproject/net/host/HostStore.java
@@ -127,7 +127,7 @@
     Set<Host> getHosts(IpAddress ip);
 
     /**
-     * Returns the set of hosts whose location falls on the given connection point.
+     * Returns the set of hosts that attach to the specified connection point.
      *
      * @param connectPoint connection point
      * @return set of hosts
@@ -135,7 +135,7 @@
     Set<Host> getConnectedHosts(ConnectPoint connectPoint);
 
     /**
-     * Returns the set of hosts whose location falls on the given device.
+     * Returns the set of hosts that attach to the specified device.
      *
      * @param deviceId infrastructure device identifier
      * @return set of hosts