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 3e5dc21..029108a 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,7 @@
     @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", "innerVlan", "outerTpid"};
 
     /**
      * Get all end-station hosts.
@@ -221,6 +222,7 @@
             MacAddress mac = MacAddress.valueOf(node.get("mac").asText());
             VlanId vlanId = VlanId.vlanId((short) node.get("vlan").asInt(VlanId.UNTAGGED));
 
+            // Parse locations
             Iterator<JsonNode> locationNodes = node.get("locations").elements();
             Set<HostLocation> locations = new HashSet<>();
             while (locationNodes.hasNext()) {
@@ -231,18 +233,29 @@
                 locations.add(hostLocation);
             }
 
+            // Parse ipAddresses
             Iterator<JsonNode> ipNodes = node.get("ipAddresses").elements();
             Set<IpAddress> ips = new HashSet<>();
             while (ipNodes.hasNext()) {
                 ips.add(IpAddress.valueOf(ipNodes.next().asText()));
             }
 
+            // 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,
+                    ips, innerVlan, outerTpid, true, annotations);
             hostProviderService.hostDetected(hostId, desc, false);
             return hostId;
         }
diff --git a/web/api/src/main/resources/definitions/Host.json b/web/api/src/main/resources/definitions/Host.json
index b29e828..d8606a6 100644
--- a/web/api/src/main/resources/definitions/Host.json
+++ b/web/api/src/main/resources/definitions/Host.json
@@ -52,6 +52,14 @@
           }
         }
       }
+    },
+    "innerVlan": {
+      "type": "string",
+      "example": "-1"
+    },
+    "outerTpid": {
+      "type": "string",
+      "example": "unknown"
     }
   }
 }
\ No newline at end of file
diff --git a/web/api/src/main/resources/definitions/HostPut.json b/web/api/src/main/resources/definitions/HostPut.json
index 26e1c41..395cb33 100644
--- a/web/api/src/main/resources/definitions/HostPut.json
+++ b/web/api/src/main/resources/definitions/HostPut.json
@@ -47,6 +47,16 @@
           }
         }
       }
+    },
+    "innerVlan": {
+      "required": false,
+      "type": "string",
+      "example": "10"
+    },
+    "outerTpid": {
+      "required": false,
+      "type": "string",
+      "example": "0x88a8"
     }
   }
 }
\ No newline at end of file
diff --git a/web/api/src/main/resources/definitions/Hosts.json b/web/api/src/main/resources/definitions/Hosts.json
index 3615ba4..5adef94 100644
--- a/web/api/src/main/resources/definitions/Hosts.json
+++ b/web/api/src/main/resources/definitions/Hosts.json
@@ -65,6 +65,14 @@
                 }
               }
             }
+          },
+          "innerVlan": {
+            "type": "string",
+            "example": "-1"
+          },
+          "outerTpid": {
+            "type": "string",
+            "example": "unknown"
           }
         }
       }