cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jessicaw...@apache.org
Subject git commit: updated refs/heads/master to 45dbd9c
Date Sat, 27 Apr 2013 18:02:47 GMT
Updated Branches:
  refs/heads/master 1f0863f75 -> 45dbd9cdc


CLOUDSTACK-2120: mixed zone management - API: extend listTemplates, listIsos API to to take
in zonetype.


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

Branch: refs/heads/master
Commit: 45dbd9cdc6d0adc7f69bf1e3fa7b5964ac916fe5
Parents: 1f0863f
Author: Jessica Wang <jessica.wang@citrix.com>
Authored: Sat Apr 27 11:02:02 2013 -0700
Committer: Jessica Wang <jessica.wang@citrix.com>
Committed: Sat Apr 27 11:02:02 2013 -0700

----------------------------------------------------------------------
 .../api/command/user/iso/ListIsosCmd.java          |    7 +++++++
 .../command/user/template/ListTemplatesCmd.java    |    8 ++++++++
 .../src/com/cloud/server/ManagementServerImpl.java |   12 ++++++------
 .../src/com/cloud/storage/dao/VMTemplateDao.java   |    2 +-
 .../com/cloud/storage/dao/VMTemplateDaoImpl.java   |   11 +++++++----
 5 files changed, 29 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/45dbd9cd/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java b/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java
index 3219601..f872c12 100644
--- a/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/iso/ListIsosCmd.java
@@ -78,6 +78,9 @@ public class ListIsosCmd extends BaseListTaggedResourcesCmd {
             description="the ID of the zone")
     private Long zoneId;
 
