incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From prachida...@apache.org
Subject [2/8] git commit: refs/heads/4.1 - CLOUDSTACK-1127: [EC2 Query API] DescribeSecurityGroups, support for additional filters
Date Tue, 12 Feb 2013 23:10:28 GMT
CLOUDSTACK-1127: [EC2 Query API] DescribeSecurityGroups, support for additional filters

Add support for filters ip-permission.group-name and ip-permission.user-id


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

Branch: refs/heads/4.1
Commit: 961c8ee3657f6874ea772ac1bab42825aeb91b70
Parents: 2a565d4
Author: Likitha Shetty <Likitha.Shetty@citrix.com>
Authored: Mon Feb 11 15:25:30 2013 -0800
Committer: Prachi Damle <prachi@cloud.com>
Committed: Tue Feb 12 13:45:26 2013 -0800

----------------------------------------------------------------------
 .../bridge/service/core/ec2/EC2GroupFilterSet.java |   22 ++++++++++++++-
 1 files changed, 21 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/961c8ee3/awsapi/src/com/cloud/bridge/service/core/ec2/EC2GroupFilterSet.java
----------------------------------------------------------------------
diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2GroupFilterSet.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2GroupFilterSet.java
index 149d25f..dbc367c 100644
--- a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2GroupFilterSet.java
+++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2GroupFilterSet.java
@@ -41,6 +41,8 @@ public class EC2GroupFilterSet {
 		filterTypes.put( "ip-permission.from-port", "string" );
 		filterTypes.put( "ip-permission.to-port",   "string" ); 
 		filterTypes.put( "ip-permission.protocol",  "string" ); 
+        filterTypes.put( "ip-permission.group-name","string" );
+        filterTypes.put( "ip-permission.user-id",   "string" );
 		filterTypes.put( "owner-id",                "string" );
 	}
 
@@ -126,7 +128,7 @@ public class EC2GroupFilterSet {
         EC2IpPermission[] permissionSet = sg.getIpPermissionSet();
 
         for (EC2IpPermission perm : permissionSet) {
-            boolean matched = true;
+            boolean matched = false;
             for (EC2Filter filter : ipPermissionFilterSet) {
                 String filterName = filter.getName();
                 String[] valueSet = filter.getValueSet();
@@ -144,6 +146,24 @@ public class EC2GroupFilterSet {
                         matched = containsString( perm.getToPort().toString(), valueSet );
                 } else if (filterName.equalsIgnoreCase( "ip-permission.protocol" ))
                     matched = containsString( perm.getProtocol(), valueSet );
+                else if (filterName.equalsIgnoreCase( "ip-permission.group-name" )) {
+                    EC2SecurityGroup[] userSet = perm.getUserSet();
+                    for (EC2SecurityGroup user : userSet) {
+                        if (containsString(user.getName(), valueSet)) {
+                            matched = true;
+                            break;
+                        }
+                    }
+                }
+                else if (filterName.equalsIgnoreCase( "ip-permission.user-id" )){
+                    EC2SecurityGroup[] userSet = perm.getUserSet();
+                    for (EC2SecurityGroup user : userSet) {
+                        if (containsString(user.getAccountName(), valueSet)) {
+                            matched = true;
+                            break;
+                        }
+                    }
+                }
                 if (!matched) break;
             }
             if (matched) return true;


Mime
View raw message