cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject [1/2] git commit: updated refs/heads/object_store to 0acce2c
Date Fri, 14 Jun 2013 22:15:02 GMT
Updated Branches:
  refs/heads/object_store c5083a385 -> 0acce2c51


Remove state from vm_template table, we should use template_store_ref
state column to represent the state of a template in each zone.

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

Branch: refs/heads/object_store
Commit: bb85a564dabe82dfbe16b80ee7e9cc74cbc000ee
Parents: c5083a3
Author: Min Chen <min.chen@citrix.com>
Authored: Fri Jun 14 15:14:09 2013 -0700
Committer: Min Chen <min.chen@citrix.com>
Committed: Fri Jun 14 15:14:09 2013 -0700

----------------------------------------------------------------------
 client/tomcatconf/applicationContext.xml.in     |   1 -
 .../src/com/cloud/storage/VMTemplateVO.java     |  14 +-
 .../com/cloud/storage/dao/VMTemplateDao.java    |   3 +-
 .../cloud/storage/dao/VMTemplateDaoImpl.java    | 181 ++++++++-----------
 .../storage/image/TemplateServiceImpl.java      |  39 +---
 .../storage/image/manager/ImageDataManager.java |  30 ---
 .../image/manager/ImageDataManagerImpl.java     |  52 ------
 .../storage/image/store/TemplateObject.java     |  27 ++-
 .../api/query/dao/TemplateJoinDaoImpl.java      |  11 +-
 .../com/cloud/api/query/vo/TemplateJoinVO.java  |  26 +--
 setup/db/db/schema-410to420.sql                 |   5 +-
 11 files changed, 109 insertions(+), 280 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bb85a564/client/tomcatconf/applicationContext.xml.in
----------------------------------------------------------------------
diff --git a/client/tomcatconf/applicationContext.xml.in b/client/tomcatconf/applicationContext.xml.in
index 0193642..8d251ee 100644
--- a/client/tomcatconf/applicationContext.xml.in
+++ b/client/tomcatconf/applicationContext.xml.in
@@ -764,7 +764,6 @@
   <bean id="iSCSI" class="org.apache.cloudstack.storage.datastore.type.ISCSI" />
   <bean id="ISO" class="org.apache.cloudstack.storage.image.format.ISO" />
   <bean id="templateDataFactoryImpl" class="org.apache.cloudstack.storage.image.TemplateDataFactoryImpl"
/>
-  <bean id="imageDataManagerImpl" class="org.apache.cloudstack.storage.image.manager.ImageDataManagerImpl"
/>
   <bean id="imageStoreHelper" class="org.apache.cloudstack.storage.image.datastore.ImageStoreHelper"
/>
   <bean id="imageFormatHelper" class="org.apache.cloudstack.storage.image.format.ImageFormatHelper"
/>
   <bean id="templateServiceImpl" class="org.apache.cloudstack.storage.image.TemplateServiceImpl"
/>

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bb85a564/engine/schema/src/com/cloud/storage/VMTemplateVO.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/VMTemplateVO.java b/engine/schema/src/com/cloud/storage/VMTemplateVO.java
index 00c394f..ac5f021 100755
--- a/engine/schema/src/com/cloud/storage/VMTemplateVO.java
+++ b/engine/schema/src/com/cloud/storage/VMTemplateVO.java
@@ -42,7 +42,7 @@ import com.cloud.utils.fsm.StateObject;
 
 @Entity
 @Table(name = "vm_template")
