cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t..@apache.org
Subject [23/50] [abbrv] git commit: updated refs/heads/marvin_refactor to 30e2971
Date Fri, 12 Apr 2013 11:58:56 GMT
Fixes to de-couple the AffinityGroupResponse from UserVmResponse, since ApiDiscoveryService
breaks, if we nest two response objects into each other.


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

Branch: refs/heads/marvin_refactor
Commit: 0f565f2167981071962b629cb550f9a1973c8fa4
Parents: 3403b54
Author: Prachi Damle <prachi@cloud.com>
Authored: Fri Apr 5 17:01:06 2013 -0700
Committer: Prachi Damle <prachi@cloud.com>
Committed: Thu Apr 11 13:23:25 2013 -0700

----------------------------------------------------------------------
 .../cloudstack/affinity/AffinityGroupResponse.java |   18 +++++++-----
 .../api/query/dao/AffinityGroupJoinDaoImpl.java    |   21 +++------------
 setup/db/db/schema-410to420.sql                    |    3 +-
 3 files changed, 16 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0f565f21/api/src/org/apache/cloudstack/affinity/AffinityGroupResponse.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/affinity/AffinityGroupResponse.java b/api/src/org/apache/cloudstack/affinity/AffinityGroupResponse.java
index 1ae7c59..afd33da 100644
--- a/api/src/org/apache/cloudstack/affinity/AffinityGroupResponse.java
+++ b/api/src/org/apache/cloudstack/affinity/AffinityGroupResponse.java
@@ -16,8 +16,10 @@
 // under the License.
 package org.apache.cloudstack.affinity;
 
+import java.util.ArrayList;
 import java.util.HashSet;
 import java.util.LinkedHashSet;
+import java.util.List;
 import java.util.Set;
 
 import org.apache.cloudstack.api.ApiConstants;
@@ -57,12 +59,12 @@ public class AffinityGroupResponse extends BaseResponse implements ControlledVie
     @Param(description = "the type of the affinity group")
     private String type;
 
-    @SerializedName("virtualmachine")
-    @Param(description = "virtual machines associated with this affinity group ", responseObject
= UserVmResponse.class)
-    private Set<UserVmResponse> vmList;
+    @SerializedName("virtualmachineIds")
+    @Param(description = "virtual machine Ids associated with this affinity group ")
+    private List<String> vmIdList;
 
     public AffinityGroupResponse() {
-        this.vmList = new LinkedHashSet<UserVmResponse>();
+        this.vmIdList = new ArrayList<String>();
     }
 
     @Override
@@ -142,12 +144,12 @@ public class AffinityGroupResponse extends BaseResponse implements ControlledVie
 
     }
 
-    public void setVMList(Set<UserVmResponse> vmList) {
-        this.vmList = vmList;
+    public void setVMIdList(List<String> vmIdList) {
+        this.vmIdList = vmIdList;
     }
 
-    public void addVM(UserVmResponse vm) {
-        this.vmList.add(vm);
+    public void addVMId(String vmId) {
+        this.vmIdList.add(vmId);
     }
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0f565f21/server/src/com/cloud/api/query/dao/AffinityGroupJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/AffinityGroupJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/AffinityGroupJoinDaoImpl.java
index 98c6440..a176793 100644
--- a/server/src/com/cloud/api/query/dao/AffinityGroupJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/AffinityGroupJoinDaoImpl.java
@@ -25,13 +25,10 @@ import javax.inject.Inject;
 
 import org.apache.cloudstack.affinity.AffinityGroup;
 import org.apache.cloudstack.affinity.AffinityGroupResponse;
-import org.apache.cloudstack.api.response.UserVmResponse;
 import org.apache.log4j.Logger;
-import org.springframework.stereotype.Component;
 import com.cloud.api.ApiResponseHelper;
 import com.cloud.api.query.vo.AffinityGroupJoinVO;
 import com.cloud.configuration.dao.ConfigurationDao;
-import com.cloud.user.Account;
 import com.cloud.utils.db.GenericDaoBase;
 import com.cloud.utils.db.SearchBuilder;
 import com.cloud.utils.db.SearchCriteria;
@@ -72,13 +69,9 @@ public class AffinityGroupJoinDaoImpl extends GenericDaoBase<AffinityGroupJoinVO
         // update vm information
         long instanceId = vag.getVmId();
         if (instanceId > 0) {
-            UserVmResponse resp = new UserVmResponse();
-            resp.setObjectName("virtualmachine");
-            resp.setId(vag.getVmUuid());
-            resp.setName(vag.getVmName());
-            resp.setDisplayName(vag.getVmDisplayName());
-            resp.setState(vag.getVmState().toString());
-            agResponse.addVM(resp);
+            List<String> vmIdList = new ArrayList<String>();
+            vmIdList.add(vag.getVmUuid());
+            agResponse.setVMIdList(vmIdList);
         }
 
         agResponse.setObjectName("affinitygroup");
@@ -90,13 +83,7 @@ public class AffinityGroupJoinDaoImpl extends GenericDaoBase<AffinityGroupJoinVO
         // update vm information
         long instanceId = vag.getVmId();
         if (instanceId > 0) {
-            UserVmResponse resp = new UserVmResponse();
-            resp.setObjectName("virtualmachine");
-            resp.setId(vag.getVmUuid());
-            resp.setName(vag.getVmName());
-            resp.setDisplayName(vag.getVmDisplayName());
-            resp.setState(vag.getVmState().toString());
-            vagData.addVM(resp);
+            vagData.addVMId(vag.getVmUuid());
         }
         return vagData;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/0f565f21/setup/db/db/schema-410to420.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql
index ae08ebe..92b2d9c 100644
--- a/setup/db/db/schema-410to420.sql
+++ b/setup/db/db/schema-410to420.sql
@@ -162,7 +162,8 @@ CREATE TABLE `cloud`.`affinity_group_vm_map` (
   `affinity_group_id` bigint unsigned NOT NULL,
   `instance_id` bigint unsigned NOT NULL,
   PRIMARY KEY  (`id`),
-  CONSTRAINT `fk_agvm__group_id` FOREIGN KEY(`affinity_group_id`) REFERENCES `affinity_group`(`id`)
 
+  CONSTRAINT `fk_agvm__group_id` FOREIGN KEY(`affinity_group_id`) REFERENCES `affinity_group`(`id`)
ON DELETE CASCADE,
+  CONSTRAINT `fk_affinity_group_vm_map___instance_id` FOREIGN KEY(`instance_id`) REFERENCES
`user_vm` (`id`) ON DELETE CASCADE
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 
 


Mime
View raw message