Sergey Gotliv has posted comments on this change. Change subject: backend,webadmin: Enable virtual drive size extension ......................................................................
Patch Set 8: (26 inline comments) .................................................... File backend/manager/dbscripts/images_sp.sql Line 97: BEGIN Line 98: UPDATE images Line 99: SET size = v_size, Line 100: lastModified = v_lastModified Line 101: WHERE image_group_id = v_image_group_id; The name of java method which executes this function is "UpdateImagesSize". It probably better describes the purpose: by image id I can update the size of the single image, but I have to update size of all snapshots. Line 102: END; $procedure$ Line 103: LANGUAGE plpgsql; Line 104: Line 105: .................................................... File backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/ExtendImageSizeCommand.java Line 30: import java.util.ArrayList; Line 31: import java.util.List; Line 32: Line 33: @InternalCommandAttribute Line 34: public class ExtendImageSizeCommand<T extends ExtendImageSizeParameters> extends BaseImagesCommand<T> Done Line 35: implements QuotaStorageDependent { Line 36: Line 37: private List<PermissionSubject> permissionsList; Line 38: private List<VM> vmsDiskPluggedTo; Line 49: validateImageFormat() && Line 50: validateVMStatus(); Line 51: } Line 52: Line 53: protected boolean isImageExist() { Done Line 54: if (getImage() == null) { Line 55: return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_DISK_NOT_EXIST); Line 56: } Line 57: return true; Line 57: return true; Line 58: } Line 59: Line 60: protected boolean isFeatureSupported() { Line 61: StoragePool storagePool = getStoragePoolDAO().get(getParameters().getStoragePoolId()); Done Line 62: if (!FeatureSupported.extendImageSizeSupported(storagePool.getcompatibility_version())) { Line 63: return failCanDoAction(VdcBllMessages.ACTION_NOT_SUPPORTED_FOR_CLUSTER_POOL_LEVEL); Line 64: } Line 65: return true; Line 65: return true; Line 66: } Line 67: Line 68: protected boolean validateNewSize() { Line 69: if (getImage().getSize() > getParameters().getNewSize()) { This is command is internal and called only if disk size was changed, therefore "=" is impossible. Line 70: return failCanDoAction(VdcBllMessages.ACTION_TYPE_FAILED_SHRINK_IS_NOT_SUPPORTED); Line 71: } Line 72: return true; Line 73: } Line 87: } Line 88: Line 89: @Override Line 90: protected void executeCommand() { Line 91: VDSReturnValue vdsReturnValue = extendUnderlyingVolumeSize(getImage()); Parent command doing that Line 92: setSucceeded(vdsReturnValue.getSucceeded()); Line 93: Line 94: if (vdsReturnValue.getSucceeded()) { Line 95: Guid taskId = createTask(vdsReturnValue.getCreationInfo(), getParameters().getParentCommand()); Line 94: if (vdsReturnValue.getSucceeded()) { Line 95: Guid taskId = createTask(vdsReturnValue.getCreationInfo(), getParameters().getParentCommand()); Line 96: getReturnValue().getInternalTaskIdList().add(taskId); Line 97: } else { Line 98: updateAuditLog(AuditLogType.USER_EXTEND_DISK_SIZE_FAILURE); This is internal command... Line 99: } Line 100: } Line 101: Line 102: private VDSReturnValue extendUnderlyingVolumeSize(DiskImage diskImage) { Line 129: private void updateRelevantVms() { Line 130: List<VM> vms = getVmsDiskPluggedTo(); Line 131: Line 132: for (VM vm : vms) { Line 133: if (vm.getStatus().isUpOrPaused() || vms.size() == 1) { In case of QCOW disk format, QCOW header must be synced with volume metadata. I will add a comment in the code. Line 134: try { Line 135: VDSReturnValue ret = extendVmDiskSize(vm, getParameters().getNewSize()); Line 136: if (!ret.getSucceeded()) { Line 137: updateAuditLogFailedToUpdateVM(vm.getName()); Line 136: if (!ret.getSucceeded()) { Line 137: updateAuditLogFailedToUpdateVM(vm.getName()); Line 138: } Line 139: } catch (RuntimeException e) { Line 140: if (log.isWarnEnabled()) { Done Line 141: log.warnFormat("Failed to update VM '{0}' with the new volume size due to error: {1}." + Line 142: "VM should be restarted to detect the new size.", Line 143: vm.getName(), ExceptionUtils.getMessage(e)); Line 144: } Line 149: } Line 150: Line 151: private VDSReturnValue extendVmDiskSize(VM vm, Long newSize) { Line 152: Guid vdsId, vmId; Line 153: Done Line 154: if (vm.getStatus().isUpOrPaused()) { Line 155: vdsId = vm.getRunOnVds().getValue(); Line 156: vmId = vm.getId(); Line 157: } else if (vm.getStatus().isDownOrSuspended()) { Line 157: } else if (vm.getStatus().isDownOrSuspended()) { Line 158: vdsId = getStoragePool().getspm_vds_id().getValue(); Line 159: vmId = Guid.Empty; Line 160: } else { Line 161: throw new RuntimeException("The VM '" + vm.getName() + "' status is illegal!"); VM should be locked by the parent command Line 162: } Line 163: Line 164: ExtendVmDiskSizeVDSCommandParameters params = new ExtendVmDiskSizeVDSCommandParameters(vdsId, vmId, Line 165: getParameters().getStoragePoolId(), getParameters().getStorageDomainId(), Line 191: updateAuditLog(AuditLogType.USER_EXTEND_DISK_SIZE_FAILURE); Line 192: } Line 193: Line 194: private void updateAuditLog(AuditLogType auditLogType) { Line 195: addCustomValue("DiskId", getImageId().toString()); Done Line 196: addCustomValue("UserName", getUserName()); Line 197: AuditLogDirector.log(this, auditLogType); Line 198: } Line 199: Line 205: @Override Line 206: public List<PermissionSubject> getPermissionCheckSubjects() { Line 207: if (permissionsList == null) { Line 208: permissionsList = new ArrayList<PermissionSubject>(); Line 209: permissionsList.add(new PermissionSubject(getImageId(), VdcObjectType.Disk, ActionGroup.EDIT_DISK_PROPERTIES)); Done Line 210: } Line 211: Line 212: return permissionsList; Line 213: } Line 246: if (vmsDiskPluggedTo == null) { Line 247: vmsDiskPluggedTo = getVmDAO().getForDisk(getImage().getId()).get(Boolean.TRUE); Line 248: Line 249: if (vmsDiskPluggedTo == null) { Line 250: vmsDiskPluggedTo = new ArrayList<VM>(); Done Line 251: } Line 252: } Line 253: return vmsDiskPluggedTo; Line 254: } .................................................... File backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/UpdateVmDiskCommand.java Line 35: import org.ovirt.engine.core.common.utils.Pair; Line 36: import org.ovirt.engine.core.compat.Guid; Line 37: import org.ovirt.engine.core.utils.transaction.TransactionMethod; Line 38: import org.ovirt.engine.core.utils.transaction.TransactionSupport; Line 39: This is the parent command of ExtendImageSizeCommand so most changes are really necessary for the feature, but not all of them. Anyway, I can't separate them, sorry. Line 40: @LockIdNameAttribute Line 41: @NonTransactiveCommandAttribute Line 42: public class UpdateVmDiskCommand<T extends UpdateVmDiskParameters> extends AbstractDiskVmCommand<T> Line 43: implements QuotaStorageDependent { Line 154: Line 155: return true; Line 156: } Line 157: Line 158: private boolean validateImageStatus() { Done Line 159: DiskImage diskImage = (DiskImage) getOldDisk(); Line 160: if (diskImage.getImageStatus() == ImageStatus.LOCKED) { Line 161: addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_DISKS_LOCKED); Line 162: addCanDoActionMessage(String.format("$%1$s %2$s", "diskAliases", getOldDisk().getDiskAlias())); Line 248: public Object runInTransaction() { Line 249: getVmStaticDAO().incrementDbGeneration(getVm().getId()); Line 250: updateSnapshotIdOnShareableChange(diskToUpdate, getNewDisk()); Line 251: clearAddressOnInterfaceChange(diskToUpdate, getNewDisk()); Line 252: diskToUpdate.setBoot(getNewDisk().isBoot()); Done Line 253: diskToUpdate.setDiskInterface(getNewDisk().getDiskInterface()); Line 254: diskToUpdate.setPropagateErrors(getNewDisk().getPropagateErrors()); Line 255: diskToUpdate.setWipeAfterDelete(getNewDisk().isWipeAfterDelete()); Line 256: diskToUpdate.setDiskAlias(getNewDisk().getDiskAlias()); Line 301: if (ret.getSucceeded()) { Line 302: getReturnValue().getTaskIdList().addAll(ret.getInternalTaskIdList()); Line 303: } else { Line 304: propagateInternalCommandFailure(ret); Line 305: unlockImageInDb(); Done Line 306: getReturnValue().setFault(ret.getFault()); Line 307: } Line 308: setSucceeded(ret.getSucceeded()); Line 309: } Line 484: return vmsDiskPluggedTo; Line 485: } Line 486: Line 487: private void lockImageInDb() { Line 488: updateImageStatus(ImageStatus.LOCKED); Done Line 489: } Line 490: Line 491: private void unlockImageInDb() { Line 492: updateImageStatus(ImageStatus.OK); .................................................... File backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/vdscommands/ExtendVmDiskSizeVDSCommandParameters.java Line 4: Line 5: import java.util.HashMap; Line 6: import java.util.Map; Line 7: Line 8: public class ExtendVmDiskSizeVDSCommandParameters extends VdsAndVmIDVDSParametersBase { I am not sure its possible. Everything is about the hierarchy. One of them is IIrs... the second is IVds... And generally, most our(storage) parameters contain at least storagePoolId and storageDomainId. Line 9: Line 10: private long newSize; Line 11: private Guid storagePoolId; Line 12: private Guid storageDomainId; .................................................... File frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/AbstractDiskModel.java Line 443: boolean isShareableDiskEnabled = (Boolean) AsyncDataProvider.getConfigValuePreConverted( Line 444: ConfigurationValues.ShareableDiskEnabled, datacenter.getcompatibility_version().getValue()); Line 445: Line 446: getIsShareable().setChangeProhibitionReason(CONSTANTS.shareableDiskNotSupported()); Line 447: getIsShareable().setIsChangable(isShareableDiskEnabled && isVmDown()); Till now user couldn't "edit" disk properties for running VM. The "edit" link was disabled for any VM state other than "DOWN". Now user can resize VM disk even if VM is running(statuses - UP and PAUSED), but I still have to verify that all other properties are disabled. Line 448: } Line 449: Line 450: private void updateDirectLunDiskEnabled(StoragePool datacenter) { Line 451: boolean isInternal = (Boolean) getIsInternal().getEntity(); .................................................... File frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/EditDiskModel.java Line 138: getStorageType().setIsChangable(false); Line 139: getDataCenter().setIsChangable(false); Line 140: getVolumeType().setIsChangable(false); Line 141: getSize().setIsChangable(false); Line 142: getSizeExtend().setIsChangable(isExtendImageSizeAllowed()); "size" is the actual size of the disk, this field is not editable in UI. I added new input field in UI - "Size to extend(GB)" so "sizeExtend" is the entity that receives the value from the new input. Line 143: Line 144: if (!isVmDown()) { Line 145: getDescription().setIsChangable(false); Line 146: getAlias().setIsChangable(false); .................................................... File frontend/webadmin/modules/userportal-gwtp/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties Line 206: ACTION_TYPE_FAILED_STORAGE_DOMAIN_ALREADY_EXIST=Cannot ${action} ${type}. The Storage Domain already exists. Line 207: ACTION_TYPE_FAILED_STORAGE_POOL_NAME_ALREADY_EXIST=Cannot ${action} ${type}. The Data Center name is already in use. Line 208: ACTION_TYPE_FAILED_TEMPLATE_NOT_FOUND_ON_DESTINATION_DOMAIN=Cannot ${action} ${type}. The selected Storage Domain does not contain the VM Template. Line 209: ACTION_TYPE_FAILED_NO_VDS_IN_POOL=Cannot ${action} ${type}. There is no active Host in the Data Center. Line 210: ACTION_TYPE_FAILED_SHRINK_IS_NOT_SUPPORTED=Cannot ${action}. New disk size cannot be smaller than the current. Good point, I will change. Line 211: ACTION_TYPE_FAILED_NOT_SUPPORTED_IMAGE_FORMAT=Cannot ${action}. The selected disk format is not supported. Line 212: ACTION_TYPE_FAILED_ILLEGAL_DISK_OPERATION=Cannot ${action} ${type}. Disk is in illegal state. Illegal disks can only be deleted. Line 213: VAR__TYPE__HOST=$type Host Line 214: VAR__ENTITIES__HOSTS=$entities hosts Line 207: ACTION_TYPE_FAILED_STORAGE_POOL_NAME_ALREADY_EXIST=Cannot ${action} ${type}. The Data Center name is already in use. Line 208: ACTION_TYPE_FAILED_TEMPLATE_NOT_FOUND_ON_DESTINATION_DOMAIN=Cannot ${action} ${type}. The selected Storage Domain does not contain the VM Template. Line 209: ACTION_TYPE_FAILED_NO_VDS_IN_POOL=Cannot ${action} ${type}. There is no active Host in the Data Center. Line 210: ACTION_TYPE_FAILED_SHRINK_IS_NOT_SUPPORTED=Cannot ${action}. New disk size cannot be smaller than the current. Line 211: ACTION_TYPE_FAILED_NOT_SUPPORTED_IMAGE_FORMAT=Cannot ${action}. The selected disk format is not supported. I forgot to remove the volume format validation, message will be removed either. Line 212: ACTION_TYPE_FAILED_ILLEGAL_DISK_OPERATION=Cannot ${action} ${type}. Disk is in illegal state. Illegal disks can only be deleted. Line 213: VAR__TYPE__HOST=$type Host Line 214: VAR__ENTITIES__HOSTS=$entities hosts Line 215: VAR__TYPE__NETWORK=$type Network Line 208: ACTION_TYPE_FAILED_TEMPLATE_NOT_FOUND_ON_DESTINATION_DOMAIN=Cannot ${action} ${type}. The selected Storage Domain does not contain the VM Template. Line 209: ACTION_TYPE_FAILED_NO_VDS_IN_POOL=Cannot ${action} ${type}. There is no active Host in the Data Center. Line 210: ACTION_TYPE_FAILED_SHRINK_IS_NOT_SUPPORTED=Cannot ${action}. New disk size cannot be smaller than the current. Line 211: ACTION_TYPE_FAILED_NOT_SUPPORTED_IMAGE_FORMAT=Cannot ${action}. The selected disk format is not supported. Line 212: ACTION_TYPE_FAILED_ILLEGAL_DISK_OPERATION=Cannot ${action} ${type}. Disk is in illegal state. Illegal disks can only be deleted. Message is removed. Line 213: VAR__TYPE__HOST=$type Host Line 214: VAR__ENTITIES__HOSTS=$entities hosts Line 215: VAR__TYPE__NETWORK=$type Network Line 216: VAR__TYPE__NETWORKS=$type Networks .................................................... File frontend/webadmin/modules/webadmin/src/main/resources/org/ovirt/engine/ui/frontend/AppErrors.properties Line 204: ACTION_TYPE_FAILED_TEMPLATE_NOT_FOUND_ON_DESTINATION_DOMAIN=Cannot ${action} ${type}. The selected Storage Domain does not contain the VM Template. Line 205: ACTION_TYPE_FAILED_NO_VDS_IN_POOL=Cannot ${action} ${type}. There is no active Host in the Data Center. Line 206: ACTION_TYPE_FAILED_SHRINK_IS_NOT_SUPPORTED=Cannot ${action} ${type}. New disk size cannot be smaller than the current. Line 207: ACTION_TYPE_FAILED_NOT_SUPPORTED_IMAGE_FORMAT=Cannot ${action}. The selected disk format is not supported. Line 208: ACTION_TYPE_FAILED_ILLEGAL_DISK_OPERATION=Cannot ${action} ${type}. Disk is in illegal state. Illegal disks can only be deleted. Message is removed. Line 209: VAR__TYPE__HOST=$type Host Line 210: VAR__ENTITIES__HOSTS=$entities hosts Line 211: VAR__TYPE__NETWORK=$type Network Line 212: VAR__TYPE__NETWORKS=$type Networks -- To view, visit http://gerrit.ovirt.org/14975 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: comment Gerrit-Change-Id: Ie702348a68a26ac02a01f66aaa1ea42c2c675ebb Gerrit-PatchSet: 8 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Sergey Gotliv <sgot...@redhat.com> Gerrit-Reviewer: A Burden <abur...@redhat.com> Gerrit-Reviewer: Alissa Bonas <abo...@redhat.com> Gerrit-Reviewer: Allon Mureinik <amure...@redhat.com> Gerrit-Reviewer: Cheryn Tan <cheryn...@redhat.com> Gerrit-Reviewer: Daniel Erez <de...@redhat.com> Gerrit-Reviewer: Federico Simoncelli <fsimo...@redhat.com> Gerrit-Reviewer: Liron Ar <lara...@redhat.com> Gerrit-Reviewer: Sergey Gotliv <sgot...@redhat.com> Gerrit-Reviewer: Tal Nisan <tni...@redhat.com> Gerrit-Reviewer: oVirt Jenkins CI Server _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches