[ONOS-4747] NETCONF function for FUJITSU OLT #2

 - Enhanced device-setcontrollers command to apply additional key-value pair.
    e.g. onos> device-setcontrollers netconf:10.10.1.11:830 tcp:10.10.1.11:6630,ofconfig-id=1

Change-Id: I2cb5941dbd9829ade6fa89d5546bbc6aab44f83f
diff --git a/cli/src/main/java/org/onosproject/cli/net/DeviceSetControllersCommand.java b/cli/src/main/java/org/onosproject/cli/net/DeviceSetControllersCommand.java
index 556dcc9..5d0707d 100644
--- a/cli/src/main/java/org/onosproject/cli/net/DeviceSetControllersCommand.java
+++ b/cli/src/main/java/org/onosproject/cli/net/DeviceSetControllersCommand.java
@@ -18,7 +18,10 @@
 
 import org.apache.karaf.shell.commands.Argument;
 import org.apache.karaf.shell.commands.Command;
+import org.onlab.packet.IpAddress;
 import org.onosproject.cli.AbstractShellCommand;
+import org.onosproject.net.Annotations;
+import org.onosproject.net.DefaultAnnotations;
 import org.onosproject.net.DeviceId;
 import org.onosproject.net.behaviour.ControllerConfig;
 import org.onosproject.net.behaviour.ControllerInfo;
@@ -52,7 +55,7 @@
     protected void execute() {
 
         Arrays.asList(controllersListStrings).forEach(
-                cInfoString -> newControllers.add(new ControllerInfo(cInfoString)));
+                cInfoString -> newControllers.add(parseCInfoString(cInfoString)));
         DriverService service = get(DriverService.class);
         deviceId = DeviceId.deviceId(uri);
         DriverHandler h = service.createHandler(deviceId);
@@ -69,4 +72,31 @@
         print("size %d", config.getControllers().size());
     }
 
+
+    private ControllerInfo parseCInfoString(String cInfoString) {
+        Annotations annotation;
+
+        String[] config = cInfoString.split(",");
+        if (config.length == 2) {
+            String[] pair = config[1].split("=");
+
+            if (pair.length == 2) {
+                annotation = DefaultAnnotations.builder()
+                        .set(pair[0], pair[1]).build();
+            } else {
+                print("Wrong format {}", config[1]);
+                return null;
+            }
+
+            String[] data = config[0].split(":");
+            String type = data[0];
+            IpAddress ip = IpAddress.valueOf(data[1]);
+            int port = Integer.parseInt(data[2]);
+
+            return new ControllerInfo(ip, port, type, annotation);
+        } else {
+            print(config[0]);
+            return new ControllerInfo(config[0]);
+        }
+    }
 }