Skip to content
Draft
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 @@ -109,6 +109,11 @@ VolumeInfo moveVolume(VolumeInfo volume, long destPoolDcId, Long destPoolPodId,

StoragePool findChildDataStoreInDataStoreCluster(DataCenter dc, Pod pod, Long clusterId, Long hostId, VirtualMachine vm, Long datastoreClusterId);

/**
* Sets up the encryption of a volume if its disk offering is encrypted and the volume has none yet.
*/
void setUpVolumeEncryption(long volumeId, DiskOffering diskOffering);

VolumeInfo createVolumeFromSnapshot(Volume volume, Snapshot snapshot, UserVm vm) throws StorageUnavailableException;

Volume migrateVolume(Volume volume, StoragePool destPool) throws StorageUnavailableException;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1904,6 +1904,15 @@ private Pair<VolumeVO, DataStore> recreateVolume(VolumeVO vol, VirtualMachinePro
return new Pair<>(newVol, destPool);
}

@Override
public void setUpVolumeEncryption(long volumeId, DiskOffering diskOffering) {
if (diskOffering == null || !diskOffering.getEncrypt()) {
return;
}
VolumeVO volume = _volsDao.findById(volumeId);
setPassphraseForVolumeEncryption(volume);
}

private VolumeVO setPassphraseForVolumeEncryption(VolumeVO volume) {
if (volume.getPassphraseId() != null) {
return volume;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1090,6 +1090,8 @@ private VolumeVO createVolumeOnStoragePool(Long volumeId, Long storageId) throws
throw new InvalidParameterValueException(String.format("Disk offering: %s is not compatible with the storage pool", diskOffering.getUuid()));
}

_volumeMgr.setUpVolumeEncryption(volumeId, diskOffering);

DataStore dataStore = dataStoreMgr.getDataStore(storageId, DataStoreRole.Primary);
VolumeInfo volumeInfo = volFactory.getVolume(volumeId, dataStore);
AsyncCallFuture<VolumeApiResult> createVolumeFuture = volService.createVolumeAsync(volumeInfo, dataStore);
Expand Down
Loading