Source:
protected boolean validateShareableDisk() { if (DiskStorageType.LUN == oldDisk.getDiskStorageType()) { return true; } boolean isDiskUpdatedToShareable = newDisk.isShareable(); boolean isOldDiskSharable = oldDisk.isShareable(); if (getSnapshotDao().exists(getVmId(), SnapshotStatus.IN_PREVIEW)) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_VM_IN_PREVIEW); return false; } if (!isOldDiskSharable && isDiskUpdatedToShareable) { List<DiskImage> diskImageList = getDiskImageDao().getAllSnapshotsForImageGroup(oldDisk.getId()); if ((diskImageList.size() > 1) || !Guid.Empty.equals(((DiskImage) oldDisk).getit_guid())) { addCanDoActionMessage(VdcBllMessages.SHAREABLE_DISK_IS_NOT_SUPPORTED_FOR_DISK); return false; } if (!isVersionSupportedForShareable(oldDisk, getStoragePoolDAO().get(getVm().getStoragePoolId()) .getcompatibility_version() .getValue())) { addCanDoActionMessage(VdcBllMessages.ACTION_NOT_SUPPORTED_FOR_CLUSTER_POOL_LEVEL); return false; } DiskImage diskImage = (DiskImage) newDisk; if (!isVolumeFormatSupportedForShareable(diskImage.getvolume_format())) { addCanDoActionMessage(VdcBllMessages.SHAREABLE_DISK_IS_NOT_SUPPORTED_BY_VOLUME_FORMAT); return false; } ((DiskImage) oldDisk).setvm_snapshot_id(null); } else if (isOldDiskSharable && !isDiskUpdatedToShareable) { if (getVmDAO().getVmsListForDisk(oldDisk.getId()).size() > 1) { addCanDoActionMessage(VdcBllMessages.DISK_IS_ALREADY_SHARED_BETWEEN_VMS); return false; } ((DiskImage) oldDisk).setvm_snapshot_id(DbFacade.getInstance() .getSnapshotDao() .getId(getVmId(), SnapshotType.ACTIVE) .getValue()); } return true; }

Target:
protected boolean validateShareableDisk() { if (DiskStorageType.LUN == oldDisk.getDiskStorageType()) { return true; } boolean isDiskUpdatedToShareable = newDisk.isShareable(); boolean isOldDiskShaerable = oldDisk.isShareable(); if (getSnapshotDao().exists(getVmId(), SnapshotStatus.IN_PREVIEW)) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_VM_IN_PREVIEW); return false; } if (!isOldDiskShaerable && isDiskUpdatedToShareable) { List<DiskImage> diskImageList = getDiskImageDao().getAllSnapshotsForImageGroup(oldDisk.getId()); if ((diskImageList.size() > 1) || !Guid.Empty.equals(((DiskImage) oldDisk).getit_guid())) { addCanDoActionMessage(VdcBllMessages.SHAREABLE_DISK_IS_NOT_SUPPORTED_FOR_DISK); return false; } if (!isVersionSupportedForShareable(oldDisk, getStoragePoolDAO().get(getVm().getStoragePoolId()) .getcompatibility_version() .getValue())) { addCanDoActionMessage(VdcBllMessages.ACTION_NOT_SUPPORTED_FOR_CLUSTER_POOL_LEVEL); return false; } DiskImage diskImage = (DiskImage) newDisk; if (!isVolumeFormatSupportedForShareable(diskImage.getvolume_format())) { addCanDoActionMessage(VdcBllMessages.SHAREABLE_DISK_IS_NOT_SUPPORTED_BY_VOLUME_FORMAT); return false; } ((DiskImage) oldDisk).setvm_snapshot_id(null); } else if (isOldDiskShaerable && !isDiskUpdatedToShareable) { if (getVmDAO().getVmsListForDisk(oldDisk.getId()).size() > 1) { addCanDoActionMessage(VdcBllMessages.DISK_IS_ALREADY_SHARED_BETWEEN_VMS); return false; } ((DiskImage) oldDisk).setvm_snapshot_id(DbFacade.getInstance() .getSnapshotDao() .getId(getVmId(), SnapshotType.ACTIVE) .getValue()); } return true; }