cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From likit...@apache.org
Subject [52/71] [abbrv] git commit: updated refs/heads/4.2 to e6ce4da
Date Sun, 28 Jul 2013 06:57:20 GMT
CLOUDSTACK-3258. In AWSAPI provide Tags support for resource 'security group'

Signed-off-by: Likitha Shetty <likitha.shetty@citrix.com>


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

Branch: refs/heads/4.2
Commit: a0a5f67a418b72cd132c57105ee5cc8e0f53123f
Parents: 7a0813e
Author: Likitha Shetty <likitha.shetty@citrix.com>
Authored: Thu Jun 27 16:57:27 2013 +0530
Committer: Likitha Shetty <likitha.shetty@citrix.com>
Committed: Sun Jul 28 12:19:19 2013 +0530

----------------------------------------------------------------------
 .../bridge/service/EC2SoapServiceImpl.java      |  2 +
 .../bridge/service/core/ec2/EC2Engine.java      | 13 +++++-
 .../service/core/ec2/EC2GroupFilterSet.java     | 44 ++++++++++++++++++++
 .../service/core/ec2/EC2SecurityGroup.java      | 11 ++++-
 .../stack/models/CloudStackSecurityGroup.java   |  7 ++++
 5 files changed, 75 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a0a5f67a/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java
----------------------------------------------------------------------
diff --git a/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java b/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java
index 3e3f578..0edb1fd 100644
--- a/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java
+++ b/awsapi/src/com/cloud/bridge/service/EC2SoapServiceImpl.java
@@ -2127,6 +2127,8 @@ public class EC2SoapServiceImpl implements AmazonEC2SkeletonInterface
 {
 				param4.addItem(param5);
 			}
 			param3.setIpPermissions(param4);
+            EC2TagKeyValue[] tags = group.getResourceTags();
+            param3.setTagSet(setResourceTags(tags));
 			param2.addItem(param3);
 		}
 		param1.setSecurityGroupInfo(param2);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a0a5f67a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java
----------------------------------------------------------------------
diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java
index 22d7753..1636bac 100644
--- a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java
+++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2Engine.java
@@ -2053,7 +2053,14 @@ public class EC2Engine extends ManagerBase {
                     ec2Group.setDomainId(group.getDomainId());
                     ec2Group.setId(group.getId().toString());
                     toPermission(ec2Group, group);
-
+                    List<CloudStackKeyValue> resourceTags = group.getTags();
+                    for(CloudStackKeyValue resourceTag : resourceTags) {
+                        EC2TagKeyValue param = new EC2TagKeyValue();
+                             param.setKey(resourceTag.getKey());
+                        if (resourceTag.getValue() != null)
+                            param.setValue(resourceTag.getValue());
+                        ec2Group.addResourceTag(param);
+                    }
                     groupSet.addGroup(ec2Group);
                 }
             return groupSet;
@@ -2502,6 +2509,8 @@ public class EC2Engine extends ManagerBase {
             return("template");
         else if(resourceType.equalsIgnoreCase("instance"))
             return("userVm");
+        else if (resourceType.equalsIgnoreCase("security-group"))
+            return("securityGroup");
         else
             return resourceType;
     }
