@Test public void testUpdateVolume() { _svc.updateVolume(2L, "toor", null, null, null, null, null, 1L, null, null); Assert.assertEquals("toor", _svc._volsDao.findById(2L).getName()); }
@Override @ActionEvent(eventType = EventTypes.EVENT_VOLUME_UPDATE, eventDescription = "updating volume", async = true) public Volume updateVolume(final long volumeId, final String name, final String path, final String state, final Long storageId, final Boolean displayVolume, final String customId, final long entityOwnerId, final String chainInfo, final DiskControllerType diskControllerType) { final VolumeVO volume = this._volsDao.findById(volumeId); if (volume.getInstanceId() != null) { final VMInstanceVO vmInstanceVO = this._vmInstanceDao.findById(volume.getInstanceId()); if (vmInstanceVO.getState() != State.Stopped) { throw new CloudRuntimeException("Volume is attached to a running VM, unable to update volume at this point."); } } if (volume == null) { throw new InvalidParameterValueException("The volume id doesn't exist"); } if (name != null) { volume.setName(name); } if (path != null) { volume.setPath(path); } if (chainInfo != null) { volume.setChainInfo(chainInfo); } if (diskControllerType != null) { volume.setDiskController(diskControllerType); } if (state != null) { try { final Volume.State volumeState = Volume.State.valueOf(state); volume.setState(volumeState); } catch (final IllegalArgumentException ex) { throw new InvalidParameterValueException("Invalid volume state specified"); } } if (storageId != null) { final StoragePool pool = this._storagePoolDao.findById(storageId); if (pool.getDataCenterId() != volume.getDataCenterId()) { throw new InvalidParameterValueException("Invalid storageId specified; refers to the pool outside of the volume's zone"); } volume.setPoolId(pool.getId()); } if (customId != null) { volume.setUuid(customId); } updateDisplay(volume, displayVolume); this._volsDao.update(volumeId, volume); return volume; }
VolumeApiServiceImpl extends ManagerBase implements VolumeApiService, VmWorkJobHandler { @Override @ActionEvent(eventType = EventTypes.EVENT_VOLUME_UPDATE, eventDescription = "updating volume", async = true) public Volume updateVolume(final long volumeId, final String name, final String path, final String state, final Long storageId, final Boolean displayVolume, final String customId, final long entityOwnerId, final String chainInfo, final DiskControllerType diskControllerType) { final VolumeVO volume = this._volsDao.findById(volumeId); if (volume.getInstanceId() != null) { final VMInstanceVO vmInstanceVO = this._vmInstanceDao.findById(volume.getInstanceId()); if (vmInstanceVO.getState() != State.Stopped) { throw new CloudRuntimeException("Volume is attached to a running VM, unable to update volume at this point."); } } if (volume == null) { throw new InvalidParameterValueException("The volume id doesn't exist"); } if (name != null) { volume.setName(name); } if (path != null) { volume.setPath(path); } if (chainInfo != null) { volume.setChainInfo(chainInfo); } if (diskControllerType != null) { volume.setDiskController(diskControllerType); } if (state != null) { try { final Volume.State volumeState = Volume.State.valueOf(state); volume.setState(volumeState); } catch (final IllegalArgumentException ex) { throw new InvalidParameterValueException("Invalid volume state specified"); } } if (storageId != null) { final StoragePool pool = this._storagePoolDao.findById(storageId); if (pool.getDataCenterId() != volume.getDataCenterId()) { throw new InvalidParameterValueException("Invalid storageId specified; refers to the pool outside of the volume's zone"); } volume.setPoolId(pool.getId()); } if (customId != null) { volume.setUuid(customId); } updateDisplay(volume, displayVolume); this._volsDao.update(volumeId, volume); return volume; } }
VolumeApiServiceImpl extends ManagerBase implements VolumeApiService, VmWorkJobHandler { @Override @ActionEvent(eventType = EventTypes.EVENT_VOLUME_UPDATE, eventDescription = "updating volume", async = true) public Volume updateVolume(final long volumeId, final String name, final String path, final String state, final Long storageId, final Boolean displayVolume, final String customId, final long entityOwnerId, final String chainInfo, final DiskControllerType diskControllerType) { final VolumeVO volume = this._volsDao.findById(volumeId); if (volume.getInstanceId() != null) { final VMInstanceVO vmInstanceVO = this._vmInstanceDao.findById(volume.getInstanceId()); if (vmInstanceVO.getState() != State.Stopped) { throw new CloudRuntimeException("Volume is attached to a running VM, unable to update volume at this point."); } } if (volume == null) { throw new InvalidParameterValueException("The volume id doesn't exist"); } if (name != null) { volume.setName(name); } if (path != null) { volume.setPath(path); } if (chainInfo != null) { volume.setChainInfo(chainInfo); } if (diskControllerType != null) { volume.setDiskController(diskControllerType); } if (state != null) { try { final Volume.State volumeState = Volume.State.valueOf(state); volume.setState(volumeState); } catch (final IllegalArgumentException ex) { throw new InvalidParameterValueException("Invalid volume state specified"); } } if (storageId != null) { final StoragePool pool = this._storagePoolDao.findById(storageId); if (pool.getDataCenterId() != volume.getDataCenterId()) { throw new InvalidParameterValueException("Invalid storageId specified; refers to the pool outside of the volume's zone"); } volume.setPoolId(pool.getId()); } if (customId != null) { volume.setUuid(customId); } updateDisplay(volume, displayVolume); this._volsDao.update(volumeId, volume); return volume; } protected  VolumeApiServiceImpl(); }
VolumeApiServiceImpl extends ManagerBase implements VolumeApiService, VmWorkJobHandler { @Override @ActionEvent(eventType = EventTypes.EVENT_VOLUME_UPDATE, eventDescription = "updating volume", async = true) public Volume updateVolume(final long volumeId, final String name, final String path, final String state, final Long storageId, final Boolean displayVolume, final String customId, final long entityOwnerId, final String chainInfo, final DiskControllerType diskControllerType) { final VolumeVO volume = this._volsDao.findById(volumeId); if (volume.getInstanceId() != null) { final VMInstanceVO vmInstanceVO = this._vmInstanceDao.findById(volume.getInstanceId()); if (vmInstanceVO.getState() != State.Stopped) { throw new CloudRuntimeException("Volume is attached to a running VM, unable to update volume at this point."); } } if (volume == null) { throw new InvalidParameterValueException("The volume id doesn't exist"); } if (name != null) { volume.setName(name); } if (path != null) { volume.setPath(path); } if (chainInfo != null) { volume.setChainInfo(chainInfo); } if (diskControllerType != null) { volume.setDiskController(diskControllerType); } if (state != null) { try { final Volume.State volumeState = Volume.State.valueOf(state); volume.setState(volumeState); } catch (final IllegalArgumentException ex) { throw new InvalidParameterValueException("Invalid volume state specified"); } } if (storageId != null) { final StoragePool pool = this._storagePoolDao.findById(storageId); if (pool.getDataCenterId() != volume.getDataCenterId()) { throw new InvalidParameterValueException("Invalid storageId specified; refers to the pool outside of the volume's zone"); } volume.setPoolId(pool.getId()); } if (customId != null) { volume.setUuid(customId); } updateDisplay(volume, displayVolume); this._volsDao.update(volumeId, volume); return volume; } protected  VolumeApiServiceImpl(); @Override @DB @ActionEvent(eventType = EventTypes.EVENT_VOLUME_CREATE, eventDescription = "creating volume", create = true) VolumeVO allocVolume(final CreateVolumeCmd cmd); boolean validateVolumeSizeRange(final long size); String getVolumeNameFromCommand(final CreateVolumeCmd cmd); String getRandomVolumeName(); @Override @DB @ActionEvent(eventType = EventTypes.EVENT_VOLUME_CREATE, eventDescription = "creating volume", async = true) VolumeVO createVolume(final CreateVolumeCmd cmd); Volume attachVolumeToVM(final Long vmId, final Long volumeId, final Long deviceId); Outcome<Volume> attachVolumeToVmThroughJobQueue(final Long vmId, final Long volumeId, final Long deviceId, final DiskControllerType diskController); @Override @DB @ActionEvent(eventType = EventTypes.EVENT_VOLUME_RESIZE, eventDescription = "resizing volume", async = true) VolumeVO resizeVolume(final ResizeVolumeCmd cmd); 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); @DB @Override @ActionEvent(eventType = EventTypes.EVENT_VOLUME_MIGRATE, eventDescription = "migrating volume", async = true) Volume migrateVolume(final MigrateVolumeCmd cmd); @Override @DB @ActionEvent(eventType = EventTypes.EVENT_VOLUME_UPLOAD, eventDescription = "uploading volume", async = true) VolumeVO uploadVolume(final UploadVolumeCmd cmd); @Override @ActionEvent(eventType = EventTypes.EVENT_VOLUME_UPLOAD, eventDescription = "uploading volume for post upload", async = true) GetUploadParamsResponse uploadVolume(final GetUploadParamsForVolumeCmd cmd); @Override @DB @ActionEvent(eventType = EventTypes.EVENT_VOLUME_DELETE, eventDescription = "deleting volume") boolean deleteVolume(final long volumeId, final Account caller); @Override @ActionEvent(eventType = EventTypes.EVENT_VOLUME_ATTACH, eventDescription = "attaching volume", async = true) Volume attachVolumeToVM(final AttachVolumeCmd command); @Override @ActionEvent(eventType = EventTypes.EVENT_VOLUME_DETACH, eventDescription = "detaching volume", async = true) Volume detachVolumeFromVM(final DetachVolumeCmd cmmd); Outcome<Volume> detachVolumeFromVmThroughJobQueue(final Long vmId, final Long volumeId); @Override @ActionEvent(eventType = EventTypes.EVENT_SNAPSHOT_CREATE, eventDescription = "taking snapshot", async = true) Snapshot takeSnapshot(final Long volumeId, final Long policyId, final Long snapshotId, final Account account, final boolean quiescevm); Outcome<Snapshot> takeVolumeSnapshotThroughJobQueue(final Long vmId, final Long volumeId,
                                                               final Long policyId, final Long snapshotId, final Long accountId, final boolean quiesceVm); @Override @ActionEvent(eventType = EventTypes.EVENT_SNAPSHOT_CREATE, eventDescription = "allocating snapshot", create = true) Snapshot allocSnapshot(final Long volumeId, final Long policyId, final String snapshotName); @Override Snapshot allocSnapshotForVm(final Long vmId, final Long volumeId, final String snapshotName); @Override @ActionEvent(eventType = EventTypes.EVENT_VOLUME_UPDATE, eventDescription = "updating volume", async = true) Volume updateVolume(final long volumeId, final String name, final String path, final String state, final Long storageId, final Boolean displayVolume, final String customId, final long
            entityOwnerId, final String chainInfo, final DiskControllerType diskControllerType); @Override @ActionEvent(eventType = EventTypes.EVENT_VOLUME_EXTRACT, eventDescription = "extracting volume", async = true) String extractVolume(final ExtractVolumeCmd cmd); Outcome<String> extractVolumeThroughJobQueue(final Long vmId, final long volumeId,
                                                        final long zoneId); @Override boolean isDisplayResourceEnabled(final Long id); @Override void updateDisplay(final Volume volume, final Boolean displayVolume); Outcome<Volume> migrateVolumeThroughJobQueue(final Long vmId, final long volumeId,
                                                        final long destPoolId, final boolean liveMigrate); @Override boolean configure(final String name, final Map<String, Object> params); List<StoragePoolAllocator> getStoragePoolAllocators(); @Inject void setStoragePoolAllocators(final List<StoragePoolAllocator> storagePoolAllocators); @Override Pair<JobInfo.Status, String> handleVmWorkJob(final VmWork work); }
