Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public interface VolumeOrchestrationService {
VolumeInfo moveVolume(VolumeInfo volume, long destPoolDcId, Long destPoolPodId, Long destPoolClusterId, HypervisorType dataDiskHyperType)
throws ConcurrentOperationException, StorageUnavailableException;

Volume allocateDuplicateVolume(Volume oldVol, Long templateId);
Volume allocateDuplicateVolume(Volume oldVol, DiskOffering diskOffering, Long templateId);

boolean volumeOnSharedStoragePool(Volume volume);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,11 +305,11 @@ public VolumeInfo moveVolume(VolumeInfo volumeInfo, long destPoolDcId, Long dest
}

@Override
public Volume allocateDuplicateVolume(Volume oldVol, Long templateId) {
return allocateDuplicateVolumeVO(oldVol, templateId);
public Volume allocateDuplicateVolume(Volume oldVol, DiskOffering diskOffering, Long templateId) {
return allocateDuplicateVolumeVO(oldVol, diskOffering, templateId);
}

public VolumeVO allocateDuplicateVolumeVO(Volume oldVol, Long templateId) {
public VolumeVO allocateDuplicateVolumeVO(Volume oldVol, DiskOffering diskOffering, Long templateId) {
VolumeVO newVol = new VolumeVO(oldVol.getVolumeType(), oldVol.getName(), oldVol.getDataCenterId(), oldVol.getDomainId(), oldVol.getAccountId(), oldVol.getDiskOfferingId(),
oldVol.getProvisioningType(), oldVol.getSize(), oldVol.getMinIops(), oldVol.getMaxIops(), oldVol.get_iScsiName());
if (templateId != null) {
Expand All @@ -321,8 +321,7 @@ public VolumeVO allocateDuplicateVolumeVO(Volume oldVol, Long templateId) {
newVol.setInstanceId(oldVol.getInstanceId());
newVol.setRecreatable(oldVol.isRecreatable());
newVol.setFormat(oldVol.getFormat());

if (oldVol.getPassphraseId() != null) {
if ((diskOffering == null || diskOffering.getEncrypt()) && oldVol.getPassphraseId() != null) {
PassphraseVO passphrase = passphraseDao.persist(new PassphraseVO(true));
newVol.setPassphraseId(passphrase.getId());
}
Expand Down Expand Up @@ -1180,7 +1179,7 @@ protected VolumeVO switchVolume(final VolumeVO existingVolume, final VirtualMach
return Transaction.execute(new TransactionCallback<VolumeVO>() {
@Override
public VolumeVO doInTransaction(TransactionStatus status) {
VolumeVO newVolume = allocateDuplicateVolumeVO(existingVolume, templateIdToUseFinal);
VolumeVO newVolume = allocateDuplicateVolumeVO(existingVolume, null, templateIdToUseFinal);
try {
stateTransitTo(existingVolume, Volume.Event.DestroyRequested);
} catch (NoTransitionException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1236,7 +1236,7 @@ private void destroyAndReallocateManagedVolume(VolumeInfo volumeInfo) {

volumeInfo.processEvent(Event.DestroyRequested);

Volume newVol = _volumeMgr.allocateDuplicateVolume(volume, null);
Volume newVol = _volumeMgr.allocateDuplicateVolume(volume, null, null);
VolumeVO newVolume = (VolumeVO) newVol;
newVolume.set_iScsiName(null);
volDao.update(newVolume.getId(), newVolume);
Expand Down
6 changes: 3 additions & 3 deletions server/src/main/java/com/cloud/vm/UserVmManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -7852,19 +7852,19 @@ public Pair<UserVmVO, Volume> doInTransaction(final TransactionStatus status) th
Volume newVol = null;
if (newTemplateId != null) {
if (isISO) {
newVol = volumeMgr.allocateDuplicateVolume(root, null);
newVol = volumeMgr.allocateDuplicateVolume(root, diskOffering, null);
userVm.setIsoId(newTemplateId);
userVm.setGuestOSId(template.getGuestOSId());
userVm.setTemplateId(newTemplateId);
} else {
newVol = volumeMgr.allocateDuplicateVolume(root, newTemplateId);
newVol = volumeMgr.allocateDuplicateVolume(root, diskOffering, newTemplateId);
userVm.setGuestOSId(template.getGuestOSId());
userVm.setTemplateId(newTemplateId);
}
// check and update VM if it can be dynamically scalable with the new template
updateVMDynamicallyScalabilityUsingTemplate(userVm, newTemplateId);
} else {
newVol = volumeMgr.allocateDuplicateVolume(root, null);
newVol = volumeMgr.allocateDuplicateVolume(root, diskOffering, null);
}

updateVolume(newVol, template, userVm, diskOffering, details);
Expand Down