[ONOS-7269] Additional annotation about OpenFlow port status

Change-Id: I9a1b3cede47316c372322af68dc652d4f372f9fb
diff --git a/core/api/src/main/java/org/onosproject/net/AnnotationKeys.java b/core/api/src/main/java/org/onosproject/net/AnnotationKeys.java
index da93417..550899b 100644
--- a/core/api/src/main/java/org/onosproject/net/AnnotationKeys.java
+++ b/core/api/src/main/java/org/onosproject/net/AnnotationKeys.java
@@ -137,6 +137,13 @@
     public static final String PORT_MAC = "portMac";
 
     /**
+     * Annotation key for the admin state.
+     * The value of this key is expected to be "enabled" or "disabled"
+     *
+     */
+    public static final String ADMIN_STATE = "adminState";
+
+    /**
      * Annotation key for the router ID.
      */
     public static final String ROUTER_ID = "routerId";
diff --git a/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java b/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
index 51213de..b303308 100644
--- a/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
+++ b/providers/openflow/device/src/main/java/org/onosproject/provider/of/device/impl/OpenFlowDeviceProvider.java
@@ -725,7 +725,10 @@
             PortNumber portNo = PortNumber.portNumber(port.getPortNo().getPortNumber());
             boolean enabled = !port.getState().contains(OFPortState.LINK_DOWN)
                     && !port.getConfig().contains(OFPortConfig.PORT_DOWN);
-            SparseAnnotations annotations = makePortAnnotation(port.getName(), port.getHwAddr().toString()).build();
+            boolean adminDown = port.getConfig().contains(OFPortConfig.PORT_DOWN);
+            SparseAnnotations annotations = makePortAnnotation(port.getName(),
+                                                               port.getHwAddr().toString(),
+                                                               adminDown).build();
 
             OFExpPortDescPropOpticalTransport firstProp = port.getProperties().get(0);
             OFPortOpticalTransportSignalType sigType = firstProp.getPortSignalType();
@@ -789,10 +792,11 @@
          *
          * @param portName the port name
          * @param portMac the port mac
-         * @return annotation builder containing port name and/or port MAC if any of
-         *          the two is found, empty otherwise
+         * @param adminDown the port admin state
+         * @return annotation builder containing port admin state, port name
+         *          and/or port MAC if any of the two is found
          */
-        private DefaultAnnotations.Builder makePortAnnotation(String portName, String portMac) {
+        private DefaultAnnotations.Builder makePortAnnotation(String portName, String portMac, boolean adminDown) {
             DefaultAnnotations.Builder builder = DefaultAnnotations.builder();
             String pName = Strings.emptyToNull(portName);
             String pMac = Strings.emptyToNull(portMac);
@@ -802,6 +806,8 @@
             if (pMac != null) {
                 builder.set(AnnotationKeys.PORT_MAC, pMac);
             }
+            String adminState = adminDown ? "disabled" : "enabled";
+            builder.set(AnnotationKeys.ADMIN_STATE, adminState);
             return builder;
         }
 
@@ -825,8 +831,10 @@
             boolean enabled =
                     !port.getState().contains(OFPortState.LINK_DOWN) &&
                     !port.getConfig().contains(OFPortConfig.PORT_DOWN);
+            boolean adminDown = port.getConfig().contains(OFPortConfig.PORT_DOWN);
             Builder annotations = makePortAnnotation(port.getName(),
-                                                     port.getHwAddr().toString());
+                                                               port.getHwAddr().toString(),
+                                                               adminDown);
 
             Optional<OFPortDescPropEthernet> ether = port.getProperties().stream()
                 .filter(OFPortDescPropEthernet.class::isInstance)
@@ -940,7 +948,10 @@
                     !port.getState().contains(OFPortState.LINK_DOWN) &&
                             !port.getConfig().contains(OFPortConfig.PORT_DOWN);
             Port.Type type = port.getCurr().contains(OFPortFeatures.PF_FIBER) ? FIBER : COPPER;
-            SparseAnnotations annotations = makePortAnnotation(port.getName(), port.getHwAddr().toString()).build();
+            boolean adminDown = port.getConfig().contains(OFPortConfig.PORT_DOWN);
+            SparseAnnotations annotations = makePortAnnotation(port.getName(),
+                                                               port.getHwAddr().toString(),
+                                                               adminDown).build();
             return new DefaultPortDescription(portNo, enabled, type,
                                               portSpeed(port), annotations);
         }
@@ -962,7 +973,10 @@
 
             boolean enabled = !port.getState().contains(OFPortState.LINK_DOWN)
                     && !port.getConfig().contains(OFPortConfig.PORT_DOWN);
-            SparseAnnotations annotations = makePortAnnotation(port.getName(), port.getHwAddr().toString()).build();
+            boolean adminDown = port.getConfig().contains(OFPortConfig.PORT_DOWN);
+            SparseAnnotations annotations = makePortAnnotation(port.getName(),
+                                                               port.getHwAddr().toString(),
+                                                               adminDown).build();
 
             if (port.getVersion() == OFVersion.OF_13
                     && ptype == PortDescPropertyType.OPTICAL_TRANSPORT) {
@@ -1040,7 +1054,8 @@
 
             // FIXME when Calient OF agent reports port status
             boolean enabled = true;
-            SparseAnnotations annotations = makePortAnnotation(name, port.getHwAddr().toString()).build();
+            boolean adminDown = false;
+            SparseAnnotations annotations = makePortAnnotation(name, port.getHwAddr().toString(), adminDown).build();
 
             // S160 data sheet
             // Wavelength range: 1260 - 1630 nm, grid is irrelevant for this type of switch