Source:
protected boolean canDoAction() { boolean retValue = true; if (disk == null) { retValue = false; addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_VM_IMAGE_DOES_NOT_EXIST); } retValue = retValue && acquireLockInternal() && isVmExist() && isVmUpOrDown() && isDiskCanBeAddedToVm(disk) && isDiskPassPCIAndIDELimit(disk); if (retValue && getVmDeviceDao().exists(new VmDeviceId(disk.getId(), getVmId()))) { retValue = false; addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_DISK_ALREADY_ATTACHED); } if (retValue && disk.isShareable() && !isVersionSupportedForShareable(disk, getStoragePoolDAO().get(getVm().getstorage_pool_id()) .getcompatibility_version() .getValue())) { retValue = false; addCanDoActionMessage(VdcBllMessages.ACTION_NOT_SUPPORTED_FOR_CLUSTER_POOL_LEVEL); } if (retValue && disk.getDiskStorageType() == DiskStorageType.IMAGE && getStoragePoolIsoMapDao().get(new StoragePoolIsoMapId( ((DiskImage) disk).getstorage_ids().get(0), getVm().getstorage_pool_id())) == null) { retValue = false; addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_POOL_NOT_MATCH); } if (retValue && disk.getDiskStorageType() == DiskStorageType.IMAGE) { retValue = validate(new SnapshotsValidator().vmNotDuringSnapshot(getVm().getId())); if (((DiskImage) disk).getimageStatus() == ImageStatus.ILLEGAL) { retValue = false; addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_ILLEGAL_DISK_OPERATION); } } if (retValue && getParameters().isPlugUnPlug() && getVm().getstatus() != VMStatus.Down) { retValue = isOSSupportingHotPlug() && isHotPlugSupported() && isInterfaceSupportedForPlugUnPlug(disk); } return retValue; }

Target:
protected boolean canDoAction() { boolean retValue = true; if (disk == null) { retValue = false; addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_VM_IMAGE_DOES_NOT_EXIST); } boolean isImageDisk = disk.getDiskStorageType() == DiskStorageType.IMAGE; if (isImageDisk && ((DiskImage) disk).getimageStatus() == ImageStatus.ILLEGAL) { addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_ILLEGAL_DISK_OPERATION); return false; } retValue = retValue && acquireLockInternal() && isVmExist() && isVmUpOrDown() && isDiskCanBeAddedToVm(disk) && isDiskPassPCIAndIDELimit(disk); if (retValue && getVmDeviceDao().exists(new VmDeviceId(disk.getId(), getVmId()))) { retValue = false; addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_DISK_ALREADY_ATTACHED); } if (retValue && disk.isShareable() && !isVersionSupportedForShareable(disk, getStoragePoolDAO().get(getVm().getstorage_pool_id()) .getcompatibility_version() .getValue())) { retValue = false; addCanDoActionMessage(VdcBllMessages.ACTION_NOT_SUPPORTED_FOR_CLUSTER_POOL_LEVEL); } if (retValue && isImageDisk && getStoragePoolIsoMapDao().get(new StoragePoolIsoMapId( ((DiskImage) disk).getstorage_ids().get(0), getVm().getstorage_pool_id())) == null) { retValue = false; addCanDoActionMessage(VdcBllMessages.ACTION_TYPE_FAILED_STORAGE_POOL_NOT_MATCH); } if (retValue && isImageDisk) { retValue = validate(new SnapshotsValidator().vmNotDuringSnapshot(getVm().getId())); } if (retValue && getParameters().isPlugUnPlug() && getVm().getstatus() != VMStatus.Down) { retValue = isOSSupportingHotPlug() && isHotPlugSupported() && isInterfaceSupportedForPlugUnPlug(disk); } return retValue; }