mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-5414: With NFS Image Store migrated to S3 an error is thrown
in creation of Virtual Router.
This commit is contained in:
parent
78b39bbe12
commit
010b007ee4
@ -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;
|
||||
|
||||
@ -50,6 +51,8 @@ public interface TemplateDataStoreDao extends GenericDao<TemplateDataStoreVO, Lo
|
||||
|
||||
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);
|
||||
|
||||
@ -301,6 +301,23 @@ public class TemplateDataStoreDaoImpl extends GenericDaoBase<TemplateDataStoreVO
|
||||
return null;
|
||||
}
|
||||
|
||||
@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();
|
||||
|
||||
@ -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;
|
||||
@ -1697,7 +1696,12 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
||||
public Long getTemplateSize(long templateId, long zoneId) {
|
||||
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();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user