cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kis...@apache.org
Subject git commit: updated refs/heads/4.2 to 5eb5594
Date Fri, 18 Oct 2013 13:35:41 GMT
Updated Branches:
  refs/heads/4.2 8f5965c79 -> 5eb5594e8


CLOUDSTACK-4783: Added supported for listing all templates/ISOs with showremoved = true


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

Branch: refs/heads/4.2
Commit: 5eb5594e8e646dbba29746c5aeb8cb8dd2a3c343
Parents: 8f5965c
Author: Harikrishna Patnala <harikrishna.patnala@citrix.com>
Authored: Fri Oct 18 16:13:04 2013 +0530
Committer: Kishan Kavala <kishan@cloud.com>
Committed: Fri Oct 18 19:05:21 2013 +0530

----------------------------------------------------------------------
 .../org/apache/cloudstack/api/ApiConstants.java |  1 +
 .../api/command/user/iso/ListIsosCmd.java       |  7 +++++++
 .../command/user/template/ListTemplatesCmd.java |  7 +++++++
 .../com/cloud/api/query/QueryManagerImpl.java   | 21 ++++++++++++++++----
 .../com/cloud/api/query/vo/TemplateJoinVO.java  |  2 +-
 5 files changed, 33 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5eb5594e/api/src/org/apache/cloudstack/api/ApiConstants.java
