From 5d4843d94709e192311888113dad767d4d947582 Mon Sep 17 00:00:00 2001 From: Andrew Kim Date: Fri, 6 Sep 2013 17:21:27 -0500 Subject: [PATCH] Fix cluster menu Change-Id: I78b11efc4928b1be0d3d3f0b865483b59b8fb839 Signed-off-by: Andrew Kim --- .../controller/web/DaylightWebAdmin.java | 25 ++++++++++--------- .../web/root/src/main/resources/js/open.js | 16 ++++++------ 2 files changed, 22 insertions(+), 19 deletions(-) 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..3b0b85c065 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 @@ -56,7 +56,7 @@ public class DaylightWebAdmin { return null; } - List clusters = new ArrayList(); + List clusterNodes = new ArrayList(); List controllers = clusterServices.getClusteredControllers(); for (InetAddress controller : controllers) { @@ -64,25 +64,24 @@ public class DaylightWebAdmin { if (controller.equals(clusterServices.getMyAddress())) { clusterBeanBuilder.highlightMe(); } - if (clusterServices.amICoordinator()) { + 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 +98,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; diff --git a/opendaylight/web/root/src/main/resources/js/open.js b/opendaylight/web/root/src/main/resources/js/open.js index 599922d391..85e4d472ef 100644 --- a/opendaylight/web/root/src/main/resources/js/open.js +++ b/opendaylight/web/root/src/main/resources/js/open.js @@ -515,9 +515,6 @@ one.main.cluster = { close : 'one-main-cluster-id-close', datagrid : 'one-main-cluster-id-datagrid' }, - registry : { // one.main.cluster.registry - cluster : undefined - }, initialize : function() { var h3 = 'Cluster Management'; var footer = one.main.cluster.footer(); @@ -544,7 +541,7 @@ one.main.cluster = { if ($tr.find('td:nth-child(1)').attr('colspan') === '1') { return false; } - var address = one.main.cluster.registry.cluster[$tr.index()]; + var address = $tr.find('.ux-id').text(); one.main.cluster.nodes.initialize(address); }); }); @@ -558,7 +555,14 @@ one.main.cluster = { var registry = []; $(data).each(function(idx, val) { var name = val.name; + var address = val.address; + var $registry = $(document.createElement('span')); + $registry + .append(JSON.stringify(address)) + .css('display', 'none') + .addClass('ux-id'); name = one.lib.dashlet.label(name, null)[0].outerHTML; + name += $registry[0].outerHTML; if (val.me === true) { var me = one.lib.dashlet.label('*', 'label-inverse')[0].outerHTML; name += ' '+me; @@ -570,9 +574,7 @@ one.main.cluster = { tdata.push({ 'controller' : name }); - registry.push(val.address); }); - one.main.cluster.registry.cluster = registry; var source = new StaticDataSource({ columns : [ { @@ -613,7 +615,7 @@ one.main.cluster.nodes = { }); // body - $.getJSON('/admin/cluster/controller/'+JSON.stringify(address), function(data) { + $.getJSON('/admin/cluster/controller/'+address, function(data) { var $gridHTML = one.lib.dashlet.datagrid.init(one.main.cluster.nodes.id.datagrid, { searchable: true, filterable: false, -- 2.36.6