Adding driver information and short version to cli print of devices and hosts

Change-Id: I1ab9e9865c499240256aa72760b225976e0f19d2
diff --git a/cli/src/main/java/org/onosproject/cli/AbstractShellCommand.java b/cli/src/main/java/org/onosproject/cli/AbstractShellCommand.java
index 8945d62..6305f76 100644
--- a/cli/src/main/java/org/onosproject/cli/AbstractShellCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/AbstractShellCommand.java
@@ -29,6 +29,9 @@
 import com.fasterxml.jackson.databind.ObjectMapper;
 import com.fasterxml.jackson.databind.node.ObjectNode;
 
+import java.util.Set;
+import java.util.TreeSet;
+
 /**
  * Base abstraction of Karaf shell commands.
  */
@@ -95,6 +98,24 @@
     }
 
     /**
+     * Produces a string image of the specified key/value annotations.
+     * Excludes the keys in the given Set.
+     *
+     * @param annotations  key/value annotations
+     * @param excludedKeys keys not to add in the resulting string
+     * @return string image with ", k1=v1, k2=v2, ..." pairs
+     */
+    public static String annotations(Annotations annotations, Set<String> excludedKeys) {
+        StringBuilder sb = new StringBuilder();
+        Set<String> keys = new TreeSet<>(annotations.keys());
+        keys.removeAll(excludedKeys);
+        for (String key : keys) {
+            sb.append(", ").append(key).append('=').append(annotations.value(key));
+        }
+        return sb.toString();
+    }
+
+    /**
      * Produces a JSON object from the specified key/value annotations.
      *
      * @param mapper ObjectMapper to use while converting to JSON