+ * Retrieve a list of all the nodes and their properties in the network
+ *
+ * @param containerName
+ * Name of the Container (Eg. 'default')
+ * @return A list of Pair each pair represents a
+ * {@link org.opendaylight.controller.sal.core.Node} and Set of
+ * {@link org.opendaylight.controller.sal.core.Property} attached to
+ * it.
+ *
+ * <pre>
+ *
+ * Example:
+ *
+ * Request URL:
+ * http://localhost:8080/controller/nb/v2/switchmanager/default/nodes
+ *
+ * Response body in XML:
+ * <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+ * <list>
+ *    <nodeProperties>
+ *       <node>
+ *          <id>00:00:00:00:00:00:00:02</id>
+ *          <type>OF</type>
+ *       </node>
+ *       <properties>
+ *          <tables>
+ *             <value>-1</value>
+ *          </tables>
+ *          <description>
+ *             <value>Switch2</value>
+ *          </description>
+ *          <actions>
+ *             <value>4095</value>
+ *          </actions>
+ *          <macAddress>
+ *             <value>00:00:00:00:00:02</value>
+ *          </macAddress>
+ *          <capabilities>
+ *             <value>199</value>
+ *          </capabilities>
+ *          <timeStamp>
+ *             <value>1377291227877</value>
+ *             <name>connectedSince</name>
+ *          </timeStamp>
+ *          <buffers>
+ *             <value>256</value>
+ *          </buffers>
+ *       </properties>
+ *    </nodeProperties>
+ * </list>
+ *
+ * Response body in JSON:
+ * {
+ * "nodeProperties":[
+ * {
+ * "node":{
+ * "id":"00:00:00:00:00:00:00:02",
+ * "type":"OF"
+ * },
+ * "properties":{
+ * "tables":{
+ * "value":"-1"
+ * },
+ * "description":{
+ * "value":"None"
+ * },
+ * "actions":{
+ * "value":"4095"
+ * },
+ * "macAddress":{
+ * "value":"00:00:00:00:00:02"
+ * },
+ * "capabilities":{
+ * "value":"199"
+ * },
+ * "timeStamp":{
+ * "value":"1377291227877",
+ * "name":"connectedSince"
+ * },
+ * "buffers":{
+ * "value":"256"
+ * }
+ * }
+ * }
+ * ]
+ * }
+ *
+ * </pre>
+ */
+ @Path("/{containerName}/nodes")
+ @GET
+ @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
+ @TypeHint(Nodes.class)
+ @StatusCodes({ @ResponseCode(code = 200, condition = "Operation successful"),
+ @ResponseCode(code = 401, condition = "User not authorized to perform this operation"),
+ @ResponseCode(code = 404, condition = "The containerName is not found"),
+ @ResponseCode(code = 503, condition = "One or more of Controller Services are unavailable") })
+ public Nodes getNodes(@PathParam("containerName") String containerName) {
+
+ if (!isValidContainer(containerName)) {
+ throw new ResourceNotFoundException("Container " + containerName + " does not exist.");
+ }
+
+ if (!NorthboundUtils.isAuthorized(getUserName(), containerName, Privilege.READ, this)) {
+ throw new UnauthorizedException("User is not authorized to perform this operation on container "
+ + containerName);
+ }
+
+ ISwitchManager switchManager = getIfSwitchManagerService(containerName);
+ if (switchManager == null) {
+ throw new ServiceUnavailableException("Switch Manager " + RestMessages.SERVICEUNAVAILABLE.toString());
+ }
+
+ List<NodeProperties> res = new ArrayList<NodeProperties>();
+ Set<Node> nodes = switchManager.getNodes();
+ if (nodes == null) {
+ return new Nodes(res);
+ }
+
+ for (Node node : nodes) {
+ Map<String, Property> propMap = switchManager.getNodeProps(node);
+ if (propMap == null) {
+ continue;
+ }
+ Set<Property> props = new HashSet<Property>(propMap.values());
+
+ NodeProperties nodeProps = new NodeProperties(node, props);
+ res.add(nodeProps);
+ }
+
+ return new Nodes(res);
+ }
+
+ /**
+ * Add a Description, Tier and Forwarding mode property to a node. This
+ * method returns a non-successful response if a node by that name already
+ * exists.
+ *
+ * @param containerName
+ * Name of the Container (Eg. 'default')
+ * @param nodeType
+ * Type of the node being programmed (Eg. 'OF')
+ * @param nodeId
+ * Node Identifier as specified by
+ * {@link org.opendaylight.controller.sal.core.Node} (Eg.
+ * '00:00:00:00:00:00:00:03')
+ * @param propertyName
+ * Name of the Property. Properties that can be configured are:
+ * description, forwarding(only for default container) and tier
+ * @param propertyValue
+ * Value of the Property. Description can be any string (Eg.
+ * 'Node1'), valid values for tier are non negative numbers, and
+ * valid values for forwarding are 0 for reactive and 1 for
+ * proactive forwarding.