From c475aacc08f5e614720b35b96cec7cfbf3ba2b2c Mon Sep 17 00:00:00 2001 From: Jessica Wang Date: Wed, 16 Feb 2011 15:05:55 -0800 Subject: [PATCH] bug 8578: make listRouters API take in id parameter. --- api/src/com/cloud/api/commands/ListRoutersCmd.java | 8 ++++++++ server/src/com/cloud/server/ManagementServerImpl.java | 6 ++++++ ui/scripts/cloud.core.router.js | 7 ++----- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/api/src/com/cloud/api/commands/ListRoutersCmd.java b/api/src/com/cloud/api/commands/ListRoutersCmd.java index 32ec016e4f0..3f8f5cd4a27 100644 --- a/api/src/com/cloud/api/commands/ListRoutersCmd.java +++ b/api/src/com/cloud/api/commands/ListRoutersCmd.java @@ -27,6 +27,7 @@ import com.cloud.api.ApiConstants; import com.cloud.api.BaseListCmd; import com.cloud.api.Implementation; import com.cloud.api.Parameter; +import com.cloud.api.BaseCmd.CommandType; import com.cloud.api.response.DomainRouterResponse; import com.cloud.api.response.ListResponse; import com.cloud.async.AsyncJob; @@ -51,6 +52,9 @@ public class ListRoutersCmd extends BaseListCmd { @Parameter(name=ApiConstants.HOST_ID, type=CommandType.LONG, description="the host ID of the router") private Long hostId; + @Parameter(name=ApiConstants.ID, type=CommandType.LONG, description="the ID of the disk volume") + private Long id; + @Parameter(name=ApiConstants.NAME, type=CommandType.STRING, description="the name of the router") private String routerName; @@ -82,6 +86,10 @@ public class ListRoutersCmd extends BaseListCmd { return hostId; } + public Long getId() { + return id; + } + public String getRouterName() { return routerName; } diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java index 76c713b3c3e..1b1dfff730d 100755 --- a/server/src/com/cloud/server/ManagementServerImpl.java +++ b/server/src/com/cloud/server/ManagementServerImpl.java @@ -2138,6 +2138,7 @@ public class ManagementServerImpl implements ManagementServer { Filter searchFilter = new Filter(DomainRouterVO.class, "id", true, cmd.getStartIndex(), cmd.getPageSizeVal()); + Object id = cmd.getId(); Object name = cmd.getRouterName(); Object state = cmd.getState(); Object zone = cmd.getZoneId(); @@ -2148,6 +2149,7 @@ public class ManagementServerImpl implements ManagementServer { SearchBuilder sb = _routerDao.createSearchBuilder(); sb.and("name", sb.entity().getName(), SearchCriteria.Op.LIKE); + sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ); sb.and("accountId", sb.entity().getAccountId(), SearchCriteria.Op.IN); sb.and("state", sb.entity().getState(), SearchCriteria.Op.EQ); sb.and("dataCenterId", sb.entity().getDataCenterId(), SearchCriteria.Op.EQ); @@ -2185,6 +2187,10 @@ public class ManagementServerImpl implements ManagementServer { if (name != null) { sc.setParameters("name", "%" + name + "%"); } + + if(id != null) { + sc.setParameters("id", id); + } if (accountId != null) { sc.setParameters("accountId", accountId); diff --git a/ui/scripts/cloud.core.router.js b/ui/scripts/cloud.core.router.js index f2a5626b6b2..c8d7b04dd9e 100644 --- a/ui/scripts/cloud.core.router.js +++ b/ui/scripts/cloud.core.router.js @@ -92,9 +92,7 @@ function routerJsonToDetailsTab() { var $thisTab = $("#right_panel_content").find("#tab_content_details"); $thisTab.find("#tab_container").hide(); $thisTab.find("#tab_spinning_wheel").show(); - - //uncomment the following section when Bug 8578("listRouters API doesnt' take in id parameter correctly") is fixed. - /* + $.ajax({ data: createURL("command=listRouters&id="+jsonObj.id), dataType: "json", @@ -107,8 +105,7 @@ function routerJsonToDetailsTab() { } } }); - */ - + $thisTab.find("#grid_header_title").text(fromdb(jsonObj.name)); setVmStateInRightPanel(fromdb(jsonObj.state), $thisTab.find("#state")); $thisTab.find("#id").text(fromdb(jsonObj.id));