cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject git commit: updated refs/heads/object_store to 565bdfb
Date Mon, 20 May 2013 23:24:33 GMT
Updated Branches:
  refs/heads/object_store ef541a2a7 -> 565bdfb27


Fix CLOUDSTACK-2525: clean up db entries in vm_template and
template_store_ref in case of template creation failure.

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

Branch: refs/heads/object_store
Commit: 565bdfb27b0e5a151d7acbc6471c676bb1e2ec25
Parents: ef541a2
Author: Min Chen <min.chen@citrix.com>
Authored: Mon May 20 16:21:45 2013 -0700
Committer: Min Chen <min.chen@citrix.com>
Committed: Mon May 20 16:21:45 2013 -0700

----------------------------------------------------------------------
 .../storage/datastore/db/TemplateDataStoreDao.java |    2 ++
 .../storage/image/db/TemplateDataStoreDaoImpl.java |    9 +++++++++
 .../com/cloud/template/TemplateManagerImpl.java    |    2 ++
 3 files changed, 13 insertions(+), 0 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/565bdfb2/engine/api/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java
----------------------------------------------------------------------
diff --git a/engine/api/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java
b/engine/api/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java
index dbb8dbd..b83c590 100644
--- a/engine/api/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java
+++ b/engine/api/src/org/apache/cloudstack/storage/datastore/db/TemplateDataStoreDao.java
@@ -37,6 +37,8 @@ public interface TemplateDataStoreDao extends GenericDao<TemplateDataStoreVO,
Lo
 
     public void deletePrimaryRecordsForStore(long id);
 
+    public void deletePrimaryRecordsForTemplate(long templateId);
+
     List<TemplateDataStoreVO> listByTemplateStore(long templateId, long storeId);
 
     List<TemplateDataStoreVO> listByTemplateStoreStatus(long templateId, long storeId,
State... states);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/565bdfb2/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 345098c..d41733d 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
@@ -182,6 +182,15 @@ public class TemplateDataStoreDaoImpl extends GenericDaoBase<TemplateDataStoreVO
         txn.commit();
     }
 
+    @Override
+    public void deletePrimaryRecordsForTemplate(long templateId) {
+        SearchCriteria<TemplateDataStoreVO> sc = templateSearch.create();
+        sc.setParameters("template_id", templateId);
+        Transaction txn = Transaction.currentTxn();
+        txn.start();
+        expunge(sc);
+        txn.commit();
+    }
 
     @Override
     public List<TemplateDataStoreVO> listByTemplateStore(long templateId, long storeId)
{

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/565bdfb2/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 c783773..dca892f 100755
--- a/server/src/com/cloud/template/TemplateManagerImpl.java
+++ b/server/src/com/cloud/template/TemplateManagerImpl.java
@@ -1456,6 +1456,8 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
             if (privateTemplate == null) {
                 Transaction txn = Transaction.currentTxn();
                 txn.start();
+                // Remove the template_store_ref record first, otherwise, we cannot remove
the template record due to FK constraints
+                this._tmplStoreDao.deletePrimaryRecordsForTemplate(templateId);
                 // Remove the template record
                 this._tmpltDao.expunge(templateId);
 


Mime
View raw message