+    @Parameter(name=ApiConstants.ZONE_TYPE, type=CommandType.STRING, description="the network
type of the zone that the virtual machine belongs to")
+    private String zoneType;
+    
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
@@ -115,6 +118,10 @@ public class ListIsosCmd extends BaseListTaggedResourcesCmd {
         return zoneId;
     }
 
+    public String getZoneType() {
+        return zoneType;
+    }
+    
     public boolean listInReadyState() {
         Account account = UserContext.current().getCaller();
         // It is account specific if account is admin type and domainId and accountName are
not null

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/45dbd9cd/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatesCmd.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatesCmd.java
b/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatesCmd.java
index aeb76f5..f0fc241 100644
--- a/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatesCmd.java
+++ b/api/src/org/apache/cloudstack/api/command/user/template/ListTemplatesCmd.java
@@ -68,6 +68,10 @@ public class ListTemplatesCmd extends BaseListTaggedResourcesCmd {
     @Parameter(name=ApiConstants.ZONE_ID, type=CommandType.UUID, entityType = ZoneResponse.class,
             description="list templates by zoneId")
     private Long zoneId;
+    
+    @Parameter(name=ApiConstants.ZONE_TYPE, type=CommandType.STRING, description="the network
type of the zone that the virtual machine belongs to")
+    private String zoneType;
+    
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
@@ -92,6 +96,10 @@ public class ListTemplatesCmd extends BaseListTaggedResourcesCmd {
         return zoneId;
     }
 
+    public String getZoneType() {
+        return zoneType;
+    }
+    
     public boolean listInReadyState() {
 
         Account account = UserContext.current().getCaller();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/45dbd9cd/server/src/com/cloud/server/ManagementServerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/server/ManagementServerImpl.java b/server/src/com/cloud/server/ManagementServerImpl.java
index 16127a2..0da8d4f 100755
--- a/server/src/com/cloud/server/ManagementServerImpl.java
+++ b/server/src/com/cloud/server/ManagementServerImpl.java
@@ -1309,7 +1309,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
         HypervisorType hypervisorType = HypervisorType.getType(cmd.getHypervisor());
         return listTemplates(cmd.getId(), cmd.getIsoName(), cmd.getKeyword(), isoFilter,
true, cmd.isBootable(), cmd.getPageSizeVal(),
                 cmd.getStartIndex(), cmd.getZoneId(), hypervisorType, true, cmd.listInReadyState(),
permittedAccounts, caller,
-                listProjectResourcesCriteria, tags);
+                listProjectResourcesCriteria, tags, cmd.getZoneType());
     }
 
     @Override
@@ -1342,12 +1342,12 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
         HypervisorType hypervisorType = HypervisorType.getType(cmd.getHypervisor());
 
         return listTemplates(id, cmd.getTemplateName(), cmd.getKeyword(), templateFilter,
false, null, cmd.getPageSizeVal(), cmd.getStartIndex(),
-                cmd.getZoneId(), hypervisorType, showDomr, cmd.listInReadyState(), permittedAccounts,
caller, listProjectResourcesCriteria, tags);
+                cmd.getZoneId(), hypervisorType, showDomr, cmd.listInReadyState(), permittedAccounts,
caller, listProjectResourcesCriteria, tags, cmd.getZoneType());
     }
 
     private Set<Pair<Long, Long>> listTemplates(Long templateId, String name,
String keyword, TemplateFilter templateFilter, boolean isIso,
             Boolean bootable, Long pageSize, Long startIndex, Long zoneId, HypervisorType
hyperType, boolean showDomr, boolean onlyReady,
-            List<Account> permittedAccounts, Account caller, ListProjectResourcesCriteria
listProjectResourcesCriteria, Map<String, String> tags) {
+            List<Account> permittedAccounts, Account caller, ListProjectResourcesCriteria
listProjectResourcesCriteria, Map<String, String> tags, String zoneType) {
 
         VMTemplateVO template = null;
         if (templateId != null) {
@@ -1388,7 +1388,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
                         startIndex, zoneId, hyperType, onlyReady, showDomr, permittedAccounts,
caller, tags);
                 Set<Pair<Long, Long>> templateZonePairSet2 = new HashSet<Pair<Long,
Long>>();
                 templateZonePairSet2 = _templateDao.searchTemplates(name, keyword, templateFilter,
isIso, hypers, bootable, domain, pageSize,
-                        startIndex, zoneId, hyperType, onlyReady, showDomr, permittedAccounts,
caller, listProjectResourcesCriteria, tags);
+                        startIndex, zoneId, hyperType, onlyReady, showDomr, permittedAccounts,
caller, listProjectResourcesCriteria, tags, zoneType);
 
                 for (Pair<Long, Long> tmpltPair : templateZonePairSet2) {
                     if (!templateZonePairSet.contains(new Pair<Long, Long>(tmpltPair.first(),
-1L))) {
@@ -1412,7 +1412,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
                 Set<Pair<Long, Long>> templateZonePairSet2 = new HashSet<Pair<Long,
Long>>();
                 templateZonePairSet2 = _templateDao.searchTemplates(name, keyword, templateFilter,
isIso, hypers,
                         bootable, domain, pageSize, startIndex, zoneId, hyperType, onlyReady,
showDomr,
-                        permittedAccounts, caller, listProjectResourcesCriteria, tags);
+                        permittedAccounts, caller, listProjectResourcesCriteria, tags, zoneType);
 
                 for (Pair<Long, Long> tmpltPair : templateZonePairSet2) {
                     if (!templateZonePairSet.contains(new Pair<Long, Long>(tmpltPair.first(),
-1L))) {
@@ -1430,7 +1430,7 @@ public class ManagementServerImpl extends ManagerBase implements ManagementServe
         } else {
             if (template == null) {
                 templateZonePairSet = _templateDao.searchTemplates(name, keyword, templateFilter,
isIso, hypers, bootable, domain, pageSize,
-                        startIndex, zoneId, hyperType, onlyReady, showDomr, permittedAccounts,
caller, listProjectResourcesCriteria, tags);
+                        startIndex, zoneId, hyperType, onlyReady, showDomr, permittedAccounts,
caller, listProjectResourcesCriteria, tags, zoneType);
             } else {
                 // if template is not public, perform permission check here
                 if (!template.isPublicTemplate() && caller.getType() != Account.ACCOUNT_TYPE_ADMIN)
{

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/45dbd9cd/server/src/com/cloud/storage/dao/VMTemplateDao.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/dao/VMTemplateDao.java b/server/src/com/cloud/storage/dao/VMTemplateDao.java
index 7263371..3f1fe93 100755
--- a/server/src/com/cloud/storage/dao/VMTemplateDao.java
+++ b/server/src/com/cloud/storage/dao/VMTemplateDao.java
@@ -56,7 +56,7 @@ public interface VMTemplateDao extends GenericDao<VMTemplateVO, Long>,
StateDao<
 	public Set<Pair<Long, Long>> searchTemplates(String name, String keyword, TemplateFilter
templateFilter, boolean isIso,
 	        List<HypervisorType> hypers, Boolean bootable, DomainVO domain, Long pageSize,
Long startIndex, Long zoneId,
 	        HypervisorType hyperType, boolean onlyReady, boolean showDomr, List<Account>
permittedAccounts, Account caller,
-	        ListProjectResourcesCriteria listProjectResourcesCriteria, Map<String, String>
tags);
+	        ListProjectResourcesCriteria listProjectResourcesCriteria, Map<String, String>
tags, String zoneType);
 	
     public Set<Pair<Long, Long>> searchSwiftTemplates(String name, String keyword,
TemplateFilter templateFilter,
             boolean isIso, List<HypervisorType> hypers, Boolean bootable, DomainVO
domain, Long pageSize, Long startIndex,

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/45dbd9cd/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java b/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java
index d9a26d3..3b37f24 100755
--- a/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java
+++ b/server/src/com/cloud/storage/dao/VMTemplateDaoImpl.java
@@ -520,7 +520,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO,
Long> implem
 	public Set<Pair<Long, Long>> searchTemplates(String name, String keyword, TemplateFilter
templateFilter,
 	        boolean isIso, List<HypervisorType> hypers, Boolean bootable, DomainVO domain,
Long pageSize, Long startIndex,
 	        Long zoneId, HypervisorType hyperType, boolean onlyReady, boolean showDomr,List<Account>
permittedAccounts,
-	        Account caller, ListProjectResourcesCriteria listProjectResourcesCriteria, Map<String,
String> tags) {
+	        Account caller, ListProjectResourcesCriteria listProjectResourcesCriteria, Map<String,
String> tags, String zoneType) {
         StringBuilder builder = new StringBuilder();
         if (!permittedAccounts.isEmpty()) {
             for (Account permittedAccount : permittedAccounts) {
@@ -561,7 +561,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO,
Long> implem
         		sql = SELECT_TEMPLATE_HOST_REF;
                 groupByClause = " GROUP BY t.id, h.data_center_id ";
         	}
-        	if ((templateFilter == TemplateFilter.featured) || (templateFilter == TemplateFilter.community))
{
+        	if (((templateFilter == TemplateFilter.featured) || (templateFilter == TemplateFilter.community))
||(zoneType != null && zoneId != null)) {
         	    dataCenterJoin = " INNER JOIN data_center dc on (h.data_center_id = dc.id)";
         	}
 
@@ -691,7 +691,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO,
Long> implem
             }
 
             sql += whereClause + getExtrasWhere(templateFilter, name, keyword, isIso, bootable,
hyperType, zoneId,
-                    onlyReady, showDomr) + groupByClause + getOrderByLimit(pageSize, startIndex);
+                    onlyReady, showDomr, zoneType) + groupByClause + getOrderByLimit(pageSize,
startIndex);
 
             pstmt = txn.prepareStatement(sql);
             rs = pstmt.executeQuery();
@@ -752,7 +752,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO,
Long> implem
         return templateZonePairList;
 	}
 
-	private String getExtrasWhere(TemplateFilter templateFilter, String name, String keyword,
boolean isIso, Boolean bootable, HypervisorType hyperType, Long zoneId, boolean onlyReady,
boolean showDomr) {
+	private String getExtrasWhere(TemplateFilter templateFilter, String name, String keyword,
boolean isIso, Boolean bootable, HypervisorType hyperType, Long zoneId, boolean onlyReady,
boolean showDomr, String zoneType) {
 	    String sql = "";
         if (keyword != null) {
             sql += " t.name LIKE \"%" + keyword + "%\" AND";
@@ -783,6 +783,9 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO,
Long> implem
             }
         }else if (zoneId != null){
         	sql += " AND tzr.zone_id = " +zoneId+ " AND tzr.removed is null" ;
+        	if (zoneType != null){        	  
+        		sql += " AND dc.networktype = " + zoneType;
+        	}        	
         }else{
         	sql += " AND tzr.removed is null ";
         }


Mime
View raw message