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);
|
void updateStoreRoleToCachce(long storeId);
|
||||||
|
|
||||||
List<TemplateDataStoreVO> listTemplateDownloadUrls();
|
List<TemplateDataStoreVO> listTemplateDownloadUrls();
|
||||||
|
|
||||||
|
void removeByTemplateStore(long templateId, long imageStoreId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -291,6 +291,16 @@ public class TemplateDataStoreDaoImpl extends GenericDaoBase<TemplateDataStoreVO
|
|||||||
return null;
|
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
|
@Override
|
||||||
public TemplateDataStoreVO findByTemplateZoneDownloadStatus(long templateId, Long zoneId, Status... status) {
|
public TemplateDataStoreVO findByTemplateZoneDownloadStatus(long templateId, Long zoneId, Status... status) {
|
||||||
// get all elgible image stores
|
// get all elgible image stores
|
||||||
|
|||||||
@ -27,6 +27,7 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
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.DeleteIsoCmd;
|
||||||
import org.apache.cloudstack.api.command.user.iso.RegisterIsoCmd;
|
import org.apache.cloudstack.api.command.user.iso.RegisterIsoCmd;
|
||||||
import org.apache.cloudstack.api.command.user.template.DeleteTemplateCmd;
|
import org.apache.cloudstack.api.command.user.template.DeleteTemplateCmd;
|
||||||
@ -83,6 +84,7 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase {
|
|||||||
@Inject
|
@Inject
|
||||||
AgentManager _agentMgr;
|
AgentManager _agentMgr;
|
||||||
|
|
||||||
|
@Inject TemplateDataStoreDao templateDataStoreDao;
|
||||||
@Inject
|
@Inject
|
||||||
DataStoreManager storeMgr;
|
DataStoreManager storeMgr;
|
||||||
@Inject
|
@Inject
|
||||||
@ -306,6 +308,9 @@ public class HypervisorTemplateAdapter extends TemplateAdapterBase {
|
|||||||
templateZoneDao.remove(templateZone.getId());
|
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) {
|
} catch (InterruptedException e) {
|
||||||
s_logger.debug("delete template Failed", e);
|
s_logger.debug("delete template Failed", e);
|
||||||
throw new CloudRuntimeException("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) {
|
if (dstTmpltStore != null && dstTmpltStore.getDownloadState() == Status.DOWNLOADED) {
|
||||||
return true; // already downloaded on this image store
|
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);
|
AsyncCallFuture<TemplateApiResult> future = _tmpltSvr.copyTemplate(srcTemplate, dstSecStore);
|
||||||
try {
|
try {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user