----------------------------------------------------------------------
diff --git a/api/src/org/apache/cloudstack/api/ApiConstants.java b/api/src/org/apache/cloudstack/api/ApiConstants.java
index d71db40..761ff45 100755
--- a/api/src/org/apache/cloudstack/api/ApiConstants.java
+++ b/api/src/org/apache/cloudstack/api/ApiConstants.java
@@ -201,6 +201,7 @@ public class ApiConstants {
     public static final String SENT_BYTES = "sentbytes";
     public static final String SERVICE_OFFERING_ID = "serviceofferingid";
     public static final String SHOW_CAPACITIES = "showcapacities";
+    public static final String SHOW_REMOVED = "showremoved";
     public static final String SIZE = "size";
     public static final String SNAPSHOT_ID = "snapshotid";
     public static final String SNAPSHOT_POLICY_ID = "snapshotpolicyid";

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5eb5594e/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 b490ca9..4bee476 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.SHOW_REMOVED, type=CommandType.BOOLEAN, description="show
removed ISOs as well")
+    private Boolean showRemoved;
+
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
@@ -115,6 +118,10 @@ public class ListIsosCmd extends BaseListTaggedResourcesCmd {
         return zoneId;
     }
 
+    public Boolean getShowRemoved() {
+        return (showRemoved != null ? showRemoved : false);
+    }
+
     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/5eb5594e/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 0b937be..a25723c 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
@@ -69,6 +69,9 @@ 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.SHOW_REMOVED, type=CommandType.BOOLEAN, description="show
removed templates as well")
+    private Boolean showRemoved;
     /////////////////////////////////////////////////////
     /////////////////// Accessors ///////////////////////
     /////////////////////////////////////////////////////
@@ -93,6 +96,10 @@ public class ListTemplatesCmd extends BaseListTaggedResourcesCmd {
         return zoneId;
     }
 
+    public Boolean getShowRemoved() {
+        return (showRemoved != null ? showRemoved : false);
+    }
+
     public boolean listInReadyState() {
 
         Account account = UserContext.current().getCaller();

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5eb5594e/server/src/com/cloud/api/query/QueryManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/QueryManagerImpl.java b/server/src/com/cloud/api/query/QueryManagerImpl.java
index 6104ec0..9963d42 100644
--- a/server/src/com/cloud/api/query/QueryManagerImpl.java
+++ b/server/src/com/cloud/api/query/QueryManagerImpl.java
@@ -2683,6 +2683,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService
{
         TemplateFilter templateFilter = TemplateFilter.valueOf(cmd.getTemplateFilter());
         Long id = cmd.getId();
         Map<String, String> tags = cmd.getTags();
+        boolean showRemovedTmpl = cmd.getShowRemoved();
         Account caller = UserContext.current().getCaller();
 
         boolean listAll = false;
@@ -2710,14 +2711,14 @@ public class QueryManagerImpl extends ManagerBase implements QueryService
{
 
         return searchForTemplatesInternal(id, cmd.getTemplateName(), cmd.getKeyword(), templateFilter,
false, null,
                 cmd.getPageSizeVal(), cmd.getStartIndex(), cmd.getZoneId(), hypervisorType,
showDomr,
-                cmd.listInReadyState(), permittedAccounts, caller, listProjectResourcesCriteria,
tags);
+                cmd.listInReadyState(), permittedAccounts, caller, listProjectResourcesCriteria,
tags, showRemovedTmpl);
     }
 
     private Pair<List<TemplateJoinVO>, Integer> searchForTemplatesInternal(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) {
+            Map<String, String> tags, boolean showRemovedTmpl) {
 
         // check if zone is configured, if not, just return empty list
         List<HypervisorType> hypers = null;
@@ -2740,7 +2741,11 @@ public class QueryManagerImpl extends ManagerBase implements QueryService
{
 
         // verify templateId parameter and specially handle it
         if (templateId != null) {
-            template = _templateDao.findById(templateId);
+            if(showRemovedTmpl){
+                template = _templateDao.findByIdIncludingRemoved(templateId);
+            }else{
+                template = _templateDao.findById(templateId);
+            }
             if (template == null) {
                 throw new InvalidParameterValueException("Please specify a valid template
ID.");
             }// If ISO requested then it should be ISO.
@@ -2758,6 +2763,10 @@ public class QueryManagerImpl extends ManagerBase implements QueryService
{
                 ex.addProxyObject(template.getUuid(), "templateId");
                 throw ex;
             }
+            if ((template == null) || ((template.getRemoved() != null) && !showRemovedTmpl)){
// If template is removed and showRemoved flag not turned -> throw exception. findbyId
returns removed template as well above.
+                s_logger.error("Please specify a valid template ID, template " + template.getUuid()
+ " is removed");
+                throw new InvalidParameterValueException("Please specify a valid template
ID " + template.getUuid());
+            }
 
             // if template is not public, perform permission check here
             if (!template.isPublicTemplate() && caller.getType() != Account.ACCOUNT_TYPE_ADMIN)
{
@@ -2940,6 +2949,9 @@ public class QueryManagerImpl extends ManagerBase implements QueryService
{
         // don't return removed template, this should not be needed since we
         // changed annotation for removed field in TemplateJoinVO.
         // sc.addAnd("removed", SearchCriteria.Op.NULL);
+        if(!showRemovedTmpl){
+            sc.addAnd("removed", SearchCriteria.Op.NULL);
+        }
 
         // search unique templates and find details by Ids
         Pair<List<TemplateJoinVO>, Integer> uniqueTmplPair = _templateJoinDao.searchAndCount(sc,
searchFilter);
@@ -2979,6 +2991,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService
{
         TemplateFilter isoFilter = TemplateFilter.valueOf(cmd.getIsoFilter());
         Long id = cmd.getId();
         Map<String, String> tags = cmd.getTags();
+        boolean showRemovedIso = cmd.getShowRemoved();
         Account caller = UserContext.current().getCaller();
 
         boolean listAll = false;
@@ -3005,7 +3018,7 @@ public class QueryManagerImpl extends ManagerBase implements QueryService
{
 
         return searchForTemplatesInternal(cmd.getId(), cmd.getIsoName(), cmd.getKeyword(),
isoFilter, true,
                 cmd.isBootable(), cmd.getPageSizeVal(), cmd.getStartIndex(), cmd.getZoneId(),
hypervisorType, true,
-                cmd.listInReadyState(), permittedAccounts, caller, listProjectResourcesCriteria,
tags);
+                cmd.listInReadyState(), permittedAccounts, caller, listProjectResourcesCriteria,
tags, showRemovedIso);
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/5eb5594e/server/src/com/cloud/api/query/vo/TemplateJoinVO.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/vo/TemplateJoinVO.java b/server/src/com/cloud/api/query/vo/TemplateJoinVO.java
index bb1cfed..618b813 100644
--- a/server/src/com/cloud/api/query/vo/TemplateJoinVO.java
+++ b/server/src/com/cloud/api/query/vo/TemplateJoinVO.java
@@ -82,7 +82,7 @@ public class TemplateJoinVO extends BaseViewVO implements ControlledViewEntity
{
     @Column(name="created_on_store")
     private Date createdOnStore = null;
 
-    @Column(name=GenericDao.REMOVED_COLUMN)
+    @Column(name=GenericDao.REMOVED)
     @Temporal(TemporalType.TIMESTAMP)
     private Date removed;
 


Mime
View raw message