mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
CLOUDSTACK-7155 Re-copying templates to other zones doesn't work
This commit is contained in:
parent
ffa4d73290
commit
cab2b12d7d
@ -76,4 +76,6 @@ public interface TemplateDataStoreDao extends GenericDao<TemplateDataStoreVO, Lo
|
||||
void updateStoreRoleToCachce(long storeId);
|
||||
|
||||
List<TemplateDataStoreVO> listTemplateDownloadUrls();
|
||||
|
||||
void removeByTemplateStore(long templateId, long imageStoreId);
|
||||
}
|
||||
|
||||
@ -291,6 +291,16 @@ public class TemplateDataStoreDaoImpl extends GenericDaoBase<TemplateDataStoreVO
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeByTemplateStore(long templateId, long imageStoreId) {
|
||||
SearchCriteria<TemplateDataStoreVO> sc = storeTemplateSearch.create();
|
||||
sc.setParameters("template_id", templateId);
|
||||
sc.setParameters("store_id", imageStoreId);
|
||||
sc.setParameters("destroyed", false);
|
||||
expunge(sc);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public TemplateDataStoreVO findByTemplateZoneDownloadStatus(long templateId, Long zoneId, Status... status) {
|
||||
// get all elgible image stores
|
||||
|
||||
@ -27,6 +27,7 @@ import javax.inject.Inject;
|
||||
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.storage.datastore.db.TemplateDataStoreDao;
|
||||
import org.apache.cloudstack.api.command.user.iso.DeleteIsoCmd;
|
||||
import org.apache.cloudstack.api.command.user.iso.RegisterIsoCmd;
|
||||
import org.apache.cloudstack.api.command.user.template.DeleteTemplateCmd;
|
||||
@ -83,6 +84,7 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase {
|
||||
@Inject
|
||||
AgentManager _agentMgr;
|
||||
|
||||
@Inject TemplateDataStoreDao templateDataStoreDao;
|
||||
@Inject
|
||||
DataStoreManager storeMgr;
|
||||
@Inject
|
||||
@ -306,6 +308,9 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase {
|
||||
templateZoneDao.remove(templateZone.getId());
|
||||
}
|
||||
}
|
||||
//mark all the occurrences of this template in the given store as destroyed.
|
||||
templateDataStoreDao.removeByTemplateStore(template.getId(), imageStore.getId());
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
s_logger.debug("delete template Failed", e);
|
||||
throw new CloudRuntimeException("delete template Failed", e);
|
||||
|
||||
@ -648,6 +648,9 @@ public class TemplateManagerImpl extends ManagerBase implements TemplateManager,
|
||||
if (dstTmpltStore != null && dstTmpltStore.getDownloadState() == Status.DOWNLOADED) {
|
||||
return true; // already downloaded on this image store
|
||||
}
|
||||
if (dstTmpltStore != null && dstTmpltStore.getDownloadState() != Status.DOWNLOAD_IN_PROGRESS) {
|
||||
_tmplStoreDao.removeByTemplateStore(tmpltId, dstSecStore.getId());
|
||||
}
|
||||
|
||||
AsyncCallFuture<TemplateApiResult> future = _tmpltSvr.copyTemplate(srcTemplate, dstSecStore);
|
||||
try {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user