cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bhais...@apache.org
Subject [05/50] [abbrv] git commit: updated refs/heads/saml2 to ba68616
Date Sun, 24 Aug 2014 14:04:25 GMT
CLOUDSTACK-7155 Re-copying templates to other zones doesn't work


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

Branch: refs/heads/saml2
Commit: cab2b12d7d2a37bb4d8e157bd12dee3117d1e8f0
Parents: ffa4d73
Author: Bharat Kumar <bharat.kumar@citrix.com>
Authored: Tue Aug 19 20:09:02 2014 +0530
Committer: root <root@kk-dev47.lab.citrite.net>
Committed: Thu Aug 21 09:50:54 2014 +0530

----------------------------------------------------------------------
 .../storage/datastore/db/TemplateDataStoreDao.java        |  2 ++
 .../storage/image/db/TemplateDataStoreDaoImpl.java        | 10 ++++++++++
 .../src/com/cloud/template/HypervisorTemplateAdapter.java |  5 +++++
 server/src/com/cloud/template/TemplateManagerImpl.java    |  3 +++
 4 files changed, 20 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cab2b12d/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java
b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java
index cb15949..13c4d31 100644
--- a/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java
+++ b/engine/schema/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java
@@ -76,4 +76,6 @@ public interface TemplateDataStoreDao extends GenericDao<TemplateDataStoreVO,
Lo
     void updateStoreRoleToCachce(long storeId);
 
     List<TemplateDataStoreVO> listTemplateDownloadUrls();
+
+    void removeByTemplateStore(long templateId, long imageStoreId);
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cab2b12d/engine/storage/src/org/apache/cloudstack/storage/image/db/TemplateDataStoreDaoImpl.java
----------------------------------------------------------------------
diff --git a/engine/storage/src/org/apache/cloudstack/storage/image/db/TemplateDataStoreDaoImpl.java
b/engine/storage/src/org/apache/cloudstack/storage/image/db/TemplateDataStoreDaoImpl.java
index 50334f4..a5cf6f8 100644
--- a/engine/storage/src/org/apache/cloudstack/storage/image/db/TemplateDataStoreDaoImpl.java
+++ b/engine/storage/src/org/apache/cloudstack/storage/image/db/TemplateDataStoreDaoImpl.java
@@ -292,6 +292,16 @@ public class TemplateDataStoreDaoImpl extends GenericDaoBase<TemplateDataStoreVO
     }
 
     @Override
+    public  void removeByTemplateStore(long templateId, long imageStoreId) {
+        SearchCriteria<TemplateDataStoreVO> sc = storeTemplateSearch.create();
+        sc.setParameters("template_id", templateId);
+        sc.setParameters("store_id", imageStoreId);
+        sc.setParameters("destroyed", false);
+        expunge(sc);
+
+    }
+
+    @Override
     public TemplateDataStoreVO findByTemplateZoneDownloadStatus(long templateId, Long zoneId,
Status... status) {
         // get all elgible image stores
         List<DataStore> imgStores = _storeMgr.getImageStoresByScope(new ZoneScope(zoneId));

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cab2b12d/server/src/com/cloud/template/HypervisorTemplateAdapter.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/HypervisorTemplateAdapter.java b/server/src/com/cloud/template/HypervisorTemplateAdapter.java
index 72aaff5..42f4b55 100755
--- a/server/src/com/cloud/template/HypervisorTemplateAdapter.java
+++ b/server/src/com/cloud/template/HypervisorTemplateAdapter.java
@@ -27,6 +27,7 @@ import javax.inject.Inject;
 
 import org.apache.log4j.Logger;
 
+import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
 import org.apache.cloudstack.api.command.user.iso.DeleteIsoCmd;
 import org.apache.cloudstack.api.command.user.iso.RegisterIsoCmd;
 import org.apache.cloudstack.api.command.user.template.DeleteTemplateCmd;
@@ -83,6 +84,7 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase {
     @Inject
     AgentManager _agentMgr;
 
+    @Inject TemplateDataStoreDao templateDataStoreDao;
     @Inject
     DataStoreManager storeMgr;
     @Inject
@@ -306,6 +308,9 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase {
                             templateZoneDao.remove(templateZone.getId());
                         }
                     }
+                    //mark all the occurrences of this template in the given store as destroyed.
+                    templateDataStoreDao.removeByTemplateStore(template.getId(), imageStore.getId());
+
                 } catch (InterruptedException e) {
                     s_logger.debug("delete template Failed", e);
                     throw new CloudRuntimeException("delete template Failed", e);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/cab2b12d/server/src/com/cloud/template/TemplateManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/template/TemplateManagerImpl.java b/server/src/com/cloud/template/TemplateManagerImpl.java
index f5ad97f..9214459 100755
--- a/server/src/com/cloud/template/TemplateManagerImpl.java
+++ b/server/src/com/cloud/template/TemplateManagerImpl.java
@@ -648,6 +648,9 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
             if (dstTmpltStore != null && dstTmpltStore.getDownloadState() == Status.DOWNLOADED)
{
                 return true; // already downloaded on this image store
             }
+            if (dstTmpltStore != null && dstTmpltStore.getDownloadState() != Status.DOWNLOAD_IN_PROGRESS)
{
+                _tmplStoreDao.removeByTemplateStore(tmpltId, dstSecStore.getId());
+            }
 
             AsyncCallFuture<TemplateApiResult> future = _tmpltSvr.copyTemplate(srcTemplate,
dstSecStore);
             try {


Mime
View raw message