bug 11497:

1. remove Garbagecollection primary storage allocator. other storage allocators fails may because there is primary storage with the same tag, it is not caused by no primary storage capacity.
2. delete template will try to delete templates in secondary storage in the API.

status 11497: resolved fixed

GarbageCollecting

Conflicts:

	server/src/com/cloud/template/HyervisorTemplateAdapter.java
This commit is contained in:
anthony 2012-01-12 16:20:44 -08:00
parent c0f87a25fd
commit 0156ec7cdd
2 changed files with 17 additions and 2 deletions

View File

@ -43,7 +43,6 @@
<adapters key="com.cloud.storage.allocator.StoragePoolAllocator">
<adapter name="LocalStorage" class="com.cloud.storage.allocator.LocalStoragePoolAllocator"/>
<adapter name="Storage" class="com.cloud.storage.allocator.FirstFitStoragePoolAllocator"/>
<adapter name="GarbageCollecting" class="com.cloud.storage.allocator.GarbageCollectingStoragePoolAllocator"/>
</adapters>
<adapters key="com.cloud.agent.manager.allocator.PodAllocator">
<adapter name="User First" class="com.cloud.agent.manager.allocator.impl.UserConcentratedAllocator"/>

View File

@ -11,6 +11,9 @@ import javax.ejb.Local;
import org.apache.log4j.Logger;
import com.cloud.agent.AgentManager;
import com.cloud.agent.api.Answer;
import com.cloud.agent.api.storage.DeleteTemplateCommand;
import com.cloud.api.commands.DeleteIsoCmd;
import com.cloud.api.commands.DeleteTemplateCmd;
import com.cloud.api.commands.RegisterIsoCmd;
@ -40,6 +43,7 @@ public class HyervisorTemplateAdapter extends TemplateAdapterBase implements Tem
private final static Logger s_logger = Logger.getLogger(HyervisorTemplateAdapter.class);
@Inject DownloadMonitor _downloadMonitor;
@Inject SecondaryStorageVmManager _ssvmMgr;
@Inject AgentManager _agentMgr;
private String validateUrl(String url) {
try {
@ -176,7 +180,6 @@ public class HyervisorTemplateAdapter extends TemplateAdapterBase implements Tem
List<VMTemplateHostVO> templateHostVOs = _tmpltHostDao.listByHostTemplate(hostId, templateId);
for (VMTemplateHostVO templateHostVO : templateHostVOs) {
VMTemplateHostVO lock = _tmpltHostDao.acquireInLockTable(templateHostVO.getId());
try {
if (lock == null) {
s_logger.debug("Failed to acquire lock when deleting templateHostVO with ID: " + templateHostVO.getId());
@ -187,6 +190,19 @@ public class HyervisorTemplateAdapter extends TemplateAdapterBase implements Tem
_usageEventDao.persist(usageEvent);
templateHostVO.setDestroyed(true);
_tmpltHostDao.update(templateHostVO.getId(), templateHostVO);
String installPath = templateHostVO.getInstallPath();
if (installPath != null) {
Answer answer = _agentMgr.sendToSecStorage(secondaryStorageHost, new DeleteTemplateCommand(secondaryStorageHost.getStorageUrl(), installPath));
if (answer == null || !answer.getResult()) {
s_logger.debug("Failed to delete " + templateHostVO + " due to " + ((answer == null) ? "answer is null" : answer.getDetails()));
} else {
_tmpltHostDao.remove(templateHostVO.getId());
s_logger.debug("Deleted template at: " + installPath);
}
} else {
_tmpltHostDao.remove(templateHostVO.getId());
}
VMTemplateZoneVO templateZone = _tmpltZoneDao.findByZoneTemplate(sZoneId, templateId);
if (templateZone != null) {