VolumeApiServiceImpl extends ManagerBase implements VolumeApiService, VmWorkJobHandler { @Override @ActionEvent(eventType = EventTypes.EVENT_VOLUME_UPDATE, eventDescription = "updating volume", async = true) public Volume updateVolume(final long volumeId, final String name, final String path, final String state, final Long storageId, final Boolean displayVolume, final String customId, final long entityOwnerId, final String chainInfo, final DiskControllerType diskControllerType) { final VolumeVO volume = this._volsDao.findById(volumeId); if (volume.getInstanceId() != null) { final VMInstanceVO vmInstanceVO = this._vmInstanceDao.findById(volume.getInstanceId()); if (vmInstanceVO.getState() != State.Stopped) { throw new CloudRuntimeException("Volume is attached to a running VM, unable to update volume at this point."); } } if (volume == null) { throw new InvalidParameterValueException("The volume id doesn't exist"); } if (name != null) { volume.setName(name); } if (path != null) { volume.setPath(path); } if (chainInfo != null) { volume.setChainInfo(chainInfo); } if (diskControllerType != null) { volume.setDiskController(diskControllerType); } if (state != null) { try { final Volume.State volumeState = Volume.State.valueOf(state); volume.setState(volumeState); } catch (final IllegalArgumentException ex) { throw new InvalidParameterValueException("Invalid volume state specified"); } } if (storageId != null) { final StoragePool pool = this._storagePoolDao.findById(storageId); if (pool.getDataCenterId() != volume.getDataCenterId()) { throw new InvalidParameterValueException("Invalid storageId specified; refers to the pool outside of the volume's zone"); } volume.setPoolId(pool.getId()); } if (customId != null) { volume.setUuid(customId); } updateDisplay(volume, displayVolume); this._volsDao.update(volumeId, volume); return volume; } protected  VolumeApiServiceImpl(); @Override @DB @ActionEvent(eventType = EventTypes.EVENT_VOLUME_CREATE, eventDescription = "creating volume", create = true) VolumeVO allocVolume(final CreateVolumeCmd cmd); boolean validateVolumeSizeRange(final long size); String getVolumeNameFromCommand(final CreateVolumeCmd cmd); String getRandomVolumeName(); @Override @DB @ActionEvent(eventType = EventTypes.EVENT_VOLUME_CREATE, eventDescription = "creating volume", async = true) VolumeVO createVolume(final CreateVolumeCmd cmd); Volume attachVolumeToVM(final Long vmId, final Long volumeId, final Long deviceId); Outcome<Volume> attachVolumeToVmThroughJobQueue(final Long vmId, final Long volumeId, final Long deviceId, final DiskControllerType diskController); @Override @DB @ActionEvent(eventType = EventTypes.EVENT_VOLUME_RESIZE, eventDescription = "resizing volume", async = true) VolumeVO resizeVolume(final ResizeVolumeCmd cmd); 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); @DB @Override @ActionEvent(eventType = EventTypes.EVENT_VOLUME_MIGRATE, eventDescription = "migrating volume", async = true) Volume migrateVolume(final MigrateVolumeCmd cmd); @Override @DB @ActionEvent(eventType = EventTypes.EVENT_VOLUME_UPLOAD, eventDescription = "uploading volume", async = true) VolumeVO uploadVolume(final UploadVolumeCmd cmd); @Override @ActionEvent(eventType = EventTypes.EVENT_VOLUME_UPLOAD, eventDescription = "uploading volume for post upload", async = true) GetUploadParamsResponse uploadVolume(final GetUploadParamsForVolumeCmd cmd); @Override @DB @ActionEvent(eventType = EventTypes.EVENT_VOLUME_DELETE, eventDescription = "deleting volume") boolean deleteVolume(final long volumeId, final Account caller); @Override @ActionEvent(eventType = EventTypes.EVENT_VOLUME_ATTACH, eventDescription = "attaching volume", async = true) Volume attachVolumeToVM(final AttachVolumeCmd command); @Override @ActionEvent(eventType = EventTypes.EVENT_VOLUME_DETACH, eventDescription = "detaching volume", async = true) Volume detachVolumeFromVM(final DetachVolumeCmd cmmd); Outcome<Volume> detachVolumeFromVmThroughJobQueue(final Long vmId, final Long volumeId); @Override @ActionEvent(eventType = EventTypes.EVENT_SNAPSHOT_CREATE, eventDescription = "taking snapshot", async = true) Snapshot takeSnapshot(final Long volumeId, final Long policyId, final Long snapshotId, final Account account, final boolean quiescevm); Outcome<Snapshot> takeVolumeSnapshotThroughJobQueue(final Long vmId, final Long volumeId,
                                                               final Long policyId, final Long snapshotId, final Long accountId, final boolean quiesceVm); @Override @ActionEvent(eventType = EventTypes.EVENT_SNAPSHOT_CREATE, eventDescription = "allocating snapshot", create = true) Snapshot allocSnapshot(final Long volumeId, final Long policyId, final String snapshotName); @Override Snapshot allocSnapshotForVm(final Long vmId, final Long volumeId, final String snapshotName); @Override @ActionEvent(eventType = EventTypes.EVENT_VOLUME_UPDATE, eventDescription = "updating volume", async = true) Volume updateVolume(final long volumeId, final String name, final String path, final String state, final Long storageId, final Boolean displayVolume, final String customId, final long
            entityOwnerId, final String chainInfo, final DiskControllerType diskControllerType); @Override @ActionEvent(eventType = EventTypes.EVENT_VOLUME_EXTRACT, eventDescription = "extracting volume", async = true) String extractVolume(final ExtractVolumeCmd cmd); Outcome<String> extractVolumeThroughJobQueue(final Long vmId, final long volumeId,
                                                        final long zoneId); @Override boolean isDisplayResourceEnabled(final Long id); @Override void updateDisplay(final Volume volume, final Boolean displayVolume); Outcome<Volume> migrateVolumeThroughJobQueue(final Long vmId, final long volumeId,
                                                        final long destPoolId, final boolean liveMigrate); @Override boolean configure(final String name, final Map<String, Object> params); List<StoragePoolAllocator> getStoragePoolAllocators(); @Inject void setStoragePoolAllocators(final List<StoragePoolAllocator> storagePoolAllocators); @Override Pair<JobInfo.Status, String> handleVmWorkJob(final VmWork work); static final String VM_WORK_JOB_HANDLER; }