X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=blobdiff_plain;f=opendaylight%2Fweb%2Froot%2Fsrc%2Fmain%2Fjava%2Forg%2Fopendaylight%2Fcontroller%2Fweb%2FDaylightWebAdmin.java;h=2b58bcc4cb6c1fb50b12801e2e6133078a13e47f;hb=refs%2Fchanges%2F89%2F1189%2F1;hp=d9aa03ea6209a66fa4548ef091694b1e63dd633c;hpb=c11dff1f548652d147d25966033a1cd31416afc9;p=controller.git diff --git a/opendaylight/web/root/src/main/java/org/opendaylight/controller/web/DaylightWebAdmin.java b/opendaylight/web/root/src/main/java/org/opendaylight/controller/web/DaylightWebAdmin.java index d9aa03ea62..2b58bcc4cb 100644 --- a/opendaylight/web/root/src/main/java/org/opendaylight/controller/web/DaylightWebAdmin.java +++ b/opendaylight/web/root/src/main/java/org/opendaylight/controller/web/DaylightWebAdmin.java @@ -55,34 +55,47 @@ public class DaylightWebAdmin { if (clusterServices == null) { return null; } + IConnectionManager connectionManager = (IConnectionManager) ServiceHelper.getGlobalInstance( + IConnectionManager.class, this); + if (connectionManager == null) { + return null; + } - List clusters = new ArrayList(); + List clusterNodes = new ArrayList(); List controllers = clusterServices.getClusteredControllers(); for (InetAddress controller : controllers) { ClusterNodeBean.Builder clusterBeanBuilder = new ClusterNodeBean.Builder(controller); + + //get number of connected nodes + Set connectedNodes = connectionManager.getNodes(controller); + int numNodes = connectedNodes == null ? 0 : connectedNodes.size(); + clusterBeanBuilder.nodesConnected(numNodes); + + //determine if this is the executing controller if (controller.equals(clusterServices.getMyAddress())) { clusterBeanBuilder.highlightMe(); } - if (clusterServices.amICoordinator()) { + + //determine whether this is coordinator + if (clusterServices.getCoordinatorAddress().equals(controller)) { clusterBeanBuilder.iAmCoordinator(); } - - clusters.add(clusterBeanBuilder.build()); + clusterNodes.add(clusterBeanBuilder.build()); } - return gson.toJson(clusters); + return gson.toJson(clusterNodes); } /** * Return nodes connected to controller {controller} - * @param cluster + * @param controller * - byte[] of the address of the controller * @return List */ @RequestMapping("/cluster/controller/{controller}") @ResponseBody - public String getNodesConnectedToController(@PathVariable("controller") String cluster) { + public String getNodesConnectedToController(@PathVariable("controller") String controller) { IClusterGlobalServices clusterServices = (IClusterGlobalServices) ServiceHelper.getGlobalInstance( IClusterGlobalServices.class, this); if (clusterServices == null) { @@ -99,18 +112,20 @@ public class DaylightWebAdmin { return null; } - byte[] address = gson.fromJson(cluster, byte[].class); - InetAddress clusterAddress = null; + byte[] address = gson.fromJson(controller, byte[].class); + InetAddress controllerAddress = null; try { - clusterAddress = InetAddress.getByAddress(address); + controllerAddress = InetAddress.getByAddress(address); } catch (UnknownHostException e) { return null; } - InetAddress thisCluster = clusterServices.getMyAddress(); List result = new ArrayList(); - Set nodes = connectionManager.getNodes(thisCluster); + Set nodes = connectionManager.getNodes(controllerAddress); + if (nodes == null) { + return gson.toJson(result); + } for (Node node : nodes) { Description description = (Description) switchManager.getNodeProp(node, Description.propertyName); NodeBean nodeBean; @@ -156,7 +171,9 @@ public class DaylightWebAdmin { } Gson gson = new Gson(); - UserConfig config = gson.fromJson(json, UserConfig.class); + UserConfig plainConfig = gson.fromJson(json, UserConfig.class); + // Recreate using the proper constructor which will hash the password + UserConfig config = new UserConfig(plainConfig.getUser(), plainConfig.getPassword(), plainConfig.getRoles()); Status result = (action.equals("add")) ? userManager.addLocalUser(config) : userManager.removeLocalUser(config); if (result.isSuccess()) {