fixed a bug about snapshot

This commit is contained in:
anthony 2010-09-09 15:11:34 -07:00
parent 5d185ad82f
commit bce314b131
3 changed files with 11 additions and 4 deletions

View File

@ -26,6 +26,7 @@ import com.cloud.storage.SnapshotPolicyVO;
import com.cloud.storage.SnapshotScheduleVO;
import com.cloud.storage.SnapshotVO;
import com.cloud.storage.VolumeVO;
import com.cloud.storage.Storage.ImageFormat;
import com.cloud.utils.component.Manager;
import com.cloud.utils.db.Filter;
@ -155,4 +156,6 @@ public interface SnapshotManager extends Manager {
void validateSnapshot(Long userId, SnapshotVO snapshot);
ImageFormat getImageFormat(Long volumeId);
}

View File

@ -201,7 +201,8 @@ public class SnapshotManagerImpl implements SnapshotManager {
return runSnap;
}
private ImageFormat getImageFormat(Long volumeId) {
@Override
public ImageFormat getImageFormat(Long volumeId) {
ImageFormat format = null;
VolumeVO volume = _volsDao.findById(volumeId);
Long templateId = volume.getTemplateId();

View File

@ -151,6 +151,7 @@ import com.cloud.storage.dao.VMTemplateDao;
import com.cloud.storage.dao.VMTemplateHostDao;
import com.cloud.storage.dao.VolumeDao;
import com.cloud.template.VirtualMachineTemplate.BootloaderType;
import com.cloud.storage.snapshot.SnapshotManager;
import com.cloud.user.AccountManager;
import com.cloud.user.AccountVO;
import com.cloud.user.User;
@ -207,6 +208,7 @@ public class UserVmManagerImpl implements UserVmManager {
@Inject CapacityDao _capacityDao = null;
@Inject NetworkManager _networkMgr = null;
@Inject StorageManager _storageMgr = null;
@Inject SnapshotManager _snapshotMgr = null;
@Inject AgentManager _agentMgr = null;
@Inject AccountDao _accountDao = null;
@Inject UserDao _userDao = null;
@ -2483,10 +2485,11 @@ public class UserVmManagerImpl implements UserVmManager {
Long accountId = volume.getAccountId();
String origTemplateInstallPath = null;
Long origTemplateId = volume.getTemplateId();
if (origTemplateId != null) {
VMTemplateHostVO vmTemplateHostVO = _templateHostDao.findByHostTemplate(secondaryStorageHost.getId(), origTemplateId);
if (ImageFormat.ISO != _snapshotMgr.getImageFormat(volumeId)) {
Long origTemplateId = volume.getTemplateId();
VMTemplateHostVO vmTemplateHostVO = _templateHostDao.findByHostTemplate(secondaryStorageHost.getId(), origTemplateId);
origTemplateInstallPath = vmTemplateHostVO.getInstallPath();
}