mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
Update volume's passphrase to null if diskOffering doesn't support encryption (#8904)
This commit is contained in:
parent
e409c6d870
commit
80a8b80a9d
@ -85,7 +85,7 @@ public interface VolumeOrchestrationService {
|
|||||||
VolumeInfo moveVolume(VolumeInfo volume, long destPoolDcId, Long destPoolPodId, Long destPoolClusterId, HypervisorType dataDiskHyperType)
|
VolumeInfo moveVolume(VolumeInfo volume, long destPoolDcId, Long destPoolPodId, Long destPoolClusterId, HypervisorType dataDiskHyperType)
|
||||||
throws ConcurrentOperationException, StorageUnavailableException;
|
throws ConcurrentOperationException, StorageUnavailableException;
|
||||||
|
|
||||||
Volume allocateDuplicateVolume(Volume oldVol, Long templateId);
|
Volume allocateDuplicateVolume(Volume oldVol, DiskOffering diskOffering, Long templateId);
|
||||||
|
|
||||||
boolean volumeOnSharedStoragePool(Volume volume);
|
boolean volumeOnSharedStoragePool(Volume volume);
|
||||||
|
|
||||||
|
|||||||
@ -305,11 +305,11 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Volume allocateDuplicateVolume(Volume oldVol, Long templateId) {
|
public Volume allocateDuplicateVolume(Volume oldVol, DiskOffering diskOffering, Long templateId) {
|
||||||
return allocateDuplicateVolumeVO(oldVol, 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(),
|
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());
|
oldVol.getProvisioningType(), oldVol.getSize(), oldVol.getMinIops(), oldVol.getMaxIops(), oldVol.get_iScsiName());
|
||||||
if (templateId != null) {
|
if (templateId != null) {
|
||||||
@ -321,8 +321,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
|||||||
newVol.setInstanceId(oldVol.getInstanceId());
|
newVol.setInstanceId(oldVol.getInstanceId());
|
||||||
newVol.setRecreatable(oldVol.isRecreatable());
|
newVol.setRecreatable(oldVol.isRecreatable());
|
||||||
newVol.setFormat(oldVol.getFormat());
|
newVol.setFormat(oldVol.getFormat());
|
||||||
|
if ((diskOffering == null || diskOffering.getEncrypt()) && oldVol.getPassphraseId() != null) {
|
||||||
if (oldVol.getPassphraseId() != null) {
|
|
||||||
PassphraseVO passphrase = passphraseDao.persist(new PassphraseVO(true));
|
PassphraseVO passphrase = passphraseDao.persist(new PassphraseVO(true));
|
||||||
newVol.setPassphraseId(passphrase.getId());
|
newVol.setPassphraseId(passphrase.getId());
|
||||||
}
|
}
|
||||||
@ -1180,7 +1179,7 @@ public class VolumeOrchestrator extends ManagerBase implements VolumeOrchestrati
|
|||||||
return Transaction.execute(new TransactionCallback<VolumeVO>() {
|
return Transaction.execute(new TransactionCallback<VolumeVO>() {
|
||||||
@Override
|
@Override
|
||||||
public VolumeVO doInTransaction(TransactionStatus status) {
|
public VolumeVO doInTransaction(TransactionStatus status) {
|
||||||
VolumeVO newVolume = allocateDuplicateVolumeVO(existingVolume, templateIdToUseFinal);
|
VolumeVO newVolume = allocateDuplicateVolumeVO(existingVolume, null, templateIdToUseFinal);
|
||||||
try {
|
try {
|
||||||
stateTransitTo(existingVolume, Volume.Event.DestroyRequested);
|
stateTransitTo(existingVolume, Volume.Event.DestroyRequested);
|
||||||
} catch (NoTransitionException e) {
|
} catch (NoTransitionException e) {
|
||||||
|
|||||||
@ -1236,7 +1236,7 @@ public class VolumeServiceImpl implements VolumeService {
|
|||||||
|
|
||||||
volumeInfo.processEvent(Event.DestroyRequested);
|
volumeInfo.processEvent(Event.DestroyRequested);
|
||||||
|
|
||||||
Volume newVol = _volumeMgr.allocateDuplicateVolume(volume, null);
|
Volume newVol = _volumeMgr.allocateDuplicateVolume(volume, null, null);
|
||||||
VolumeVO newVolume = (VolumeVO) newVol;
|
VolumeVO newVolume = (VolumeVO) newVol;
|
||||||
newVolume.set_iScsiName(null);
|
newVolume.set_iScsiName(null);
|
||||||
volDao.update(newVolume.getId(), newVolume);
|
volDao.update(newVolume.getId(), newVolume);
|
||||||
|
|||||||
@ -7863,19 +7863,19 @@ public class UserVmManagerImpl extends ManagerBase implements UserVmManager, Vir
|
|||||||
Volume newVol = null;
|
Volume newVol = null;
|
||||||
if (newTemplateId != null) {
|
if (newTemplateId != null) {
|
||||||
if (isISO) {
|
if (isISO) {
|
||||||
newVol = volumeMgr.allocateDuplicateVolume(root, null);
|
newVol = volumeMgr.allocateDuplicateVolume(root, diskOffering, null);
|
||||||
userVm.setIsoId(newTemplateId);
|
userVm.setIsoId(newTemplateId);
|
||||||
userVm.setGuestOSId(template.getGuestOSId());
|
userVm.setGuestOSId(template.getGuestOSId());
|
||||||
userVm.setTemplateId(newTemplateId);
|
userVm.setTemplateId(newTemplateId);
|
||||||
} else {
|
} else {
|
||||||
newVol = volumeMgr.allocateDuplicateVolume(root, newTemplateId);
|
newVol = volumeMgr.allocateDuplicateVolume(root, diskOffering, newTemplateId);
|
||||||
userVm.setGuestOSId(template.getGuestOSId());
|
userVm.setGuestOSId(template.getGuestOSId());
|
||||||
userVm.setTemplateId(newTemplateId);
|
userVm.setTemplateId(newTemplateId);
|
||||||
}
|
}
|
||||||
// check and update VM if it can be dynamically scalable with the new template
|
// check and update VM if it can be dynamically scalable with the new template
|
||||||
updateVMDynamicallyScalabilityUsingTemplate(userVm, newTemplateId);
|
updateVMDynamicallyScalabilityUsingTemplate(userVm, newTemplateId);
|
||||||
} else {
|
} else {
|
||||||
newVol = volumeMgr.allocateDuplicateVolume(root, null);
|
newVol = volumeMgr.allocateDuplicateVolume(root, diskOffering, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
updateVolume(newVol, template, userVm, diskOffering, details);
|
updateVolume(newVol, template, userVm, diskOffering, details);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user