You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by ed...@apache.org on 2013/04/23 19:48:48 UTC

git commit: updated refs/heads/object_store to 4cd3903

Updated Branches:
  refs/heads/object_store e40a06dea -> 4cd3903c9


change iszoneready, to use imagestore table


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

Branch: refs/heads/object_store
Commit: 4cd3903c9d289e7653b60b67759fa67ffa8b729b
Parents: e40a06d
Author: Edison Su <su...@gmail.com>
Authored: Tue Apr 23 10:41:09 2013 -0700
Committer: Edison Su <su...@gmail.com>
Committed: Tue Apr 23 10:41:30 2013 -0700

----------------------------------------------------------------------
 .../secondary/SecondaryStorageManagerImpl.java     |   47 +++++++--------
 1 files changed, 22 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/4cd3903c/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java
index 7f729c3..7aa4efb 100755
--- a/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java
+++ b/server/src/com/cloud/storage/secondary/SecondaryStorageManagerImpl.java
@@ -115,6 +115,7 @@ import com.cloud.storage.dao.VMTemplateHostDao;
 import com.cloud.storage.resource.DummySecondaryStorageResource;
 import com.cloud.storage.swift.SwiftManager;
 import com.cloud.storage.template.TemplateConstants;
+import com.cloud.template.TemplateManager;
 import com.cloud.user.Account;
 import com.cloud.user.AccountService;
 import com.cloud.user.User;
@@ -241,6 +242,8 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
     protected IPAddressDao _ipAddressDao = null;
     @Inject
     protected RulesManager _rulesMgr;
+    @Inject 
+    TemplateManager templateMgr;
 
     @Inject
     KeystoreManager _keystoreMgr;
@@ -739,41 +742,35 @@ public class SecondaryStorageManagerImpl extends ManagerBase implements Secondar
         ZoneHostInfo zoneHostInfo = zoneHostInfoMap.get(dataCenterId);
         if (zoneHostInfo != null && (zoneHostInfo.getFlags() & RunningHostInfoAgregator.ZoneHostInfo.ROUTING_HOST_MASK) != 0) {
             VMTemplateVO template = _templateDao.findSystemVMTemplate(dataCenterId);
-            HostVO secHost = _ssvmMgr.findSecondaryStorageHost(dataCenterId);
-            if (secHost == null) {
+            if (template == null) {
+                s_logger.debug("No hypervisor host added  in zone " + dataCenterId + ", wait until it is ready to launch secondary storage vm");
+                return false;
+            }
+            
+            List<DataStore> stores = this._dataStoreMgr.getImageStoresByScope(new ZoneScope(dataCenterId));
+            if (stores.size() < 1) {
+                s_logger.debug("No image store added  in zone " + dataCenterId + ", wait until it is ready to launch secondary storage vm");
+                return false;
+            }
+            
+            DataStore store = templateMgr.getImageStore(dataCenterId, template.getId());
+            if (store == null) {
                 if (s_logger.isDebugEnabled()) {
                     s_logger.debug("No secondary storage available in zone " + dataCenterId + ", wait until it is ready to launch secondary storage vm");
                 }
                 return false;
             }
 
-            boolean templateReady = false;
-            if (template != null) {
-                VMTemplateHostVO templateHostRef = _vmTemplateHostDao.findByHostTemplate(secHost.getId(), template.getId());
-                templateReady = (templateHostRef != null) && (templateHostRef.getDownloadState() == Status.DOWNLOADED);
-            }
-
-            if (templateReady) {
-
-                List<Pair<Long, Integer>> l = _storagePoolHostDao.getDatacenterStoragePoolHostInfo(dataCenterId, !_useLocalStorage);
-                if (l != null && l.size() > 0 && l.get(0).second().intValue() > 0) {
-
-                    return true;
-                } else {
-                    if (s_logger.isDebugEnabled()) {
-                        s_logger.debug("Primary storage is not ready, wait until it is ready to launch secondary storage vm. dcId: " + dataCenterId + " system.vm.use.local.storage: " + _useLocalStorage +
-                        		"If you want to use local storage to start ssvm, need to set system.vm.use.local.storage to true");
-                    }
-                }
+            List<Pair<Long, Integer>> l = _storagePoolHostDao.getDatacenterStoragePoolHostInfo(dataCenterId, !_useLocalStorage);
+            if (l != null && l.size() > 0 && l.get(0).second().intValue() > 0) {
+                return true;
             } else {
                 if (s_logger.isDebugEnabled()) {
-                    if (template == null) {
-                        s_logger.debug("Zone host is ready, but secondary storage vm template does not exist");
-                    } else {
-                        s_logger.debug("Zone host is ready, but secondary storage vm template: " + template.getId() + " is not ready on secondary storage: " + secHost.getId());
-                    }
+                    s_logger.debug("Primary storage is not ready, wait until it is ready to launch secondary storage vm. dcId: " + dataCenterId + " system.vm.use.local.storage: " + _useLocalStorage +
+                            "If you want to use local storage to start ssvm, need to set system.vm.use.local.storage to true");
                 }
             }
+
         }
         return false;
     }