Fixes two things in OpenstackNode App. - Add whether ovsdb connection is alive in OpenstackNodeCheckCommand - Support REST API that queries the state of the specific openstack node

Change-Id: I96e7d8ff2ef2a0e03aa62454c0346a3dfa1597d1
diff --git a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/web/OpenstackNodeWebResource.java b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/web/OpenstackNodeWebResource.java
index c64cab7..673a46e 100644
--- a/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/web/OpenstackNodeWebResource.java
+++ b/apps/openstacknode/app/src/main/java/org/onosproject/openstacknode/web/OpenstackNodeWebResource.java
@@ -65,11 +65,13 @@
     private static final String DELETE = "DELETE";
     private static final String QUERY = "QUERY";
     private static final String INIT = "INIT";
+    private static final String NOT_EXIST = "Not exist";
+    private static final String STATE = "State";
 
     private static final String HOST_NAME = "hostname";
     private static final String ERROR_MESSAGE = " cannot be null";
 
-    private final ObjectNode root = mapper().createObjectNode();
+    private final ObjectNode  root = mapper().createObjectNode();
     private final ArrayNode osJsonNodes = root.putArray("nodes");
 
     private final OpenstackNodeAdminService osNodeAdminService =
@@ -184,6 +186,24 @@
     }
 
     /**
+     * Obtains the state of the openstack node.
+     *
+     * @param hostname hostname of the openstack
+     * @return the state of the openstack node in Json
+     */
+    @GET
+    @Produces(MediaType.APPLICATION_JSON)
+    @Path("state/{hostname}")
+    public Response stateOfNode(@PathParam("hostname") String hostname) {
+        log.trace(String.format(MESSAGE_NODE, QUERY));
+
+        OpenstackNode osNode = osNodeService.node(hostname);
+        String nodeState = osNode != null ? osNode.state().toString() : NOT_EXIST;
+
+        return ok(mapper().createObjectNode().put(STATE, nodeState)).build();
+    }
+
+    /**
      * Initializes openstack node.
      *
      * @param hostname hostname of openstack node