ONOS-3931: BasicDeviceConfig to allow configuration of  DeviceKeyId

Change-Id: I75d37709f19913f3382fa7614291e5a837ecf1a1
diff --git a/core/api/src/main/java/org/onosproject/net/config/basics/BasicDeviceConfig.java b/core/api/src/main/java/org/onosproject/net/config/basics/BasicDeviceConfig.java
index 77073cb..097dc77 100644
--- a/core/api/src/main/java/org/onosproject/net/config/basics/BasicDeviceConfig.java
+++ b/core/api/src/main/java/org/onosproject/net/config/basics/BasicDeviceConfig.java
@@ -17,7 +17,7 @@
 
 import org.onosproject.net.Device;
 import org.onosproject.net.DeviceId;
-
+import org.onosproject.net.key.DeviceKeyId;
 /**
  * Basic configuration for network infrastructure devices.
  */
@@ -30,12 +30,13 @@
     private static final String HW_VERSION = "hwVersion";
     private static final String SW_VERSION = "swVersion";
     private static final String SERIAL = "serial";
+    private static final String DEVICE_KEY_ID = "deviceKeyId";
 
     @Override
     public boolean isValid() {
         return hasOnlyFields(ALLOWED, NAME, LATITUDE, LONGITUDE, RACK_ADDRESS, OWNER,
                              TYPE, DRIVER, MANUFACTURER, HW_VERSION, SW_VERSION, SERIAL,
-                             MANAGEMENT_ADDRESS);
+                             MANAGEMENT_ADDRESS, DEVICE_KEY_ID);
     }
 
     /**
@@ -162,7 +163,7 @@
     }
 
     /**
-     * Sets the driver name.
+     * Sets the device management ip (ip:port).
      *
      * @param managementAddress new device management address (ip:port); null to clear
      * @return self
@@ -171,6 +172,27 @@
         return (BasicDeviceConfig) setOrClear(MANAGEMENT_ADDRESS, managementAddress);
     }
 
+    /**
+     * Returns the device key id.
+     *
+     * @return device key id or null if not set
+     */
+    public DeviceKeyId deviceKeyId() {
+        String s = get(DEVICE_KEY_ID, null);
+        return s == null ? null : DeviceKeyId.deviceKeyId(s);
+    }
+
+    /**
+     * Sets the device key id.
+     *
+     * @param deviceKeyId new device key id; null to clear
+     * @return self
+     */
+    public BasicDeviceConfig deviceKeyId(DeviceKeyId deviceKeyId) {
+        return (BasicDeviceConfig) setOrClear(DEVICE_KEY_ID,
+                                              deviceKeyId != null ? deviceKeyId.id() : null);
+    }
+
     // TODO: device port meta-data to be configured via BasicPortsConfig
     // TODO: device credentials/keys; in a separate config