-public class VMTemplateVO implements VirtualMachineTemplate, StateObject<TemplateState>
{
+public class VMTemplateVO implements VirtualMachineTemplate {
     @Id
     @TableGenerator(name = "vm_template_sq", table = "sequence", pkColumnName = "name", valueColumnName
= "value",
             pkColumnValue = "vm_template_seq", allocationSize = 1)
@@ -133,9 +133,6 @@ public class VMTemplateVO implements VirtualMachineTemplate, StateObject<Templat
     @Column(name = "size")
     private Long size;
 
-    @Column(name = "state")
-    private TemplateState state;
-
     @Column(name = "update_count", updatable = true)
     protected long updatedCount;
 
@@ -157,7 +154,6 @@ public class VMTemplateVO implements VirtualMachineTemplate, StateObject<Templat
 
     public VMTemplateVO() {
         this.uuid = UUID.randomUUID().toString();
-        this.state = TemplateState.Allocated;
     }
 
     /**
@@ -171,7 +167,6 @@ public class VMTemplateVO implements VirtualMachineTemplate, StateObject<Templat
                 null, requiresHvm, bits, accountId, cksum, displayText, enablePassword, guestOSId,
bootable, hyperType,
                 details);
         this.uuid = UUID.randomUUID().toString();
-        this.state = TemplateState.Allocated;
     }
 
     public VMTemplateVO(long id, String name, ImageFormat format, boolean isPublic, boolean
featured,
@@ -182,7 +177,6 @@ public class VMTemplateVO implements VirtualMachineTemplate, StateObject<Templat
                 displayText, enablePassword, guestOSId, bootable, hyperType, details);
         this.templateTag = templateTag;
         this.uuid = UUID.randomUUID().toString();
-        this.state = TemplateState.Allocated;
         this.enableSshKey = sshKeyEnabled;
     }
 
@@ -192,7 +186,6 @@ public class VMTemplateVO implements VirtualMachineTemplate, StateObject<Templat
             boolean bootable, HypervisorType hyperType) {
         VMTemplateVO template = new VMTemplateVO(id, uniqueName, name, format, isPublic,
featured, type, url, created,
                 requiresHvm, bits, accountId, cksum, displayText, enablePassword, guestOSId,
bootable, hyperType);
-        template.state = TemplateState.Ready;
         return template;
     }
 
@@ -219,7 +212,6 @@ public class VMTemplateVO implements VirtualMachineTemplate, StateObject<Templat
         this.bootable = bootable;
         this.hypervisorType = hyperType;
         this.uuid = UUID.randomUUID().toString();
-        this.state = TemplateState.Allocated;
     }
 
     // Has an extra attribute - isExtractable
@@ -532,10 +524,6 @@ public class VMTemplateVO implements VirtualMachineTemplate, StateObject<Templat
         return this.size;
     }
 
-    public TemplateState getState() {
-        return this.state;
-    }
-
     public long getUpdatedCount() {
         return this.updatedCount;
     }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bb85a564/engine/schema/src/com/cloud/storage/dao/VMTemplateDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/VMTemplateDao.java b/engine/schema/src/com/cloud/storage/dao/VMTemplateDao.java
index b80ad3a..c3d44bd 100755
--- a/engine/schema/src/com/cloud/storage/dao/VMTemplateDao.java
+++ b/engine/schema/src/com/cloud/storage/dao/VMTemplateDao.java
@@ -30,8 +30,7 @@ import com.cloud.utils.fsm.StateDao;
 /*
  * Data Access Object for vm_templates table
  */
-public interface VMTemplateDao extends GenericDao<VMTemplateVO, Long>,
-        StateDao<TemplateState, TemplateEvent, VMTemplateVO> {
+public interface VMTemplateDao extends GenericDao<VMTemplateVO, Long> {
 
     public List<VMTemplateVO> listByPublic();
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bb85a564/engine/schema/src/com/cloud/storage/dao/VMTemplateDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/com/cloud/storage/dao/VMTemplateDaoImpl.java b/engine/schema/src/com/cloud/storage/dao/VMTemplateDaoImpl.java
index 21dd0ad..e7b85f8 100755
--- a/engine/schema/src/com/cloud/storage/dao/VMTemplateDaoImpl.java
+++ b/engine/schema/src/com/cloud/storage/dao/VMTemplateDaoImpl.java
@@ -102,7 +102,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO,
Long> implem
     private SearchBuilder<VMTemplateVO> PublicIsoSearch;
     private SearchBuilder<VMTemplateVO> UserIsoSearch;
     private GenericSearchBuilder<VMTemplateVO, Long> CountTemplatesByAccount;
-    private SearchBuilder<VMTemplateVO> updateStateSearch;
+   // private SearchBuilder<VMTemplateVO> updateStateSearch;
 
     @Inject
     ResourceTagDao _tagsDao;
@@ -369,11 +369,11 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO,
Long> implem
         CountTemplatesByAccount.and("removed", CountTemplatesByAccount.entity().getRemoved(),
SearchCriteria.Op.NULL);
         CountTemplatesByAccount.done();
 
-        updateStateSearch = this.createSearchBuilder();
-        updateStateSearch.and("id", updateStateSearch.entity().getId(), Op.EQ);
-        updateStateSearch.and("state", updateStateSearch.entity().getState(), Op.EQ);
-        updateStateSearch.and("updatedCount", updateStateSearch.entity().getUpdatedCount(),
Op.EQ);
-        updateStateSearch.done();
+//        updateStateSearch = this.createSearchBuilder();
+//        updateStateSearch.and("id", updateStateSearch.entity().getId(), Op.EQ);
+//        updateStateSearch.and("state", updateStateSearch.entity().getState(), Op.EQ);
+//        updateStateSearch.and("updatedCount", updateStateSearch.entity().getUpdatedCount(),
Op.EQ);
+//        updateStateSearch.done();
 
         return result;
     }
@@ -390,25 +390,25 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO,
Long> implem
      * pageSize, Long startIndex, Long zoneId, HypervisorType hyperType, boolean
      * onlyReady, boolean showDomr, List<Account> permittedAccounts, Account
      * caller, Map<String, String> tags) {
-     * 
+     *
      * StringBuilder builder = new StringBuilder(); if
      * (!permittedAccounts.isEmpty()) { for (Account permittedAccount :
      * permittedAccounts) { builder.append(permittedAccount.getAccountId() +
      * ","); } }
-     * 
+     *
      * String permittedAccountsStr = builder.toString();
-     * 
+     *
      * if (permittedAccountsStr.length() > 0) { // chop the "," off
      * permittedAccountsStr = permittedAccountsStr.substring(0,
      * permittedAccountsStr.length() - 1); }
-     * 
+     *
      * Transaction txn = Transaction.currentTxn(); txn.start();
-     * 
+     *
      * Set<Pair<Long, Long>> templateZonePairList = new HashSet<Pair<Long,
      * Long>>(); PreparedStatement pstmt = null; ResultSet rs = null; String sql
      * = SELECT_TEMPLATE_SWIFT_REF; try { String joinClause = ""; String
      * whereClause = " WHERE t.removed IS NULL";
-     * 
+     *
      * if (isIso) { whereClause += " AND t.format = 'ISO'"; if
      * (!hyperType.equals(HypervisorType.None)) { joinClause =
      * " INNER JOIN guest_os guestOS on (guestOS.id = t.guest_os_id) INNER JOIN guest_os_hypervisor
goh on ( goh.guest_os_id = guestOS.id) "
@@ -424,12 +424,12 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO,
Long> implem
      * (keyword != null) { whereClause += " AND t.name LIKE \"%" + keyword +
      * "%\""; } else if (name != null) { whereClause += " AND t.name LIKE \"%" +
      * name + "%\""; }
-     * 
+     *
      * if (bootable != null) { whereClause += " AND t.bootable = " + bootable; }
-     * 
+     *
      * if (!showDomr) { whereClause += " AND t.type != '" +
      * Storage.TemplateType.SYSTEM.toString() + "'"; }
-     * 
+     *
      * if (templateFilter == TemplateFilter.featured) { whereClause +=
      * " AND t.public = 1 AND t.featured = 1"; } else if ((templateFilter ==
      * TemplateFilter.self || templateFilter == TemplateFilter.selfexecutable)
@@ -455,20 +455,20 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO,
Long> implem
      * TemplateFilter.all && caller.getType() == Account.ACCOUNT_TYPE_ADMIN) { }
      * else if (caller.getType() != Account.ACCOUNT_TYPE_ADMIN) { return
      * templateZonePairList; }
-     * 
+     *
      * sql += joinClause + whereClause + getOrderByLimit(pageSize, startIndex);
      * pstmt = txn.prepareStatement(sql); rs = pstmt.executeQuery(); while
      * (rs.next()) { Pair<Long, Long> templateZonePair = new Pair<Long,
      * Long>(rs.getLong(1), -1L); templateZonePairList.add(templateZonePair); }
-     * 
+     *
      * } catch (Exception e) { s_logger.warn("Error listing templates", e); }
      * finally { try { if (rs != null) { rs.close(); } if (pstmt != null) {
      * pstmt.close(); } txn.commit(); } catch (SQLException sqle) {
      * s_logger.warn("Error in cleaning up", sqle); } }
-     * 
+     *
      * return templateZonePairList; }
-     * 
-     * 
+     *
+     *
      * @Override public Set<Pair<Long, Long>> searchTemplates(String name,
      * String keyword, TemplateFilter templateFilter, boolean isIso,
      * List<HypervisorType> hypers, Boolean bootable, DomainVO domain, Long
@@ -479,15 +479,15 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO,
Long> implem
      * StringBuilder(); if (!permittedAccounts.isEmpty()) { for (Account
      * permittedAccount : permittedAccounts) {
      * builder.append(permittedAccount.getAccountId() + ","); } }
-     * 
+     *
      * String permittedAccountsStr = builder.toString();
-     * 
+     *
      * if (permittedAccountsStr.length() > 0) { //chop the "," off
      * permittedAccountsStr = permittedAccountsStr.substring(0,
      * permittedAccountsStr.length()-1); }
-     * 
+     *
      * Transaction txn = Transaction.currentTxn(); txn.start();
-     * 
+     *
      * // Use LinkedHashSet here to guarantee iteration order Set<Pair<Long,
      * Long>> templateZonePairList = new LinkedHashSet<Pair<Long, Long>>();
      * PreparedStatement pstmt = null; ResultSet rs = null; StringBuilder
@@ -496,7 +496,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO,
Long> implem
      * accountType; //String accountId = null; String guestOSJoin = "";
      * StringBuilder templateHostRefJoin = new StringBuilder(); String
      * dataCenterJoin = "", lpjoin = ""; String tagsJoin = "";
-     * 
+     *
      * if (isIso && !hyperType.equals(HypervisorType.None)) { guestOSJoin =
      * " INNER JOIN guest_os guestOS on (guestOS.id = t.guest_os_id) INNER JOIN guest_os_hypervisor
goh on ( goh.guest_os_id = guestOS.id) "
      * ; } if (onlyReady){ templateHostRefJoin.append(
@@ -506,22 +506,22 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO,
Long> implem
      * TemplateFilter.featured) || (templateFilter == TemplateFilter.community))
      * { dataCenterJoin =
      * " INNER JOIN data_center dc on (h.data_center_id = dc.id)"; }
-     * 
+     *
      * if (zoneType != null) { dataCenterJoin =
      * " INNER JOIN template_host_ref thr on (t.id = thr.template_id) INNER JOIN host h on
(thr.host_id = h.id)"
      * ; dataCenterJoin +=
      * " INNER JOIN data_center dc on (h.data_center_id = dc.id)"; }
-     * 
+     *
      * if (templateFilter == TemplateFilter.sharedexecutable || templateFilter
      * == TemplateFilter.shared ){ lpjoin =
      * " INNER JOIN launch_permission lp ON t.id = lp.template_id "; }
-     * 
+     *
      * if (tags != null && !tags.isEmpty()) { tagsJoin =
      * " INNER JOIN resource_tags r ON t.id = r.resource_id "; }
-     * 
+     *
      * sql += guestOSJoin + templateHostRefJoin + dataCenterJoin + lpjoin +
      * tagsJoin; String whereClause = "";
-     * 
+     *
      * //All joins have to be made before we start setting the condition
      * settings if ((listProjectResourcesCriteria ==
      * ListProjectResourcesCriteria.SkipProjectResources ||
@@ -541,19 +541,19 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO,
Long> implem
      * (listProjectResourcesCriteria ==
      * ListProjectResourcesCriteria.SkipProjectResources) { whereClause +=
      * " WHERE a.type != " + Account.ACCOUNT_TYPE_PROJECT; } }
-     * 
+     *
      * if (!permittedAccounts.isEmpty()) { for (Account account :
      * permittedAccounts) { //accountType = account.getType(); //accountId =
      * Long.toString(account.getId()); DomainVO accountDomain =
      * _domainDao.findById(account.getDomainId());
-     * 
+     *
      * // get all parent domain ID's all the way till root domain DomainVO
      * domainTreeNode = accountDomain; while (true) {
      * relatedDomainIds.append(domainTreeNode.getId());
      * relatedDomainIds.append(","); if (domainTreeNode.getParent() != null) {
      * domainTreeNode = _domainDao.findById(domainTreeNode.getParent()); } else
      * { break; } }
-     * 
+     *
      * // get all child domain ID's if (isAdmin(account.getType()) ) {
      * List<DomainVO> allChildDomains =
      * _domainDao.findAllChildren(accountDomain.getPath(),
@@ -561,10 +561,10 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO,
Long> implem
      * relatedDomainIds.append(childDomain.getId());
      * relatedDomainIds.append(","); } }
      * relatedDomainIds.setLength(relatedDomainIds.length()-1); } }
-     * 
+     *
      * String attr = " AND "; if (whereClause.endsWith(" WHERE ")) { attr +=
      * " WHERE "; }
-     * 
+     *
      * if (!isIso) { if ( hypers.isEmpty() ) { return templateZonePairList; }
      * else { StringBuilder relatedHypers = new StringBuilder(); for
      * (HypervisorType hyper : hypers ) { relatedHypers.append("'");
@@ -572,14 +572,14 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO,
Long> implem
      * relatedHypers.append(","); }
      * relatedHypers.setLength(relatedHypers.length()-1); whereClause += attr +
      * " t.hypervisor_type IN (" + relatedHypers + ")"; } }
-     * 
+     *
      * if (!permittedAccounts.isEmpty() && !(templateFilter ==
      * TemplateFilter.featured || templateFilter == TemplateFilter.community ||
      * templateFilter == TemplateFilter.executable || templateFilter ==
      * TemplateFilter.shared || templateFilter ==
      * TemplateFilter.sharedexecutable) && !isAdmin(caller.getType()) ) {
      * whereClause += attr + "t.account_id IN (" + permittedAccountsStr + ")"; }
-     * 
+     *
      * if (templateFilter == TemplateFilter.featured) { whereClause += attr +
      * "t.public = 1 AND t.featured = 1"; if (!permittedAccounts.isEmpty()) {
      * whereClause += attr + "(dc.domain_id IN (" + relatedDomainIds +
@@ -599,22 +599,22 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO,
Long> implem
      * "(dc.domain_id IN (" + relatedDomainIds + ") OR dc.domain_id is NULL)"; }
      * } else if (caller.getType() != Account.ACCOUNT_TYPE_ADMIN && !isIso) {
      * return templateZonePairList; }
-     * 
+     *
      * if (tags != null && !tags.isEmpty()) { whereClause += " AND ("; boolean
      * first = true; for (String key : tags.keySet()) { if (!first) {
      * whereClause += " OR "; } whereClause += "(r.key=\"" + key +
      * "\" and r.value=\"" + tags.get(key) + "\")"; first = false; } whereClause
      * += ")"; }
-     * 
+     *
      * if (whereClause.equals("")) { whereClause += " WHERE "; } else if
      * (!whereClause.equals(" WHERE ")) { whereClause += " AND "; }
-     * 
+     *
      * sql += whereClause + getExtrasWhere(templateFilter, name, keyword, isIso,
      * bootable, hyperType, zoneId, onlyReady, showDomr, zoneType) +
      * groupByClause + getOrderByLimit(pageSize, startIndex);
-     * 
+     *
      * pstmt = txn.prepareStatement(sql); rs = pstmt.executeQuery();
-     * 
+     *
      * while (rs.next()) { Pair<Long, Long> templateZonePair = new Pair<Long,
      * Long>(rs.getLong(1), rs.getLong(2));
      * templateZonePairList.add(templateZonePair); } //for now, defaulting
@@ -623,18 +623,18 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO,
Long> implem
      * templateFilter != TemplateFilter.community && !(templateFilter ==
      * TemplateFilter.self && !BaseCmd.isRootAdmin(caller.getType())) ){
      * //evaluates to true If root admin and filter=self
-     * 
+     *
      * List<VMTemplateVO> publicIsos = publicIsoSearch(bootable, false, tags);
      * List<VMTemplateVO> userIsos = userIsoSearch(false);
-     * 
+     *
      * //Listing the ISOs according to the page size.Restricting the total no.
      * of ISOs on a page //to be less than or equal to the pageSize parameter
-     * 
+     *
      * int i=0;
-     * 
+     *
      * if (startIndex > userIsos.size()) { i=(int) (startIndex -
      * userIsos.size()); }
-     * 
+     *
      * for (; i < publicIsos.size(); i++) { if(templateZonePairList.size() >=
      * pageSize){ break; } else { if (keyword != null &&
      * publicIsos.get(i).getName().contains(keyword)) {
@@ -649,7 +649,7 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO,
Long> implem
      * null) { rs.close(); } if (pstmt != null) { pstmt.close(); } txn.commit();
      * } catch( SQLException sqle) { s_logger.warn("Error in cleaning up",
      * sqle); } }
-     * 
+     *
      * return templateZonePairList; }
      */
 
@@ -660,39 +660,39 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO,
Long> implem
      * zoneType) { String sql = ""; if (keyword != null) { sql +=
      * " t.name LIKE \"%" + keyword + "%\" AND"; } else if (name != null) { sql
      * += " t.name LIKE \"%" + name + "%\" AND"; }
-     * 
+     *
      * if (isIso) { sql += " t.format = 'ISO'"; if
      * (!hyperType.equals(HypervisorType.None)) { sql +=
      * " AND goh.hypervisor_type = '" + hyperType.toString() + "'"; } } else {
      * sql += " t.format <> 'ISO'"; if (!hyperType.equals(HypervisorType.None))
      * { sql += " AND t.hypervisor_type = '" + hyperType.toString() + "'"; } }
-     * 
+     *
      * if (bootable != null) { sql += " AND t.bootable = " + bootable; }
-     * 
+     *
      * if (onlyReady){ sql += " AND thr.download_state = '"
      * +Status.DOWNLOADED.toString() + "'" + " AND thr.destroyed=0 "; if (zoneId
      * != null){ sql += " AND h.data_center_id = " +zoneId; } }else if (zoneId
      * != null){ sql += " AND tzr.zone_id = " +zoneId+
      * " AND tzr.removed is null" ; }else{ sql += " AND tzr.removed is null "; }
-     * 
+     *
      * if (zoneType != null){ sql += " AND dc.networktype = '" + zoneType + "'";
      * }
-     * 
+     *
      * if (!showDomr){ sql += " AND t.type != '"
      * +Storage.TemplateType.SYSTEM.toString() + "'"; }
-     * 
+     *
      * sql += " AND t.removed IS NULL";
-     * 
+     *
      * return sql; }
-     * 
+     *
      * private String getOrderByLimit(Long pageSize, Long startIndex) { Boolean
      * isAscending =
      * Boolean.parseBoolean(_configDao.getValue("sortkey.algorithm"));
      * isAscending = (isAscending == null ? true : isAscending);
-     * 
+     *
      * String sql; if (isAscending) { sql = " ORDER BY t.sort_key ASC"; } else {
      * sql = " ORDER BY t.sort_key DESC"; }
-     * 
+     *
      * if ((pageSize != null) && (startIndex != null)) { sql += " LIMIT " +
      * startIndex.toString() + "," + pageSize.toString(); } return sql; }
      */
@@ -849,17 +849,17 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO,
Long> implem
      * Long zoneId, final HypervisorType hyperType, final boolean onlyReady,
      * final boolean showDomr, final List<Account> permittedAccounts, final
      * Account caller, final Map<String, String> tags) {
-     * 
+     *
      * final String permittedAccountsStr = join(",", permittedAccounts);
-     * 
+     *
      * final Transaction txn = Transaction.currentTxn(); txn.start();
-     * 
+     *
      * Set<Pair<Long, Long>> templateZonePairList = new HashSet<Pair<Long,
      * Long>>(); PreparedStatement pstmt = null; ResultSet rs = null; try {
-     * 
+     *
      * final StringBuilder joinClause = new StringBuilder(); final StringBuilder
      * whereClause = new StringBuilder(" WHERE t.removed IS NULL");
-     * 
+     *
      * if (isIso) { whereClause.append(" AND t.format = 'ISO'"); if
      * (!hyperType.equals(HypervisorType.None)) { joinClause.append(
      * " INNER JOIN guest_os guestOS on (guestOS.id = t.guest_os_id) INNER JOIN guest_os_hypervisor
goh on ( goh.guest_os_id = guestOS.id) "
@@ -873,20 +873,20 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO,
Long> implem
      * relatedHypers.setLength(relatedHypers.length() - 1);
      * whereClause.append(" AND t.hypervisor_type IN (");
      * whereClause.append(relatedHypers); whereClause.append(")"); } }
-     * 
+     *
      * joinClause.append(
      * " INNER JOIN  template_s3_ref tsr on (t.id = tsr.template_id)");
-     * 
+     *
      * whereClause.append("AND t.name LIKE \"%"); whereClause.append(keyword ==
      * null ? keyword : name); whereClause.append("%\"");
-     * 
+     *
      * if (bootable != null) { whereClause.append(" AND t.bootable = ");
      * whereClause.append(bootable); }
-     * 
+     *
      * if (!showDomr) { whereClause.append(" AND t.type != '");
      * whereClause.append(Storage.TemplateType.SYSTEM); whereClause.append("'");
      * }
-     * 
+     *
      * if (templateFilter == TemplateFilter.featured) {
      * whereClause.append(" AND t.public = 1 AND t.featured = 1"); } else if
      * ((templateFilter == TemplateFilter.self || templateFilter ==
@@ -916,11 +916,11 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO,
Long> implem
      * (templateFilter == TemplateFilter.all && caller.getType() ==
      * Account.ACCOUNT_TYPE_ADMIN) { } else if (caller.getType() !=
      * Account.ACCOUNT_TYPE_ADMIN) { return templateZonePairList; }
-     * 
+     *
      * final StringBuilder sql = new StringBuilder(SELECT_TEMPLATE_S3_REF);
      * sql.append(joinClause); sql.append(whereClause);
      * sql.append(getOrderByLimit(pageSize, startIndex));
-     * 
+     *
      * pstmt = txn.prepareStatement(sql.toString()); rs = pstmt.executeQuery();
      * while (rs.next()) { final Pair<Long, Long> templateZonePair = new
      * Pair<Long, Long>( rs.getLong(1), -1L);
@@ -928,46 +928,9 @@ public class VMTemplateDaoImpl extends GenericDaoBase<VMTemplateVO,
Long> implem
      * (Exception e) { s_logger.warn("Error listing S3 templates", e); if (txn
      * != null) { txn.rollback(); } } finally { closeResources(pstmt, rs); if
      * (txn != null) { txn.close(); } }
-     * 
+     *
      * return templateZonePairList; }
      */
 
-    @Override
-    public boolean updateState(TemplateState currentState, TemplateEvent event, TemplateState
nextState,
-            VMTemplateVO vo, Object data) {
-        Long oldUpdated = vo.getUpdatedCount();
-        Date oldUpdatedTime = vo.getUpdated();
-
-        SearchCriteria<VMTemplateVO> sc = updateStateSearch.create();
-        sc.setParameters("id", vo.getId());
-        sc.setParameters("state", currentState);
-        sc.setParameters("updatedCount", vo.getUpdatedCount());
-
-        vo.incrUpdatedCount();
-
-        UpdateBuilder builder = getUpdateBuilder(vo);
-        builder.set(vo, "state", nextState);
-        builder.set(vo, "updated", new Date());
-
-        int rows = update((VMTemplateVO) vo, sc);
-        if (rows == 0 && s_logger.isDebugEnabled()) {
-            VMTemplateVO dbVol = findByIdIncludingRemoved(vo.getId());
-            if (dbVol != null) {
-                StringBuilder str = new StringBuilder("Unable to update ").append(vo.toString());
-                str.append(": DB Data={id=").append(dbVol.getId()).append("; state=").append(dbVol.getState())
-                        .append("; updatecount=").append(dbVol.getUpdatedCount()).append(";updatedTime=")
-                        .append(dbVol.getUpdated());
-                str.append(": New Data={id=").append(vo.getId()).append("; state=").append(nextState)
-                        .append("; event=").append(event).append("; updatecount=").append(vo.getUpdatedCount())
-                        .append("; updatedTime=").append(vo.getUpdated());
-                str.append(": stale Data={id=").append(vo.getId()).append("; state=").append(currentState)
-                        .append("; event=").append(event).append("; updatecount=").append(oldUpdated)
-                        .append("; updatedTime=").append(oldUpdatedTime);
-            } else {
-                s_logger.debug("Unable to update objectIndatastore: id=" + vo.getId()
-                        + ", as there is no such object exists in the database anymore");
-            }
-        }
-        return rows > 0;
-    }
+
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bb85a564/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java
b/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java
index 9b6382b..c06756e 100644
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/TemplateServiceImpl.java
@@ -56,7 +56,6 @@ import org.apache.cloudstack.storage.datastore.DataObjectManager;
 import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
 import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
-import org.apache.cloudstack.storage.image.manager.ImageDataManager;
 import org.apache.cloudstack.storage.image.store.TemplateObject;
 import org.apache.cloudstack.storage.to.TemplateObjectTO;
 import org.apache.log4j.Logger;
@@ -121,8 +120,6 @@ public class TemplateServiceImpl implements TemplateService {
     @Inject
     EndPointSelector _epSelector;
     @Inject
-    ImageDataManager imageMgr;
-    @Inject
     TemplateManager _tmpltMgr;
 
     class TemplateOpContext<T> extends AsyncRpcConext<T> {
@@ -324,19 +321,6 @@ public class TemplateServiceImpl implements TemplateService {
                         VMTemplateVO tmlpt = _templateDao.findById(tmplt.getId());
                         tmlpt.setSize(tmpltInfo.getSize());
                         _templateDao.update(tmplt.getId(), tmlpt);
-                        // set template to ready state
-                        if (tmplt.getState() != TemplateState.Ready) {
-                            try {
-                                imageMgr.getStateMachine().transitTo(tmplt, TemplateEvent.CreateRequested,
null,
-                                        _templateDao);
-                                imageMgr.getStateMachine().transitTo(tmplt, TemplateEvent.OperationSucceeded,
null,
-                                        _templateDao);
-                            } catch (NoTransitionException e) {
-                                // non fatal though
-                                s_logger.debug(
-                                        "failed to update template " + tmplt.getUniqueName()
+ " state to Ready", e);
-                            }
-                        }
 
                         if (tmpltInfo.getSize() > 0 && tmplt.getUrl() != null)
{
                             long accountId = tmplt.getAccountId();
@@ -370,18 +354,7 @@ public class TemplateServiceImpl implements TemplateService {
                     _templateDao.update(tmplt.getId(), tmlpt);
                     associateTemplateToZone(tmplt.getId(), zoneId);
 
-                    // set template to ready state
-                    if (tmplt.getState() != TemplateState.Ready) {
-                        try {
-                            imageMgr.getStateMachine().transitTo(tmplt, TemplateEvent.CreateRequested,
null,
-                                    _templateDao);
-                            imageMgr.getStateMachine().transitTo(tmplt, TemplateEvent.OperationSucceeded,
null,
-                                    _templateDao);
-                        } catch (NoTransitionException e) {
-                            // non fatal though
-                            s_logger.debug("failed to update template " + tmplt.getUniqueName()
+ " state to Ready", e);
-                        }
-                    }
+
                 }
             } else {
                 if (tmpltStore != null) {
@@ -623,16 +596,6 @@ public class TemplateServiceImpl implements TemplateService {
         long storeId = store.getId();
         List<VMTemplateVO> rtngTmplts = _templateDao.listAllSystemVMTemplates();
         for (VMTemplateVO tmplt : rtngTmplts) {
-            // set template ready state
-            if (tmplt.getState() != TemplateState.Ready) {
-                try {
-                    imageMgr.getStateMachine().transitTo(tmplt, TemplateEvent.CreateRequested,
null, _templateDao);
-                    imageMgr.getStateMachine().transitTo(tmplt, TemplateEvent.OperationSucceeded,
null, _templateDao);
-                } catch (NoTransitionException e) {
-                    // non fatal though
-                    s_logger.debug("failed to update system vm template state to Ready",
e);
-                }
-            }
             TemplateDataStoreVO tmpltStore = _vmTemplateStoreDao.findByStoreTemplate(storeId,
tmplt.getId());
             if (tmpltStore == null) {
                 tmpltStore = new TemplateDataStoreVO(storeId, tmplt.getId(), new Date(),
100, Status.DOWNLOADED, null,

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bb85a564/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataManager.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataManager.java
b/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataManager.java
deleted file mode 100644
index e1fd46b..0000000
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataManager.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cloudstack.storage.image.manager;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.TemplateEvent;
-import org.apache.cloudstack.engine.subsystem.api.storage.TemplateState;
-
-import com.cloud.storage.VMTemplateVO;
-import com.cloud.utils.fsm.StateMachine2;
-
-public interface ImageDataManager {
-    StateMachine2<TemplateState, TemplateEvent, VMTemplateVO> getStateMachine();
-
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bb85a564/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataManagerImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataManagerImpl.java
b/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataManagerImpl.java
deleted file mode 100644
index f41416b..0000000
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/manager/ImageDataManagerImpl.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.cloudstack.storage.image.manager;
-
-import org.apache.cloudstack.engine.subsystem.api.storage.TemplateEvent;
-import org.apache.cloudstack.engine.subsystem.api.storage.TemplateState;
-import org.springframework.stereotype.Component;
-
-import com.cloud.storage.VMTemplateVO;
-import com.cloud.utils.fsm.StateMachine2;
-
-@Component
-public class ImageDataManagerImpl implements ImageDataManager {
-    private final StateMachine2<TemplateState, TemplateEvent, VMTemplateVO> stateMachine
= new StateMachine2<TemplateState, TemplateEvent, VMTemplateVO>();
-
-    public ImageDataManagerImpl() {
-        stateMachine.addTransition(TemplateState.Allocated, TemplateEvent.CreateRequested,
TemplateState.Creating);
-        stateMachine.addTransition(TemplateState.Creating, TemplateEvent.CreateRequested,
TemplateState.Creating);
-        stateMachine.addTransition(TemplateState.Creating, TemplateEvent.OperationSucceeded,
TemplateState.Ready);
-        stateMachine.addTransition(TemplateState.Creating, TemplateEvent.OperationFailed,
TemplateState.Allocated);
-        stateMachine.addTransition(TemplateState.Creating, TemplateEvent.DestroyRequested,
TemplateState.Destroying);
-        stateMachine.addTransition(TemplateState.Ready, TemplateEvent.DestroyRequested, TemplateState.Destroying);
-        stateMachine.addTransition(TemplateState.Allocated, TemplateEvent.DestroyRequested,
TemplateState.Destroying);
-        stateMachine.addTransition(TemplateState.Destroying, TemplateEvent.DestroyRequested,
TemplateState.Destroying);
-        stateMachine.addTransition(TemplateState.Destroying, TemplateEvent.OperationFailed,
TemplateState.Destroying);
-        stateMachine.addTransition(TemplateState.Destroying, TemplateEvent.OperationSucceeded,
TemplateState.Destroyed);
-        // TODO: this should not be needed, but it happened during testing where
-        // multiple success event is sent to callback
-        stateMachine.addTransition(TemplateState.Ready, TemplateEvent.OperationSucceeded,
TemplateState.Ready);
-    }
-
-    @Override
-    public StateMachine2<TemplateState, TemplateEvent, VMTemplateVO> getStateMachine()
{
-        return stateMachine;
-    }
-}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bb85a564/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
----------------------------------------------------------------------
diff --git a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
index 9957791..72a8849 100644
--- a/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
+++ b/engine/storage/image/src/org/apache/cloudstack/storage/image/store/TemplateObject.java
@@ -33,7 +33,6 @@ import org.apache.cloudstack.storage.command.CopyCmdAnswer;
 import org.apache.cloudstack.storage.datastore.ObjectInDataStoreManager;
 import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
 import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreVO;
-import org.apache.cloudstack.storage.image.manager.ImageDataManager;
 import org.apache.cloudstack.storage.to.TemplateObjectTO;
 import org.apache.log4j.Logger;
 
@@ -58,8 +57,6 @@ public class TemplateObject implements TemplateInfo {
     private VMTemplateVO imageVO;
     private DataStore dataStore;
     @Inject
-    ImageDataManager imageMgr;
-    @Inject
     VMTemplateDao imageDao;
     @Inject
     ObjectInDataStoreManager objectInStoreMgr;
@@ -155,12 +152,12 @@ public class TemplateObject implements TemplateInfo {
         return this.imageVO.getFormat();
     }
 
-    public boolean stateTransit(TemplateEvent e) throws NoTransitionException {
-        this.imageVO = imageDao.findById(this.imageVO.getId());
-        boolean result = imageMgr.getStateMachine().transitTo(this.imageVO, e, null, imageDao);
-        this.imageVO = imageDao.findById(this.imageVO.getId());
-        return result;
-    }
+//    public boolean stateTransit(TemplateEvent e) throws NoTransitionException {
+//        this.imageVO = imageDao.findById(this.imageVO.getId());
+//        boolean result = imageMgr.getStateMachine().transitTo(this.imageVO, e, null, imageDao);
+//        this.imageVO = imageDao.findById(this.imageVO.getId());
+//        return result;
+//    }
 
     @Override
     public void processEvent(Event event) {
@@ -178,9 +175,9 @@ public class TemplateObject implements TemplateInfo {
                     templEvent = TemplateEvent.OperationFailed;
                 }
 
-                if (templEvent != null && this.getDataStore().getRole() == DataStoreRole.Image)
{
-                    this.stateTransit(templEvent);
-                }
+//                if (templEvent != null && this.getDataStore().getRole() == DataStoreRole.Image)
{
+//                    this.stateTransit(templEvent);
+//                }
             }
 
             objectInStoreMgr.update(this, event);
@@ -241,9 +238,9 @@ public class TemplateObject implements TemplateInfo {
                     templEvent = TemplateEvent.OperationFailed;
                 }
 
-                if (templEvent != null && this.getDataStore().getRole() == DataStoreRole.Image)
{
-                    this.stateTransit(templEvent);
-                }
+//                if (templEvent != null && this.getDataStore().getRole() == DataStoreRole.Image)
{
+//                    this.stateTransit(templEvent);
+//                }
             }
             objectInStoreMgr.update(this, event);
         } catch (NoTransitionException e) {

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bb85a564/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java b/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java
index 83291f8..0793093 100644
--- a/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java
+++ b/server/src/com/cloud/api/query/dao/TemplateJoinDaoImpl.java
@@ -27,6 +27,7 @@ import javax.inject.Inject;
 import org.apache.cloudstack.api.BaseCmd;
 import org.apache.cloudstack.api.response.TemplateResponse;
 import org.apache.cloudstack.api.response.TemplateZoneResponse;
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
 import org.apache.cloudstack.engine.subsystem.api.storage.TemplateState;
 import org.apache.log4j.Logger;
 import org.springframework.stereotype.Component;
@@ -103,7 +104,7 @@ public class TemplateJoinDaoImpl extends GenericDaoBase<TemplateJoinVO,
Long> im
         templateResponse.setDisplayText(template.getDisplayText());
         templateResponse.setPublic(template.isPublicTemplate());
         templateResponse.setCreated(template.getCreatedOnStore());
-        templateResponse.setReady(template.getState() == TemplateState.Ready);
+        templateResponse.setReady(template.getState() == ObjectInDataStoreStateMachine.State.Ready);
         templateResponse.setFeatured(template.isFeatured());
         templateResponse.setExtractable(template.isExtractable() && !(template.getTemplateType()
== TemplateType.SYSTEM));
         templateResponse.setPasswordEnabled(template.isEnablePassword());
@@ -293,7 +294,13 @@ public class TemplateJoinDaoImpl extends GenericDaoBase<TemplateJoinVO,
Long> im
         isoResponse.setPublic(iso.isPublicTemplate());
         isoResponse.setExtractable(iso.isExtractable() && !(iso.getTemplateType()
== TemplateType.PERHOST));
         isoResponse.setCreated(iso.getCreatedOnStore());
-        isoResponse.setReady(iso.getState() == TemplateState.Ready);
+        if ( iso.getTemplateType() == TemplateType.PERHOST ){
+            // for xs-tools.iso and vmware-tools.iso, we didn't download, but is ready to
use.
+            isoResponse.setReady(true);
+        }
+        else{
+            isoResponse.setReady(iso.getState() == ObjectInDataStoreStateMachine.State.Ready);
+        }
         isoResponse.setBootable(iso.isBootable());
         isoResponse.setFeatured(iso.isFeatured());
         isoResponse.setCrossZones(iso.isCrossZones());

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bb85a564/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 ef6d1eb..03dce99 100644
--- a/server/src/com/cloud/api/query/vo/TemplateJoinVO.java
+++ b/server/src/com/cloud/api/query/vo/TemplateJoinVO.java
@@ -26,17 +26,12 @@ import javax.persistence.Table;
 import javax.persistence.Temporal;
 import javax.persistence.TemporalType;
 
-import org.apache.cloudstack.api.Identity;
-import org.apache.cloudstack.api.InternalIdentity;
-import org.apache.cloudstack.engine.subsystem.api.storage.TemplateState;
-
+import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreStateMachine;
 import com.cloud.hypervisor.Hypervisor.HypervisorType;
 import com.cloud.server.ResourceTag.TaggedResourceType;
 import com.cloud.storage.Storage;
-import com.cloud.storage.Volume;
 import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
 import com.cloud.utils.db.GenericDao;
-import com.cloud.vm.VirtualMachine;
 
 @Entity
 @Table(name="template_view")
@@ -240,9 +235,9 @@ public class TemplateJoinVO extends BaseViewVO implements ControlledViewEntity
{
     @Column(name="tag_customer")
     private String tagCustomer;
 
-    @Column(name="state")
-    @Enumerated(value=EnumType.STRING)
-    private TemplateState state;
+    @Column(name = "state")
+    @Enumerated(EnumType.STRING)
+    ObjectInDataStoreStateMachine.State state;
 
     public TemplateJoinVO() {
     }
@@ -1021,16 +1016,15 @@ public class TemplateJoinVO extends BaseViewVO implements ControlledViewEntity
{
 
 
 
-	public TemplateState getState() {
-		return state;
-	}
-
+    public ObjectInDataStoreStateMachine.State getState() {
+        return state;
+    }
 
 
-	public void setState(TemplateState state) {
-		this.state = state;
-	}
 
+    public void setState(ObjectInDataStoreStateMachine.State state) {
+        this.state = state;
+    }
 
 
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/bb85a564/setup/db/db/schema-410to420.sql
----------------------------------------------------------------------
diff --git a/setup/db/db/schema-410to420.sql b/setup/db/db/schema-410to420.sql
index 74d4cae..387e909 100644
--- a/setup/db/db/schema-410to420.sql
+++ b/setup/db/db/schema-410to420.sql
@@ -1830,7 +1830,7 @@ CREATE VIEW `cloud`.`template_view` AS
         vm_template.display_text,
         vm_template.enable_password,
         vm_template.guest_os_id,
-        vm_template.state,
+        -- vm_template.state,
         guest_os.uuid guest_os_uuid,
         guest_os.display_name guest_os_name,
         vm_template.bootable,
@@ -1860,6 +1860,7 @@ CREATE VIEW `cloud`.`template_view` AS
         data_center.name data_center_name,
         launch_permission.account_id lp_account_id,
         template_store_ref.store_id,
+        template_store_ref.state,
         template_store_ref.download_state,
         template_store_ref.download_pct,
         template_store_ref.error_str,
@@ -1898,7 +1899,7 @@ CREATE VIEW `cloud`.`template_view` AS
             left join
         `cloud`.`data_center` ON template_zone_ref.zone_id = data_center.id
             left join
-        `cloud`.`image_store` ON image_store.data_center_id = data_center.id OR image_store.scope
= 'REGION'
+        `cloud`.`image_store` ON image_store.removed is NULL AND (image_store.data_center_id
= data_center.id OR image_store.scope = 'REGION')
             left join
         `cloud`.`template_store_ref` ON template_store_ref.template_id = vm_template.id AND
template_store_ref.store_id = image_store.id
             left join


Mime
View raw message