bug 12830: propagate ISO to other zone on demand

status 12830: resolved fixed
This commit is contained in:
anthony 2012-01-20 11:42:30 -08:00
parent ba826ddc21
commit 6297820981
3 changed files with 44 additions and 3 deletions

View File

@ -762,6 +762,12 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
}
cmd = new CreateCommand(dskCh, tmpltStoredOn.getLocalDownloadPath(), new StorageFilerTO(pool));
} else {
if (volume.getVolumeType() == Type.ROOT && Storage.ImageFormat.ISO == template.getFormat()) {
VMTemplateHostVO tmpltHostOn = _tmpltMgr.prepareISOForCreate(template, pool);
if (tmpltHostOn == null) {
throw new CloudRuntimeException("Did not find ISO in secondry storage in zone " + pool.getDataCenterId());
}
}
cmd = new CreateCommand(dskCh, new StorageFilerTO(pool));
}
@ -3065,6 +3071,12 @@ public class StorageManagerImpl implements StorageManager, StorageService, Manag
}
cmd = new CreateCommand(diskProfile, tmpltStoredOn.getLocalDownloadPath(), new StorageFilerTO(pool));
} else {
if (template != null && Storage.ImageFormat.ISO == template.getFormat()) {
VMTemplateHostVO tmpltHostOn = _tmpltMgr.prepareISOForCreate(template, pool);
if (tmpltHostOn == null) {
throw new CloudRuntimeException("Did not find ISO in secondry storage in zone " + pool.getDataCenterId());
}
}
cmd = new CreateCommand(diskProfile, new StorageFilerTO(pool));
}
long[] hostIdsToTryFirst = { dest.getHost().getId() };

View File

@ -17,7 +17,6 @@
*/
package com.cloud.template;
import java.net.URI;
import java.util.List;
import com.cloud.dc.DataCenterVO;
@ -25,8 +24,6 @@ import com.cloud.exception.InternalErrorException;
import com.cloud.exception.ResourceAllocationException;
import com.cloud.exception.StorageUnavailableException;
import com.cloud.host.HostVO;
import com.cloud.storage.Storage.ImageFormat;
import com.cloud.storage.Storage.TemplateType;
import com.cloud.storage.StoragePool;
import com.cloud.storage.StoragePoolVO;
import com.cloud.storage.VMTemplateHostVO;
@ -94,4 +91,6 @@ public interface TemplateManager extends TemplateService{
boolean templateIsDeleteable(VMTemplateHostVO templateHostRef);
VMTemplateHostVO prepareISOForCreate(VMTemplateVO template, StoragePool pool);
}

View File

@ -688,6 +688,36 @@ public class TemplateManagerImpl implements TemplateManager, Manager, TemplateSe
return null;
}
@Override
@DB
public VMTemplateHostVO prepareISOForCreate(VMTemplateVO template, StoragePool pool) {
template = _tmpltDao.findById(template.getId(), true);
long poolId = pool.getId();
long templateId = template.getId();
long dcId = pool.getDataCenterId();
VMTemplateStoragePoolVO templateStoragePoolRef = null;
VMTemplateHostVO templateHostRef = null;
long templateStoragePoolRefId;
String origUrl = null;
templateHostRef = _storageMgr.findVmTemplateHost(templateId, pool);
if (templateHostRef == null || templateHostRef.getDownloadState() != Status.DOWNLOADED) {
String result = downloadTemplateFromSwiftToSecondaryStorage(dcId, templateId);
if (result != null) {
s_logger.error("Unable to find a secondary storage host who has completely downloaded the template.");
return null;
}
templateHostRef = _storageMgr.findVmTemplateHost(templateId, pool);
if (templateHostRef == null || templateHostRef.getDownloadState() != Status.DOWNLOADED) {
s_logger.error("Unable to find a secondary storage host who has completely downloaded the template.");
return null;
}
}
return templateHostRef;
}
@Override
@DB
public boolean resetTemplateDownloadStateOnPool(long templateStoragePoolRefId) {