incubator-cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject [3/3] git commit: CLOUDSTACK-88 Cannot listVM by vpcId which is required by VPC UI
Date Thu, 13 Sep 2012 07:12:29 GMT
CLOUDSTACK-88  Cannot listVM by vpcId which is required by VPC UI


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

Branch: refs/heads/master
Commit: 55bcfaf80524469dca60477c8ecdb4339f88104b
Parents: 25e99e9
Author: Mice Xia <mice_xia@tcloudcomputing.com>
Authored: Thu Sep 13 11:20:12 2012 +0800
Committer: Mice Xia <mice_xia@tcloudcomputing.com>
Committed: Thu Sep 13 11:21:11 2012 +0800

----------------------------------------------------------------------
 api/src/com/cloud/api/commands/ListVMsCmd.java   |    7 +++++
 server/src/com/cloud/server/Criteria.java        |    1 +
 server/src/com/cloud/vm/UserVmManagerImpl.java   |   23 +++++++++++++++++
 utils/src/com/cloud/utils/db/SearchCriteria.java |    5 ++-
 4 files changed, 34 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/55bcfaf8/api/src/com/cloud/api/commands/ListVMsCmd.java
----------------------------------------------------------------------
diff --git a/api/src/com/cloud/api/commands/ListVMsCmd.java b/api/src/com/cloud/api/commands/ListVMsCmd.java
index f8b694a..37dfcd3 100755
--- a/api/src/com/cloud/api/commands/ListVMsCmd.java
+++ b/api/src/com/cloud/api/commands/ListVMsCmd.java
@@ -96,6 +96,9 @@ public class ListVMsCmd extends BaseListTaggedResourcesCmd {
     @Parameter(name=ApiConstants.ISO_ID, type=CommandType.LONG, description="list vms by
iso")
     private Long isoId;
 
+    @IdentityMapper(entityTableName="vpc")
+    @Parameter(name=ApiConstants.VPC_ID, type=CommandType.LONG, description="list vms by
vpc")
+    private Long vpcId;
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
@@ -156,6 +159,10 @@ public class ListVMsCmd extends BaseListTaggedResourcesCmd {
         return isoId;
     }
 
+    public Long getVpcId(){
+        return vpcId;
+    }
+    
     public EnumSet<VMDetails> getDetails() throws InvalidParameterValueException {
         EnumSet<VMDetails> dv;
         if (viewDetails==null || viewDetails.size() <=0){

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/55bcfaf8/server/src/com/cloud/server/Criteria.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/Criteria.java b/server/src/com/cloud/server/Criteria.java
index 3a1f740..35186f8 100755
--- a/server/src/com/cloud/server/Criteria.java
+++ b/server/src/com/cloud/server/Criteria.java
@@ -81,6 +81,7 @@ public class Criteria {
     public static final String STORAGE_ID="storageid";
     public static final String TEMPLATE_ID = "templateid";
     public static final String ISO_ID = "isoid";
+    public static final String VPC_ID = "vpcId";
 
 	public Criteria(String orderBy, Boolean ascending, Long offset, Long limit) {
 		this.offset = offset;

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/55bcfaf8/server/src/com/cloud/vm/UserVmManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/vm/UserVmManagerImpl.java b/server/src/com/cloud/vm/UserVmManagerImpl.java
index 73a60ce..79eeb31 100755
--- a/server/src/com/cloud/vm/UserVmManagerImpl.java
+++ b/server/src/com/cloud/vm/UserVmManagerImpl.java
@@ -141,6 +141,8 @@ import com.cloud.network.security.SecurityGroupManager;
 import com.cloud.network.security.dao.SecurityGroupDao;
 import com.cloud.network.security.dao.SecurityGroupVMMapDao;
 import com.cloud.network.vpc.VpcManager;
+import com.cloud.network.vpc.VpcVO;
+import com.cloud.network.vpc.dao.VpcDao;
 import com.cloud.offering.NetworkOffering;
 import com.cloud.offering.NetworkOffering.Availability;
 import com.cloud.offering.ServiceOffering;
@@ -319,6 +321,8 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService,
Manager
     @Inject
     protected NicDao _nicDao;
     @Inject
+    protected VpcDao _vpcDao;
+    @Inject
     protected RulesManager _rulesMgr;
     @Inject
     protected LoadBalancingRulesManager _lbMgr;
@@ -3012,6 +3016,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService,
Manager
         c.addCriteria(Criteria.NETWORKID, cmd.getNetworkId());
         c.addCriteria(Criteria.TEMPLATE_ID, cmd.getTemplateId());
         c.addCriteria(Criteria.ISO_ID, cmd.getIsoId());
+        c.addCriteria(Criteria.VPC_ID, cmd.getVpcId());
 
         if (domainId != null) {
             c.addCriteria(Criteria.DOMAINID, domainId);
@@ -3063,6 +3068,7 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService,
Manager
         Object storageId = c.getCriteria(Criteria.STORAGE_ID);
         Object templateId = c.getCriteria(Criteria.TEMPLATE_ID);
         Object isoId = c.getCriteria(Criteria.ISO_ID);
+        Object vpcId = c.getCriteria(Criteria.VPC_ID);
 
         sb.and("displayName", sb.entity().getDisplayName(), SearchCriteria.Op.LIKE);
         sb.and("id", sb.entity().getId(), SearchCriteria.Op.EQ);
@@ -3110,6 +3116,19 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService,
Manager
 
             sb.join("nicSearch", nicSearch, sb.entity().getId(), nicSearch.entity().getInstanceId(),
JoinBuilder.JoinType.INNER);
         }
+        
+        if(vpcId != null && networkId == null){
+            SearchBuilder<NicVO> nicSearch = _nicDao.createSearchBuilder();
+
+            SearchBuilder<NetworkVO> networkSearch = _networkDao.createSearchBuilder();
+            nicSearch.join("networkSearch", networkSearch, nicSearch.entity().getNetworkId(),
networkSearch.entity().getId(), JoinBuilder.JoinType.INNER);
+            
+            SearchBuilder<VpcVO> vpcSearch = _vpcDao.createSearchBuilder();
+            vpcSearch.and("vpcId", vpcSearch.entity().getId(), SearchCriteria.Op.EQ);
+            networkSearch.join("vpcSearch", vpcSearch, networkSearch.entity().getVpcId(),
vpcSearch.entity().getId(), JoinBuilder.JoinType.INNER);
+            
+            sb.join("nicSearch", nicSearch, sb.entity().getId(), nicSearch.entity().getInstanceId(),
JoinBuilder.JoinType.INNER);
+        }
 
         if (storageId != null) {
             SearchBuilder<VolumeVO> volumeSearch = _volsDao.createSearchBuilder();
@@ -3162,6 +3181,10 @@ public class UserVmManagerImpl implements UserVmManager, UserVmService,
Manager
         if (networkId != null) {
             sc.setJoinParameters("nicSearch", "networkId", networkId);
         }
+        
+        if(vpcId != null && networkId == null){
+            sc.setJoinParameters("vpcSearch", "vpcId", vpcId);
+        }
 
         if (name != null) {
             sc.setParameters("name", "%" + name + "%");

http://git-wip-us.apache.org/repos/asf/incubator-cloudstack/blob/55bcfaf8/utils/src/com/cloud/utils/db/SearchCriteria.java
----------------------------------------------------------------------
diff --git a/utils/src/com/cloud/utils/db/SearchCriteria.java b/utils/src/com/cloud/utils/db/SearchCriteria.java
index a0d944f..ba4e84d 100755
--- a/utils/src/com/cloud/utils/db/SearchCriteria.java
+++ b/utils/src/com/cloud/utils/db/SearchCriteria.java
@@ -223,9 +223,10 @@ public class SearchCriteria<K> {
     		return jb;
     	}
     	
-    	for (JoinBuilder<SearchCriteria<?>> j2 : _joins.values()) {
+    	for (JoinBuilder<SearchCriteria<?>> j2 : jbmap.values()) {
     		SearchCriteria<?> sc = j2.getT();
-    		jb = findJoin(sc._joins, joinName);
+    		if(sc._joins != null)
+    		    jb = findJoin(sc._joins, joinName);
     		if (jb != null) {
     			return jb;
     		}


Mime
View raw message