@@ -2517,6 +2526,8 @@ public class EC2Engine extends ManagerBase {
             return("image");
         else if(resourceType.equalsIgnoreCase("userVm"))
             return("instance");
+        else if(resourceType.equalsIgnoreCase("securityGroup"))
+            return("security-group");
         else
             return (resourceType.toLowerCase());
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a0a5f67a/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 bd79041..c5b985a 100644
--- a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2GroupFilterSet.java
+++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2GroupFilterSet.java
@@ -45,6 +45,8 @@ public class EC2GroupFilterSet {
         filterTypes.put( "ip-permission.group-name","string" );
         filterTypes.put( "ip-permission.user-id",   "string" );
 		filterTypes.put( "owner-id",                "string" );
+        filterTypes.put( "tag-key",                 "string" );
+        filterTypes.put( "tag-value",               "string" );
 	}
 
 
@@ -119,6 +121,42 @@ public class EC2GroupFilterSet {
 			String owner = new String( sg.getDomainId() + ":" + sg.getAccountName()); 
 			return containsString( owner, valueSet );	
 		}
+        else if (filterName.equalsIgnoreCase("tag-key"))
+        {
+            EC2TagKeyValue[] tagSet = sg.getResourceTags();
+            for (EC2TagKeyValue tag : tagSet)
+                if (containsString(tag.getKey(), valueSet)) return true;
+            return false;
+        }
+        else if (filterName.equalsIgnoreCase("tag-value"))
+        {
+            EC2TagKeyValue[] tagSet = sg.getResourceTags();
+            for (EC2TagKeyValue tag : tagSet){
+                if (tag.getValue() == null) {
+                    if (containsEmptyValue(valueSet)) return true;
+                }
+                else {
+                    if (containsString(tag.getValue(), valueSet)) return true;
+                }
+            }
+            return false;
+        }
+        else if (filterName.startsWith("tag:"))
+        {
+            String key = filterName.split(":")[1];
+            EC2TagKeyValue[] tagSet = sg.getResourceTags();
+            for (EC2TagKeyValue tag : tagSet){
+                if (tag.getKey().equalsIgnoreCase(key)) {
+                    if (tag.getValue() == null) {
+                        if (containsEmptyValue(valueSet)) return true;
+                    }
+                    else {
+                        if (containsString(tag.getValue(), valueSet)) return true;
+                    }
+                }
+            }
+            return false;
+        }
 		else return false;
 	}
 
@@ -182,4 +220,10 @@ public class EC2GroupFilterSet {
 		return false;
 	}
 
+    private boolean containsEmptyValue( String[] set ) {
+        for( int i=0; i < set.length; i++ )
+            if (set[i].isEmpty()) return true;
+        return false;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a0a5f67a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2SecurityGroup.java
----------------------------------------------------------------------
diff --git a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2SecurityGroup.java b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2SecurityGroup.java
index 468c3cc..3aeb064 100644
--- a/awsapi/src/com/cloud/bridge/service/core/ec2/EC2SecurityGroup.java
+++ b/awsapi/src/com/cloud/bridge/service/core/ec2/EC2SecurityGroup.java
@@ -27,6 +27,7 @@ public class EC2SecurityGroup {
 	private String accountName;
 	private String domainId;
 	private List<EC2IpPermission> permissionSet = new ArrayList<EC2IpPermission>();
   
+    private List<EC2TagKeyValue> tagsSet = new ArrayList<EC2TagKeyValue>();
 
 	public EC2SecurityGroup() {
 		id          = null;
@@ -91,5 +92,13 @@ public class EC2SecurityGroup {
 	public void setDomainId(String domainId) {
 		this.domainId = domainId;
 	}
-	
+
+    public void addResourceTag( EC2TagKeyValue param ) {
+        tagsSet.add( param );
+    }
+
+    public EC2TagKeyValue[] getResourceTags() {
+        return tagsSet.toArray(new EC2TagKeyValue[0]);
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/a0a5f67a/awsapi/src/com/cloud/stack/models/CloudStackSecurityGroup.java
----------------------------------------------------------------------
diff --git a/awsapi/src/com/cloud/stack/models/CloudStackSecurityGroup.java b/awsapi/src/com/cloud/stack/models/CloudStackSecurityGroup.java
index 72ba552..e2211f2 100644
--- a/awsapi/src/com/cloud/stack/models/CloudStackSecurityGroup.java
+++ b/awsapi/src/com/cloud/stack/models/CloudStackSecurityGroup.java
@@ -39,6 +39,8 @@ public class CloudStackSecurityGroup {
     private String name;
     @SerializedName(ApiConstants.INGRESS_RULE)
     private List<CloudStackIngressRule> ingressRules;
+    @SerializedName(ApiConstants.TAGS)
+    private List<CloudStackKeyValue> tags;
 
     
     public CloudStackSecurityGroup() {
@@ -79,4 +81,9 @@ public class CloudStackSecurityGroup {
 	public List<CloudStackIngressRule> getIngressRules() {
 		return ingressRules;
 	}
+
+    public List<CloudStackKeyValue> getTags() {
+        return tags;
+    }
+
 }


Mime
View raw message