You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by al...@apache.org on 2012/10/15 20:43:39 UTC

git commit: CLOUDSTACK-347: ipAddressResponse/NetworkResponse API - return vlan info only when the caller is ROOT admin

Updated Branches:
  refs/heads/master 7e704d1b3 -> 1d458c7a2


CLOUDSTACK-347: ipAddressResponse/NetworkResponse API - return vlan info only when the caller is ROOT admin


Project: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/commit/1d458c7a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/tree/1d458c7a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/diff/1d458c7a

Branch: refs/heads/master
Commit: 1d458c7a2d0db3ad80721a4dfcbca4c6e991065d
Parents: 7e704d1
Author: Alena Prokharchyk <al...@citrix.com>
Authored: Mon Oct 15 09:52:20 2012 -0700
Committer: Alena Prokharchyk <al...@citrix.com>
Committed: Mon Oct 15 11:39:38 2012 -0700

----------------------------------------------------------------------
 .../com/cloud/api/response/IPAddressResponse.java  |    3 ++-
 .../com/cloud/api/response/NetworkResponse.java    |    4 ++--
 server/src/com/cloud/api/ApiResponseHelper.java    |    7 +++++--
 3 files changed, 9 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1d458c7a/api/src/com/cloud/api/response/IPAddressResponse.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/response/IPAddressResponse.java b/api/src/com/cloud/api/response/IPAddressResponse.java
index a9c1769..ea5b793 100644
--- a/api/src/com/cloud/api/response/IPAddressResponse.java
+++ b/api/src/com/cloud/api/response/IPAddressResponse.java
@@ -62,7 +62,8 @@ public class IPAddressResponse extends BaseResponse implements ControlledEntityR
     @SerializedName(ApiConstants.FOR_VIRTUAL_NETWORK) @Param(description="the virtual network for the IP address")
     private Boolean forVirtualNetwork;
 
-    @SerializedName(ApiConstants.VLAN_ID) @Param(description="the ID of the VLAN associated with the IP address")
+    @SerializedName(ApiConstants.VLAN_ID) @Param(description="the ID of the VLAN associated with the IP address." +
+    		" This parameter is visible to ROOT admins only")
     private IdentityProxy vlanId = new IdentityProxy("vlan");
 
     @SerializedName("vlanname") @Param(description="the VLAN associated with the IP address")

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1d458c7a/api/src/com/cloud/api/response/NetworkResponse.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/response/NetworkResponse.java b/api/src/com/cloud/api/response/NetworkResponse.java
index a4158f1..0917cfa 100644
--- a/api/src/com/cloud/api/response/NetworkResponse.java
+++ b/api/src/com/cloud/api/response/NetworkResponse.java
@@ -77,7 +77,7 @@ public class NetworkResponse extends BaseResponse implements ControlledEntityRes
     @SerializedName("related") @Param(description="related to what other network configuration")
     private IdentityProxy related = new IdentityProxy("networks");
     
-    @SerializedName("broadcasturi") @Param(description="broadcast uri of the network")
+    @SerializedName("broadcasturi") @Param(description="broadcast uri of the network. This parameter is visible to ROOT admins only")
     private String broadcastUri;
     
     @SerializedName(ApiConstants.DNS1) @Param(description="the first DNS for the network")
@@ -89,7 +89,7 @@ public class NetworkResponse extends BaseResponse implements ControlledEntityRes
     @SerializedName(ApiConstants.TYPE) @Param(description="the type of the network")
     private String type;
     
-    @SerializedName(ApiConstants.VLAN) @Param(description="the vlan of the network")
+    @SerializedName(ApiConstants.VLAN) @Param(description="The vlan of the network. This parameter is visible to ROOT admins only")
     private String vlan;
     
     @SerializedName(ApiConstants.ACL_TYPE) @Param(description="acl type - access type to the network")

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/1d458c7a/server/src/com/cloud/api/ApiResponseHelper.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/ApiResponseHelper.java b/server/src/com/cloud/api/ApiResponseHelper.java
index 2b6a31b..caabd71 100755
--- a/server/src/com/cloud/api/ApiResponseHelper.java
+++ b/server/src/com/cloud/api/ApiResponseHelper.java
@@ -833,7 +833,7 @@ public class ApiResponseHelper implements ResponseGenerator {
 
         // show this info to admin only
         Account account = UserContext.current().getCaller();
-        if ((account == null) || account.getType() == Account.ACCOUNT_TYPE_ADMIN) {
+        if (account.getType() == Account.ACCOUNT_TYPE_ADMIN) {
             ipResponse.setVlanId(ipAddr.getVlanId());
             ipResponse.setVlanName(ApiDBUtils.findVlanById(ipAddr.getVlanId()).getVlanTag());
         }
@@ -2967,14 +2967,17 @@ public class ApiResponseHelper implements ResponseGenerator {
             response.setNetmask(NetUtils.cidr2Netmask(network.getCidr()));
         }
 
-        if (network.getBroadcastUri() != null) {
+        //return vlan information only to Root admin
+        if (network.getBroadcastUri() != null && UserContext.current().getCaller().getType() == Account.ACCOUNT_TYPE_ADMIN) {
             String broadcastUri = network.getBroadcastUri().toString();
             response.setBroadcastUri(broadcastUri);
             String vlan="N/A";
             if (broadcastUri.startsWith("vlan")) {
             	vlan = broadcastUri.substring("vlan://".length(), broadcastUri.length());
             }
+            //return vlan information only to Root admin
             response.setVlan(vlan);
+            
         }
 
         DataCenter zone = ApiDBUtils.findZoneById(network.getDataCenterId());