From 246c01b1abb0abf0d86df38120549575a9bbac69 Mon Sep 17 00:00:00 2001 From: Alex Huang Date: Tue, 7 Jun 2011 15:08:04 -0700 Subject: [PATCH] bug 9651: added tags to network response for ui --- .../com/cloud/api/response/NetworkResponse.java | 16 ++++++++++++++++ server/src/com/cloud/api/ApiResponseHelper.java | 3 ++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/api/src/com/cloud/api/response/NetworkResponse.java b/api/src/com/cloud/api/response/NetworkResponse.java index 3fa2e6f6fea..7ada9138425 100644 --- a/api/src/com/cloud/api/response/NetworkResponse.java +++ b/api/src/com/cloud/api/response/NetworkResponse.java @@ -116,6 +116,9 @@ public class NetworkResponse extends BaseResponse{ @SerializedName(ApiConstants.SECURITY_GROUP_EANBLED) @Param(description="true if security group is enabled, false otherwise") private Boolean isSecurityGroupEnabled; + @SerializedName(ApiConstants.TAGS) @Param(description="comma separated tag") + private String tags; + public Long getId() { return id; } @@ -356,4 +359,17 @@ public class NetworkResponse extends BaseResponse{ this.isSecurityGroupEnabled = sgEnabled; } + public void setTags(List tags) { + if (tags == null || tags.size() == 0) { + return; + } + + StringBuilder buf = new StringBuilder(); + for (String tag : tags) { + buf.append(tag).append(","); + } + + this.tags = buf.delete(buf.length()-1, buf.length()).toString(); + } + } diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java index 0e0c1533e58..7d9a51aa836 100755 --- a/server/src/com/cloud/api/ApiResponseHelper.java +++ b/server/src/com/cloud/api/ApiResponseHelper.java @@ -956,7 +956,7 @@ public class ApiResponseHelper implements ResponseGenerator { FirewallRuleResponse response = new FirewallRuleResponse(); response.setId(fwRule.getId()); response.setPrivateStartPort(Integer.toString(fwRule.getDestinationPortStart())); - response.setPrivateEndPort(Integer.toString(fwRule.getDestinationPortEnd())); + response.setPrivateEndPort(Integer.toString(fwRule.getDestinationPortEnd())); response.setProtocol(fwRule.getProtocol()); response.setPublicStartPort(Integer.toString(fwRule.getSourcePortStart())); response.setPublicEndPort(Integer.toString(fwRule.getSourcePortEnd())); @@ -2488,6 +2488,7 @@ public class ApiResponseHelper implements ResponseGenerator { response.setDns2(profile.getDns2()); response.setIsSecurityGroupEnabled(network.isSecurityGroupEnabled()); + response.setTags(network.getTags()); // populate capability Map> serviceCapabilitiesMap = ApiDBUtils.getNetworkCapabilities(networkOffering.getId(), network.getDataCenterId());