Supported recently introduced fields in HostsWebResource

Change-Id: I3bc3fd272008388326041540c10e8a103b01c02c
diff --git a/web/api/src/main/java/org/onosproject/rest/resources/HostsWebResource.java b/web/api/src/main/java/org/onosproject/rest/resources/HostsWebResource.java
index 34e13ca..6bdd483 100644
--- a/web/api/src/main/java/org/onosproject/rest/resources/HostsWebResource.java
+++ b/web/api/src/main/java/org/onosproject/rest/resources/HostsWebResource.java
@@ -18,6 +18,7 @@
 import com.fasterxml.jackson.databind.JsonNode;
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ObjectNode;
+import org.onlab.packet.EthType;
 import org.onlab.packet.IpAddress;
 import org.onlab.packet.MacAddress;
 import org.onlab.packet.VlanId;
@@ -69,7 +70,8 @@
     @Context
     private UriInfo uriInfo;
     private static final String HOST_NOT_FOUND = "Host is not found";
-    private static final String[] REMOVAL_KEYS = {"mac", "vlan", "locations", "ipAddresses"};
+    private static final String[] REMOVAL_KEYS = {"mac", "vlan", "locations", "ipAddresses",
+            "auxLocations", "innerVlan", "outerTpid"};
 
     /**
      * Get all end-station hosts.
@@ -222,10 +224,10 @@
             MacAddress mac = MacAddress.valueOf(node.get("mac").asText());
             VlanId vlanId = VlanId.vlanId((short) node.get("vlan").asInt(VlanId.UNTAGGED));
 
+            // Parse locations
             if (null == node.get("locations")) {
                 throw new IllegalArgumentException("location isn't specified");
             }
-
             Iterator<JsonNode> locationNodes = node.get("locations").elements();
             Set<HostLocation> locations = new HashSet<>();
             while (locationNodes.hasNext()) {
@@ -236,22 +238,49 @@
                 locations.add(hostLocation);
             }
 
+            // Parse ipAddresses
             if (null == node.get("ipAddresses")) {
                 throw new IllegalArgumentException("ipAddress isn't specified");
             }
-
             Iterator<JsonNode> ipNodes = node.get("ipAddresses").elements();
             Set<IpAddress> ips = new HashSet<>();
             while (ipNodes.hasNext()) {
                 ips.add(IpAddress.valueOf(ipNodes.next().asText()));
             }
 
+            // Parse auxLocations
+            Set<HostLocation> auxLocations;
+            JsonNode auxLocationsNode = node.get("auxLocations");
+            if (null == auxLocationsNode) {
+                auxLocations = null;
+            } else {
+                Iterator<JsonNode> auxLocationNodes = auxLocationsNode.elements();
+                auxLocations = new HashSet<>();
+                while (auxLocationNodes.hasNext()) {
+                    JsonNode auxLocationNode = auxLocationNodes.next();
+                    String deviceAndPort = auxLocationNode.get("elementId").asText() + "/" +
+                            auxLocationNode.get("port").asText();
+                    HostLocation auxLocation = new HostLocation(ConnectPoint.deviceConnectPoint(deviceAndPort), 0);
+                    auxLocations.add(auxLocation);
+                }
+            }
+
+            // Parse innerVlan
+            JsonNode innerVlanNode = node.get("innerVlan");
+            VlanId innerVlan = (null == innerVlanNode) ? VlanId.NONE : VlanId.vlanId(innerVlanNode.asText());
+
+            // Parse outerTpid
+            JsonNode outerTpidNode = node.get("outerTpid");
+            EthType outerTpid = (null == outerTpidNode) ? EthType.EtherType.UNKNOWN.ethType() :
+                    EthType.EtherType.lookup((short) (Integer.decode(outerTpidNode.asText()) & 0xFFFF)).ethType();
+
             // try to remove elements from json node after reading them
             SparseAnnotations annotations = annotations(removeElements(node, REMOVAL_KEYS));
             // Update host inventory
 
             HostId hostId = HostId.hostId(mac, vlanId);
-            DefaultHostDescription desc = new DefaultHostDescription(mac, vlanId, locations, ips, true, annotations);
+            DefaultHostDescription desc = new DefaultHostDescription(mac, vlanId, locations, auxLocations,
+                    ips, innerVlan, outerTpid, true, annotations);
             hostProviderService.hostDetected(hostId, desc, false);
             return hostId;
         }