Allow to inject external_id field when creating an OVSDB interface

Change-Id: Iabc69771ac5dd1a321f8c9cc440fa2e166965a17
diff --git a/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java b/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java
index 6d08bcb..5914dc7 100644
--- a/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java
+++ b/protocols/ovsdb/api/src/main/java/org/onosproject/ovsdb/controller/driver/DefaultOvsdbClient.java
@@ -1097,7 +1097,6 @@
 
         if (getPortUuid(ovsdbIface.name(), bridgeUuid) != null) {
             log.warn("Interface {} already exists", ovsdbIface.name());
-            // remove existing one and re-create?
             return false;
         }
 
@@ -1118,11 +1117,12 @@
         List<Mutation> mutations = Lists.newArrayList(mutation);
         operations.add(new Mutate(dbSchema.getTableSchema(BRIDGE), conditions, mutations));
 
-        // insert an interface
         Interface intf = (Interface) TableGenerator.createTable(dbSchema, OvsdbTable.INTERFACE);
         intf.setName(ovsdbIface.name());
 
-        intf.setType(ovsdbIface.typeToString());
+        if (ovsdbIface.type() != null) {
+            intf.setType(ovsdbIface.typeToString());
+        }
 
         if (ovsdbIface.mtu().isPresent()) {
             Set<Long> mtuSet = Sets.newConcurrentHashSet();
@@ -1132,6 +1132,13 @@
         }
 
         intf.setOptions(ovsdbIface.options());
+
+        ovsdbIface.data().forEach((k, v) -> {
+            if (k == Interface.InterfaceColumn.EXTERNALIDS) {
+                intf.setExternalIds(v);
+            }
+        });
+
         Insert intfInsert = new Insert(dbSchema.getTableSchema(INTERFACE), INTERFACE, intf.getRow());
         operations.add(intfInsert);
 
@@ -1990,4 +1997,4 @@
         // behavior.
         return Futures.transform(input, function, MoreExecutors.directExecutor());
     }
-}
+}
\ No newline at end of file