cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mc...@apache.org
Subject [2/2] git commit: updated refs/heads/4.3 to feb9fe1
Date Wed, 11 Dec 2013 22:09:16 GMT
CLOUDSTACK-5414: With NFS Image Store migrated to S3 an error is thrown
in creation of Virtual Router.


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

Branch: refs/heads/4.3
Commit: eb641596321a509b88050c91a51a5d114232c2fc
Parents: 2dfa84b
Author: Min Chen <min.chen@citrix.com>
Authored: Wed Dec 11 13:57:39 2013 -0800
Committer: Min Chen <min.chen@citrix.com>
Committed: Wed Dec 11 14:02:24 2013 -0800

----------------------------------------------------------------------
 .../storage/datastore/db/TemplateDataStoreDao.java |  3 +++
 .../storage/image/db/TemplateDataStoreDaoImpl.java | 17 +++++++++++++++++
 .../com/cloud/template/TemplateManagerImpl.java    | 10 +++++++---
 3 files changed, 27 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/eb641596/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 93adaaf..7a9a15a 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
@@ -24,6 +24,7 @@ import org.apache.cloudstack.engine.subsystem.api.storage.ObjectInDataStoreState
 
 import com.cloud.storage.DataStoreRole;
 import com.cloud.storage.VMTemplateStorageResourceAssoc;
+import com.cloud.storage.VMTemplateStorageResourceAssoc.Status;
 import com.cloud.utils.db.GenericDao;
 import com.cloud.utils.fsm.StateDao;
 
@@ -53,6 +54,8 @@ StateDao<ObjectInDataStoreStateMachine.State, ObjectInDataStoreStateMachine.Even
     TemplateDataStoreVO findByTemplateZoneDownloadStatus(long templateId, Long zoneId,
             VMTemplateStorageResourceAssoc.Status... status);
 
+    TemplateDataStoreVO findByTemplateZoneStagingDownloadStatus(long templateId, Long zoneId,
Status... status);
+
     TemplateDataStoreVO findByStoreTemplate(long storeId, long templateId);
 
     TemplateDataStoreVO findByStoreTemplate(long storeId, long templateId, boolean lock);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/eb641596/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 ee7c4fc..69a52c0 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
@@ -295,6 +295,23 @@ public class TemplateDataStoreDaoImpl extends GenericDaoBase<TemplateDataStoreVO
     }
 
     @Override
+    public TemplateDataStoreVO findByTemplateZoneStagingDownloadStatus(long templateId, Long
zoneId, Status... status) {
+        // get all elgible image stores
+        List<DataStore> cacheStores = _storeMgr.getImageCacheStores(new ZoneScope(zoneId));
+        if (cacheStores != null) {
+            for (DataStore store : cacheStores) {
+                List<TemplateDataStoreVO> sRes = listByTemplateStoreDownloadStatus(templateId,
store.getId(),
+                        status);
+                if (sRes != null && sRes.size() > 0) {
+                    Collections.shuffle(sRes);
+                    return sRes.get(0);
+                }
+            }
+        }
+        return null;
+    }
+
+    @Override
     public TemplateDataStoreVO findByStoreTemplate(long storeId, long templateId) {
         SearchCriteria<TemplateDataStoreVO> sc = storeTemplateSearch.create();
         sc.setParameters("store_id", storeId);

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/eb641596/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 7aab492..de30948 100755
--- a/server/src/com/cloud/template/TemplateManagerImpl.java
+++ b/server/src/com/cloud/template/TemplateManagerImpl.java
@@ -19,9 +19,9 @@ package com.cloud.template;
 import java.net.URISyntaxException;
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.HashMap;
 import java.util.UUID;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
@@ -136,7 +136,6 @@ import com.cloud.storage.StoragePoolHostVO;
 import com.cloud.storage.StoragePoolStatus;
 import com.cloud.storage.TemplateProfile;
 import com.cloud.storage.Upload;
-import com.cloud.storage.VMTemplateDetailVO;
 import com.cloud.storage.VMTemplateHostVO;
 import com.cloud.storage.VMTemplateStoragePoolVO;
 import com.cloud.storage.VMTemplateStorageResourceAssoc;
@@ -1712,7 +1711,12 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
         TemplateDataStoreVO templateStoreRef = _tmplStoreDao.findByTemplateZoneDownloadStatus(templateId,
zoneId,
                 VMTemplateStorageResourceAssoc.Status.DOWNLOADED);
         if (templateStoreRef == null) {
-            throw new CloudRuntimeException("Template " + templateId + " has not been completely
downloaded to zone " + zoneId);
+            // check if it is ready on image cache stores
+            templateStoreRef = _tmplStoreDao.findByTemplateZoneStagingDownloadStatus(templateId,
zoneId,
+                    VMTemplateStorageResourceAssoc.Status.DOWNLOADED);
+            if (templateStoreRef == null) {
+                throw new CloudRuntimeException("Template " + templateId + " has not been
completely downloaded to zone " + zoneId);
+            }
         }
         return templateStoreRef.getSize();
 


Mime
View raw message