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 2102ede
Date Tue, 14 May 2013 18:43:39 GMT
Updated Branches:
  refs/heads/object_store bbdab9806 -> 2102ede2e


Fix CLOUDSTACK-2469: default template is not downloaded.

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

Branch: refs/heads/object_store
Commit: 2102ede2e73c49e69a402c7b0f97a44b77e41e8f
Parents: bbdab98
Author: Min Chen <min.chen@citrix.com>
Authored: Tue May 14 11:42:24 2013 -0700
Committer: Min Chen <min.chen@citrix.com>
Committed: Tue May 14 11:42:24 2013 -0700

----------------------------------------------------------------------
 .../storage/image/TemplateServiceImpl.java         |   17 +++++++++-----
 .../cloud/template/HypervisorTemplateAdapter.java  |    2 +-
 2 files changed, 12 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2102ede2/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 7419e9f..a9302b3 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
@@ -340,11 +340,15 @@ public class TemplateServiceImpl implements TemplateService {
             }
             if (tmpltStore != null && tmpltStore.getDownloadState() != Status.DOWNLOADED)
{
                 s_logger.info("Template Sync did not find " + uniqueName + " ready on image
store " + storeId + ", will request download to start/resume shortly");
+                s_logger.info("Removing template " + uniqueName + " from template store table");
+                // remove those leftover entries
+                _vmTemplateStoreDao.remove(tmpltStore.getId());
 
             } else if (tmpltStore == null) {
                 s_logger.info("Template Sync did not find " + uniqueName + " on the image
store " + storeId + ", will request download shortly");
-                TemplateDataStoreVO templtStore = new TemplateDataStoreVO(storeId, tmplt.getId(),
new Date(), 0, Status.NOT_DOWNLOADED, null, null, null, null, tmplt.getUrl());
-                _vmTemplateStoreDao.persist(templtStore);
+                // persist template_zone_ref table
+                // TODO: we may have some bugs in removing these entries in case of failure,
maybe we should pass another callback below in invoking createTemplateAsync
+                // to just clear those entries.
                 associateTemplateToZone(tmplt.getId(), zoneId);
             }
 
@@ -370,20 +374,21 @@ public class TemplateServiceImpl implements TemplateService {
                     continue;
                 }
                 // check if there is a record for this template in this store
-                TemplateDataStoreVO tmpltHost = _vmTemplateStoreDao.findByStoreTemplate(storeId,
tmplt.getId());
+                TemplateDataStoreVO tmpltStoreVO = _vmTemplateStoreDao.findByStoreTemplate(storeId,
tmplt.getId());
 
                 // if this is private template, and there is no record for this
                 // template in this store, skip
+                // TODO: don't understand this logic. What happens if we have a record for
this template, still download?
                 if (!tmplt.isPublicTemplate() && !tmplt.isFeatured()) {
-                    if (tmpltHost == null) {
+                    if (tmpltStoreVO == null) {
                         continue;
                     }
                 }
                 if (availHypers.contains(tmplt.getHypervisorType())) {
-                     if (tmpltHost != null ) {
+                     if (tmpltStoreVO != null && tmpltStoreVO.getDownloadState()
== Status.DOWNLOADED) {
                         continue;
                     }
-                    s_logger.debug("Template " + tmplt.getName() + " needs to be downloaded
to " + store.getName());
+                    s_logger.info("Downloading template " + tmplt.getUniqueName() + " to
image store " + store.getName());
                     TemplateInfo tmpl = _templateFactory.getTemplate(tmplt.getId(), DataStoreRole.Image);
                     createTemplateAsync(tmpl, store, null);
                 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2102ede2/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 b2a49a3..74bae35 100755
--- a/server/src/com/cloud/template/HypervisorTemplateAdapter.java
+++ b/server/src/com/cloud/template/HypervisorTemplateAdapter.java
@@ -169,7 +169,7 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase {
 
 	@Override
 	public VMTemplateVO create(TemplateProfile profile) {
-	    // persist entry in vm_template, vm_template_details and template_zone_ref tables
+	    // persist entry in vm_template, vm_template_details and template_zone_ref tables, not
that entry at template_store_ref is not created here, and created in createTemplateAsync.
 		VMTemplateVO template = persistTemplate(profile);
 
 		if (template == null) {


Mime
View raw message