sureshanaparti commented on a change in pull request #5008:
URL: https://github.com/apache/cloudstack/pull/5008#discussion_r699030583
##########
File path: server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java
##########
@@ -1596,6 +1622,341 @@ public Volume recoverVolume(long volumeId) {
return volume;
}
+ @Override
+ @ActionEvent(eventType = EventTypes.EVENT_VOLUME_CHANGE_DISK_OFFERING,
eventDescription = "Changing disk offering of a volume")
+ public Volume changeDiskOfferingForVolume(ChangeOfferingForVolumeCmd cmd)
throws ResourceAllocationException {
+ Long newSize = cmd.getSize();
+ Long newMinIops = cmd.getMinIops();
+ Long newMaxIops = cmd.getMaxIops();
+ Integer newHypervisorSnapshotReserve = null;
+ boolean autoMigrateVolume = cmd.getAutoMigrate();
+
+ boolean volumeMigrateRequired = false;
+ boolean volumeResizeRequired = false;
+
+ VolumeVO volume = _volsDao.findById(cmd.getId());
+ if (volume == null) {
+ throw new InvalidParameterValueException("No such volume");
+ }
+ long currentSize = volume.getSize();
+
+ DiskOfferingVO diskOffering =
_diskOfferingDao.findById(volume.getDiskOfferingId());
+ DiskOfferingVO newDiskOffering =
_diskOfferingDao.findById(cmd.getNewDiskOfferingId());
+
+ /* Does the caller have authority to act on this volume? */
+ _accountMgr.checkAccess(CallContext.current().getCallingAccount(),
null, true, volume);
+
+ // VALIDATIONS
+
+ if (newDiskOffering.getId() == diskOffering.getId()) {
+ throw new InvalidParameterValueException(String.format("Volume %s
already have the new disk offering %s provided", volume.getUuid(),
diskOffering.getUuid()));
+ }
+
+ Long updateNewSize[] = {newSize};
+ Long updateNewMinIops[] = {newMinIops};
+ Long updateNewMaxIops[] = {newMaxIops};
+ Integer updateNewHypervisorSnapshotReserve[] =
{newHypervisorSnapshotReserve};
+ validateVolumeResizeWithNewDiskOfferingAndLoad(volume, diskOffering,
newDiskOffering, updateNewSize, updateNewMinIops, updateNewMaxIops,
updateNewHypervisorSnapshotReserve);
+ newSize = updateNewSize[0];
+ newMinIops = updateNewMinIops[0];
+ newMaxIops = updateNewMaxIops[0];
+ newHypervisorSnapshotReserve = updateNewHypervisorSnapshotReserve[0];
+ validateVolumeResizeWithSize(volume, currentSize, newSize, true);
+
+ /* If this volume has never been beyond allocated state, short circuit
everything and simply update the database. */
+ // We need to publish this event to usage_volume table
+ if (volume.getState() == Volume.State.Allocated) {
+ s_logger.debug("Volume is in the allocated state, but has never
been created. Simply updating database with new size and IOPS.");
Review comment:
Better to keep volume id / name in the log here
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]