VolumeApiServiceImpl extends ManagerBase implements VolumeApiService, VmWorkJobHandler { @Override @ActionEvent(eventType = EventTypes.EVENT_VOLUME_ATTACH, eventDescription = "attaching volume", async = true) public Volume attachVolumeToVM(AttachVolumeCmd command) { return attachVolumeToVM(command.getVirtualMachineId(), command.getId(), command.getDeviceId()); } protected  VolumeApiServiceImpl(); @Override @DB @ActionEvent(eventType = EventTypes.EVENT_VOLUME_UPLOAD, eventDescription = "uploading volume", async = true) VolumeVO uploadVolume(UploadVolumeCmd cmd); @Override @ActionEvent(eventType = EventTypes.EVENT_VOLUME_UPLOAD, eventDescription = "uploading volume for post upload", async = true) GetUploadParamsResponse uploadVolume(final GetUploadParamsForVolumeCmd cmd); String getRandomVolumeName(); String getVolumeNameFromCommand(CreateVolumeCmd cmd); @Override @DB @ActionEvent(eventType = EventTypes.EVENT_VOLUME_CREATE, eventDescription = "creating volume", create = true) VolumeVO allocVolume(CreateVolumeCmd cmd); boolean validateVolumeSizeRange(long size); @Override @DB @ActionEvent(eventType = EventTypes.EVENT_VOLUME_CREATE, eventDescription = "creating volume", async = true) VolumeVO createVolume(CreateVolumeCmd cmd); @Override @DB @ActionEvent(eventType = EventTypes.EVENT_VOLUME_RESIZE, eventDescription = "resizing volume", async = true) VolumeVO resizeVolume(ResizeVolumeCmd cmd); @Override @DB @ActionEvent(eventType = EventTypes.EVENT_VOLUME_DELETE, eventDescription = "deleting volume") boolean deleteVolume(long volumeId, Account caller); @Override @ActionEvent(eventType = EventTypes.EVENT_VOLUME_ATTACH, eventDescription = "attaching volume", async = true) Volume attachVolumeToVM(AttachVolumeCmd command); Volume attachVolumeToVM(Long vmId, Long volumeId, Long deviceId); @Override @ActionEvent(eventType = EventTypes.EVENT_VOLUME_UPDATE, eventDescription = "updating volume", async = true) Volume updateVolume(long volumeId, String path, String state, Long storageId, Boolean displayVolume, String customId, long entityOwnerId, String chainInfo); @Override void updateDisplay(Volume volume, Boolean displayVolume); @Override @ActionEvent(eventType = EventTypes.EVENT_VOLUME_DETACH, eventDescription = "detaching volume", async = true) Volume detachVolumeFromVM(DetachVolumeCmd cmmd); @DB @Override @ActionEvent(eventType = EventTypes.EVENT_VOLUME_MIGRATE, eventDescription = "migrating volume", async = true) Volume migrateVolume(MigrateVolumeCmd cmd); @Override @ActionEvent(eventType = EventTypes.EVENT_SNAPSHOT_CREATE, eventDescription = "taking snapshot", async = true) Snapshot takeSnapshot(Long volumeId, Long policyId, Long snapshotId, Account account, boolean quiescevm); @Override @ActionEvent(eventType = EventTypes.EVENT_SNAPSHOT_CREATE, eventDescription = "allocating snapshot", create = true) Snapshot allocSnapshot(Long volumeId, Long policyId, String snapshotName); @Override @ActionEvent(eventType = EventTypes.EVENT_VOLUME_EXTRACT, eventDescription = "extracting volume", async = true) String extractVolume(ExtractVolumeCmd cmd); @Override boolean isDisplayResourceEnabled(Long id); @Override boolean configure(String name, Map<String, Object> params); List<StoragePoolAllocator> getStoragePoolAllocators(); @Inject void setStoragePoolAllocators(List<StoragePoolAllocator> storagePoolAllocators); Outcome<Volume> attachVolumeToVmThroughJobQueue(final Long vmId, final Long volumeId, final Long deviceId); Outcome<Volume> detachVolumeFromVmThroughJobQueue(final Long vmId, final Long volumeId); Outcome<Volume> resizeVolumeThroughJobQueue(final Long vmId, final long volumeId,
      final long currentSize, final long newSize, final Long newMinIops, final Long newMaxIops, final Long newServiceOfferingId, final boolean shrinkOk); Outcome<String> extractVolumeThroughJobQueue(final Long vmId, final long volumeId,
      final long zoneId); Outcome<Volume> migrateVolumeThroughJobQueue(final Long vmId, final long volumeId,
      final long destPoolId, final boolean liveMigrate); Outcome<Snapshot> takeVolumeSnapshotThroughJobQueue(final Long vmId, final Long volumeId,
      final Long policyId, final Long snapshotId, final Long accountId, final boolean quiesceVm); @Override Pair<JobInfo.Status, String> handleVmWorkJob(VmWork work); static final String VM_WORK_JOB_HANDLER; }
@Test(expected = InvalidParameterValueException.class) public void attachIncorrectDiskType() throws NoSuchFieldException, IllegalAccessException { _svc.attachVolumeToVM(1L, 5L, 0L); }
@Test(expected = InvalidParameterValueException.class) public void attachRootDiskToRunningVm() throws NoSuchFieldException, IllegalAccessException { _svc.attachVolumeToVM(1L, 6L, 0L); }
@Test(expected = InvalidParameterValueException.class) public void attachRootDiskOfManagedDataStore() throws NoSuchFieldException, IllegalAccessException { _svc.attachVolumeToVM(2L, 7L, 0L); }
@Test(expected = InvalidParameterValueException.class) public void attachRootDiskToVmHavingRootDisk() throws NoSuchFieldException, IllegalAccessException { _svc.attachVolumeToVM(4L, 6L, 0L); }
@Test(expected = InvalidParameterValueException.class) public void attachRootInUploadedState() throws NoSuchFieldException, IllegalAccessException { _svc.attachVolumeToVM(2L, 8L, 0L); }
@Test public void attachRootVolumePositive() throws NoSuchFieldException, IllegalAccessException { thrown.expect(NullPointerException.class); _svc.attachVolumeToVM(2L, 6L, 0L); }