Eldan Shachar has uploaded a new change for review. Change subject: restapi: Control\view Soundcard property ......................................................................
restapi: Control\view Soundcard property * Added 'soundcard_enabled' property to REST VM/template/vmpool resource (accessible via 'All-Content' header) * Added support for property in: VM/Template/Instance - Add / Update Pool - Add * Updated rsdl * Updated tests Change-Id: I598cf89b6a5fd4755958cf7b597484c225166460 Bug-Url: https://bugzilla.redhat.com/1021186 Signed-off-by: Eldan Shachar <[email protected]> --- M backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd M backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendInstanceTypeResource.java M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendInstanceTypesResource.java M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendTemplateResource.java M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendTemplatesResource.java M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmPoolsResource.java M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmResource.java M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmsResource.java M backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/util/VmHelper.java M backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendTemplateBasedResourceTest.java M backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendTemplatesBasedResourceTest.java M backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendTemplatesResourceTest.java M backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendVmPoolsResourceTest.java M backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendVmResourceTest.java M backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendVmsResourceTest.java 16 files changed, 174 insertions(+), 6 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/55/32255/1 diff --git a/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd b/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd index e07001e..ddff7b8 100644 --- a/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd +++ b/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd @@ -2639,6 +2639,7 @@ <xs:element name="timezone" type="xs:string" minOccurs="0" maxOccurs="1"/> <xs:element ref="domain" minOccurs="0" maxOccurs="1"/> <xs:element ref="usb" minOccurs="0" maxOccurs="1"/> + <xs:element ref="soundcard_enabled" minOccurs="0" maxOccurs="1"/> <xs:element name="tunnel_migration" type="xs:boolean" minOccurs="0" maxOccurs="1"/> <xs:element name="migration_downtime" type="xs:int" minOccurs="0" maxOccurs="1" /> <xs:element ref="virtio_scsi" minOccurs="0" maxOccurs="1"/> @@ -3059,6 +3060,7 @@ <xs:element name="guest_info" type="GuestInfo" minOccurs="0" maxOccurs="1"/> <xs:element ref="quota" minOccurs="0" maxOccurs="1"/> <xs:element ref="usb" minOccurs="0" maxOccurs="1"/> + <xs:element ref="soundcard_enabled" minOccurs="0" maxOccurs="1"/> <xs:element name="tunnel_migration" type="xs:boolean" minOccurs="0" maxOccurs="1"/> <xs:element name="migration_downtime" type="xs:int" minOccurs="0" maxOccurs="1" /> <xs:element ref="virtio_scsi" minOccurs="0" maxOccurs="1"/> @@ -3247,6 +3249,7 @@ <xs:element name="max_user_vms" type="xs:int" minOccurs="0"/> <xs:element ref="display" minOccurs="0" maxOccurs="1"/> <xs:element ref="rng_device" minOccurs="0" maxOccurs="1"/> + <xs:element ref="soundcard_enabled" minOccurs="0" maxOccurs="1"/> </xs:sequence> </xs:extension> </xs:complexContent> @@ -3777,6 +3780,8 @@ </xs:sequence> </xs:complexType> + <xs:element name="soundcard_enabled" type="xs:boolean"/> + <xs:element name="quota" type="Quota"/> <xs:complexType name="Quota"> diff --git a/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml b/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml index 3302742..d3b7246 100644 --- a/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml +++ b/backend/manager/modules/restapi/interface/definition/src/main/resources/rsdl_metadata.yaml @@ -96,6 +96,7 @@ vm.tunnel_migration: xs:boolean vm.migration_downtime: xs:int vm.virtio_scsi.enabled: xs:boolean + vm.soundcard_enabled: xs:boolean vm.use_latest_template_version: xs:boolean vm.payloads.payload--COLLECTION: {payload.type: 'xs:string', payload.volume_id: 'xs:string', payload.files.file--COLLECTION: {file.name: 'xs:string', file.content: 'xs:string'}} vm.cpu.cpu_tune.vcpu_pin--COLLECTION: {vcpu_pin.vcpu: 'xs:int', vcpu_pin.cpu_set: 'xs:string'} @@ -183,6 +184,7 @@ vm.tunnel_migration: xs:boolean vm.migration_downtime: xs:int vm.virtio_scsi.enabled: xs:boolean + vm.soundcard_enabled: xs:boolean vm.payloads.payload--COLLECTION: {payload.type: 'xs:string', payload.volume_id: 'xs:string', payload.files.file--COLLECTION: {file.name: 'xs:string', file.content: 'xs:string'}} vm.initialization.configuration.type: 'xs:string' vm.initialization.configuration.data: 'xs:string' @@ -241,6 +243,7 @@ vm.tunnel_migration: xs:boolean vm.migration_downtime: xs:int vm.virtio_scsi.enabled: xs:boolean + vm.soundcard_enabled: xs:boolean vm.payloads.payload--COLLECTION: {payload.type: 'xs:string', payload.volume_id: 'xs:string', payload.files.file--COLLECTION: {file.name: 'xs:string', file.content: 'xs:string'}} vm.cpu.cpu_tune.vcpu_pin--COLLECTION: {vcpu_pin.vcpu: 'xs:int', vcpu_pin.cpu_set: 'xs:string'} vm.serial_number.policy: xs:string @@ -3737,6 +3740,7 @@ template.tunnel_migration: xs:boolean template.migration_downtime: xs:int template.virtio_scsi.enabled: xs:boolean + template.soundcard_enabled: xs:boolean template.version.version_name: xs:string template.serial_number.policy: xs:string template.serial_number.value: xs:string @@ -3795,6 +3799,7 @@ template.tunnel_migration: xs:boolean template.migration_downtime: xs:int template.virtio_scsi.enabled: xs:boolean + template.soundcard_enabled: xs:boolean template.vm.disks.disk--COLLECTION: {disk.id: 'xs:string', storage_domains.storage_domain--COLLECTION: {storage_domain.id: 'xs:string'}} template.permissions.clone: xs:boolean template.version.version_name: xs:string @@ -4312,7 +4317,7 @@ - mandatoryArguments: {vmpool.cluster.id|name: 'xs:string', vmpool.template.id|name: 'xs:string', vmpool.name: 'xs:string'} optionalArguments: {vmpool.comment: 'xs:string', vmpool.size: 'xs:int', vmpool.max_user_vms: 'xs:int', vmpool.display.proxy: 'xs:string', - vmpool.description: 'xs:string'} + vmpool.description: 'xs:string', vmpool.soundcard_enabled: 'xs:boolean'} description: add a new vm pool to the system urlparams: {} headers: @@ -5171,6 +5176,7 @@ instance_type.usb.type: xs:string instance_type.migration_downtime: xs:int instance_type.virtio_scsi.enabled: xs:boolean + instance_type.soundcard_enabled: xs:boolean description: add a new instance type to the system urlparams: {} headers: diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendInstanceTypeResource.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendInstanceTypeResource.java index 08b9285..e2be1f4 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendInstanceTypeResource.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendInstanceTypeResource.java @@ -59,6 +59,7 @@ model.setVirtioScsi(new VirtIOSCSI()); } model.getVirtioScsi().setEnabled(!VmHelper.getInstance().getVirtioScsiControllersForEntity(entity.getId()).isEmpty()); + model.setSoundcardEnabled(!VmHelper.getInstance().getSoundDevicesForEntity(entity.getId()).isEmpty()); setRngDevice(model); return model; } @@ -109,6 +110,9 @@ updateParams.setUpdateRngDevice(true); updateParams.setRngDevice(RngDeviceMapper.map(incoming.getRngDevice(), null)); } + if(incoming.isSetSoundcardEnabled()) { + updateParams.setSoundDeviceEnabled(incoming.isSoundcardEnabled()); + } return getMapper(modelType, UpdateVmTemplateParameters.class).map(incoming, updateParams); } diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendInstanceTypesResource.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendInstanceTypesResource.java index 8afcdb0..693243b 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendInstanceTypesResource.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendInstanceTypesResource.java @@ -74,6 +74,10 @@ addInstanceTypeParameters.setVirtioScsiEnabled(instanceType.isSetVirtioScsi() && instanceType.getVirtioScsi().isSetEnabled() ? instanceType.getVirtioScsi().isEnabled() : null); + if(instanceType.isSetSoundcardEnabled()) { + addInstanceTypeParameters.setSoundDeviceEnabled(instanceType.isSoundcardEnabled()); + } + return performCreate(VdcActionType.AddVmTemplate, addInstanceTypeParameters, @@ -110,7 +114,7 @@ model.setVirtioScsi(new VirtIOSCSI()); } model.getVirtioScsi().setEnabled(!VmHelper.getInstance().getVirtioScsiControllersForEntity(entity.getId()).isEmpty()); - + model.setSoundcardEnabled(!VmHelper.getInstance().getSoundDevicesForEntity(entity.getId()).isEmpty()); List<VmRngDevice> rngDevices = getRngDevices(entity.getId()); if (rngDevices != null && !rngDevices.isEmpty()) { model.setRngDevice(RngDeviceMapper.map(rngDevices.get(0), null)); diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendTemplateResource.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendTemplateResource.java index b174f04..243e6be 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendTemplateResource.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendTemplateResource.java @@ -127,11 +127,13 @@ VmTemplate updated = getMapper(modelType, VmTemplate.class).map(incoming, entity); updated.setUsbPolicy(VmMapper.getUsbPolicyOnUpdate(incoming.getUsb(), entity.getUsbPolicy(), lookupCluster(updated.getVdsGroupId()).getcompatibility_version())); - UpdateVmTemplateParameters params = new UpdateVmTemplateParameters(updated); if (incoming.isSetRngDevice()) { params.setUpdateRngDevice(true); params.setRngDevice(RngDeviceMapper.map(incoming.getRngDevice(), null)); + } + if(incoming.isSetSoundcardEnabled()) { + params.setSoundDeviceEnabled(incoming.isSoundcardEnabled()); } return getMapper(modelType, UpdateVmTemplateParameters.class).map(incoming, params); } @@ -151,6 +153,7 @@ model.setVirtioScsi(new VirtIOSCSI()); } model.getVirtioScsi().setEnabled(!VmHelper.getInstance().getVirtioScsiControllersForEntity(entity.getId()).isEmpty()); + model.setSoundcardEnabled(!VmHelper.getInstance().getSoundDevicesForEntity(entity.getId()).isEmpty()); setRngDevice(model); return model; } diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendTemplatesResource.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendTemplatesResource.java index 337012b..473e3fa 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendTemplatesResource.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendTemplatesResource.java @@ -98,7 +98,11 @@ !getConsoleDevicesForEntity(staticVm.getId()).isEmpty()); params.setVirtioScsiEnabled(template.isSetVirtioScsi() && template.getVirtioScsi().isSetEnabled() ? template.getVirtioScsi().isEnabled() : null); - + if(template.isSetSoundcardEnabled()) { + params.setSoundDeviceEnabled(template.isSoundcardEnabled()); + } else { + params.setSoundDeviceEnabled(!VmHelper.getInstance().getSoundDevicesForEntity(staticVm.getId()).isEmpty()); + } if (template.isSetRngDevice()) { params.setUpdateRngDevice(true); params.setRngDevice(RngDeviceMapper.map(template.getRngDevice(), null)); @@ -221,6 +225,7 @@ model.setVirtioScsi(new VirtIOSCSI()); } model.getVirtioScsi().setEnabled(!VmHelper.getInstance().getVirtioScsiControllersForEntity(entity.getId()).isEmpty()); + model.setSoundcardEnabled(!VmHelper.getInstance().getSoundDevicesForEntity(entity.getId()).isEmpty()); List<VmRngDevice> rngDevices = getRngDevices(entity.getId()); if (rngDevices != null && !rngDevices.isEmpty()) { model.setRngDevice(RngDeviceMapper.map(rngDevices.get(0), null)); diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmPoolsResource.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmPoolsResource.java index b9f84fa..d681ca7 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmPoolsResource.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmPoolsResource.java @@ -73,6 +73,7 @@ AddVmPoolWithVmsParameters params = new AddVmPoolWithVmsParameters(entity, vm, size, -1); params.setConsoleEnabled(!getConsoleDevicesForEntity(template.getId()).isEmpty()); params.setVirtioScsiEnabled(!VmHelper.getInstance().getVirtioScsiControllersForEntity(template.getId()).isEmpty()); + params.setSoundDeviceEnabled((pool.isSetSoundcardEnabled() ? pool.isSoundcardEnabled() : !VmHelper.getInstance().getSoundDevicesForEntity(template.getId()).isEmpty())); return performCreate(VdcActionType.AddVmPoolWithVms, params, diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmResource.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmResource.java index fd4bfa6..582bd33 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmResource.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmResource.java @@ -473,6 +473,7 @@ protected VM doPopulate(VM model, org.ovirt.engine.core.common.businessentities.VM entity) { parent.setConsoleDevice(model); parent.setVirtioScsiController(model); + parent.setSoundcard(model); parent.setVmOvfConfiguration(model, entity); parent.setRngDevice(model); return model; @@ -533,6 +534,9 @@ if (incoming.isSetVirtioScsi()) { params.setVirtioScsiEnabled(incoming.getVirtioScsi().isEnabled()); } + if (incoming.isSetSoundcardEnabled()) { + params.setSoundDeviceEnabled(incoming.isSoundcardEnabled()); + } if (incoming.isSetRngDevice()) { params.setUpdateRngDevice(true); params.setRngDevice(RngDeviceMapper.map(incoming.getRngDevice(), null)); diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmsResource.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmsResource.java index d37afe2..45625e4 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmsResource.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/resource/BackendVmsResource.java @@ -49,6 +49,8 @@ import org.ovirt.engine.core.common.businessentities.Entities; import org.ovirt.engine.core.common.businessentities.VDSGroup; import org.ovirt.engine.core.common.businessentities.VdsStatic; +import org.ovirt.engine.core.common.businessentities.VmDevice; +import org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType; import org.ovirt.engine.core.common.businessentities.VmInit; import org.ovirt.engine.core.common.businessentities.VmPayload; import org.ovirt.engine.core.common.businessentities.VmRngDevice; @@ -182,7 +184,7 @@ if (vm.isSetDisks()) { prepareImagesForCloneFromSnapshotParams(vm.getDisks(), diskImagesByImageId); } - return cloneVmFromSnapshot(vmConfiguration.getStaticData(), + return cloneVmFromSnapshot(vmConfiguration, vm, snapshotId, diskImagesByImageId); @@ -276,10 +278,11 @@ "Hosts: name=" + hostName).getId().toString(); } - private Response cloneVmFromSnapshot(VmStatic staticVm, + private Response cloneVmFromSnapshot(org.ovirt.engine.core.common.businessentities.VM configVm, VM vm, String snapshotId, HashMap<Guid, DiskImage> images) { + VmStatic staticVm = configVm.getStaticData(); Guid sourceSnapshotId = asGuid(snapshotId); AddVmFromSnapshotParameters params = new AddVmFromSnapshotParameters(staticVm, sourceSnapshotId); @@ -287,6 +290,11 @@ params.setMakeCreatorExplicitOwner(shouldMakeCreatorExplicitOwner()); params.setVirtioScsiEnabled(vm.isSetVirtioScsi() && vm.getVirtioScsi().isSetEnabled() ? vm.getVirtioScsi().isEnabled() : null); + if(vm.isSetSoundcardEnabled()) { + params.setSoundDeviceEnabled(vm.isSoundcardEnabled()); + } else { + params.setSoundDeviceEnabled(isVMDeviceTypeExist(configVm.getManagedVmDeviceMap(), VmDeviceGeneralType.SOUND)); + } params.setConsoleEnabled(vm.isSetConsole() && vm.getConsole().isSetEnabled() ? vm.getConsole().isEnabled() @@ -307,6 +315,12 @@ params.setVmPayload(getPayload(vm)); params.setVirtioScsiEnabled(vm.isSetVirtioScsi() && vm.getVirtioScsi().isSetEnabled() ? vm.getVirtioScsi().isEnabled() : null); + if(vm.isSetSoundcardEnabled()) { + params.setSoundDeviceEnabled(vm.isSoundcardEnabled()); + } else { + params.setSoundDeviceEnabled(!VmHelper.getInstance().getSoundDevicesForEntity(templateId).isEmpty()); + } + params.setBalloonEnabled(vm.isSetMemoryPolicy() && vm.getMemoryPolicy().isSetBallooning() ? vm.getMemoryPolicy().isBallooning() : null); @@ -376,6 +390,11 @@ params.setVirtioScsiEnabled(vm.isSetVirtioScsi() && vm.getVirtioScsi().isSetEnabled() ? vm.getVirtioScsi().isEnabled() : null); + if(vm.isSetSoundcardEnabled()) { + params.setSoundDeviceEnabled(vm.isSoundcardEnabled()); + } else { + params.setSoundDeviceEnabled(!VmHelper.getInstance().getSoundDevicesForEntity(templateId).isEmpty()); + } if (vm.isSetRngDevice()) { params.setUpdateRngDevice(true); @@ -403,6 +422,9 @@ params.setStorageDomainId(storageDomainId); params.setVirtioScsiEnabled(vm.isSetVirtioScsi() && vm.getVirtioScsi().isSetEnabled() ? vm.getVirtioScsi().isEnabled() : null); + if(vm.isSetSoundcardEnabled()) { + params.setSoundDeviceEnabled(vm.isSoundcardEnabled()); + } if (vm.isSetConsole() && vm.getConsole().isSetEnabled()) { params.setConsoleEnabled(vm.getConsole().isEnabled()); @@ -621,6 +643,10 @@ model.getVirtioScsi().setEnabled(!VmHelper.getInstance().getVirtioScsiControllersForEntity(new Guid(model.getId())).isEmpty()); } + protected void setSoundcard(VM model) { + model.setSoundcardEnabled(!VmHelper.getInstance().getSoundDevicesForEntity(new Guid(model.getId())).isEmpty()); + } + public void setCertificateInfo(VM model) { VdcQueryReturnValue result = runQuery(VdcQueryType.GetVdsCertificateSubjectByVmId, @@ -651,6 +677,7 @@ setBallooning(model); setConsoleDevice(model); setVirtioScsiController(model); + setSoundcard(model); setCertificateInfo(model); setVmOvfConfiguration(model, entity); setRngDevice(model); @@ -675,4 +702,15 @@ "GetConsoleDevices", true); } + private boolean isVMDeviceTypeExist(Map<Guid, VmDevice> deviceMap, VmDeviceGeneralType deviceType) { + if(deviceMap != null) { + for (Map.Entry<Guid, VmDevice> device : deviceMap.entrySet()) { + if (device.getValue().getType().equals(deviceType)) { + return true; + } + } + } + return false; + } + } diff --git a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/util/VmHelper.java b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/util/VmHelper.java index 33d7901..1f3242a 100644 --- a/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/util/VmHelper.java +++ b/backend/manager/modules/restapi/jaxrs/src/main/java/org/ovirt/engine/api/restapi/util/VmHelper.java @@ -24,4 +24,11 @@ new IdQueryParameters(id), "GetVirtioScsiControllers", true); } + + public List<String> getSoundDevicesForEntity(Guid id) { + return getEntity(List.class, + VdcQueryType.GetSoundDevices, + new IdQueryParameters(id), + "GetSoundDevices", true); + } } diff --git a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendTemplateBasedResourceTest.java b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendTemplateBasedResourceTest.java index 6f641a1..8b35a00 100644 --- a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendTemplateBasedResourceTest.java +++ b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendTemplateBasedResourceTest.java @@ -100,6 +100,7 @@ expect(httpHeaders.getRequestHeader(BackendResource.POPULATE)).andReturn(populates).anyTimes(); setUpGetConsoleExpectations(new int[]{0}); setUpGetVirtioScsiExpectations(new int[]{0}); + setUpGetSoundcardExpectations(new int[]{0}); setUpGetRngDeviceExpectations(new int [] {0}); } control.replay(); @@ -115,6 +116,16 @@ protected void setUpGetVirtioScsiExpectations(int ... idxs) throws Exception { for (int i = 0; i < idxs.length; i++) { setUpGetEntityExpectations(VdcQueryType.GetVirtioScsiControllers, + IdQueryParameters.class, + new String[] { "Id" }, + new Object[] { GUIDS[idxs[i]] }, + new ArrayList<>()); + } + } + + protected void setUpGetSoundcardExpectations(int ... idxs) throws Exception { + for (int i = 0; i < idxs.length; i++) { + setUpGetEntityExpectations(VdcQueryType.GetSoundDevices, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[idxs[i]] }, @@ -140,6 +151,7 @@ setUpGetEntityExpectations(2); setUpGetConsoleExpectations(new int[]{0}); setUpGetVirtioScsiExpectations(new int[]{0}); + setUpGetSoundcardExpectations(new int[]{0}); setUpGetRngDeviceExpectations(new int[]{0}); setUriInfo(setUpActionExpectations(VdcActionType.UpdateVmTemplate, diff --git a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendTemplatesBasedResourceTest.java b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendTemplatesBasedResourceTest.java index 2388f51..c547be6 100644 --- a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendTemplatesBasedResourceTest.java +++ b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendTemplatesBasedResourceTest.java @@ -98,6 +98,7 @@ setUpHttpHeaderExpectations("Expect", "201-created"); setUpGetVirtioScsiExpectations(new int[]{0, 0}); + setUpGetSoundcardExpectations(new int[]{0, 0}); setUpGetRngDeviceExpectations(new int[]{0, 0}); setUpGetEntityExpectations(0); @@ -165,6 +166,7 @@ expect(httpHeaders.getRequestHeader(BackendResource.POPULATE)).andReturn(populates).anyTimes(); setUpGetConsoleExpectations(new int[]{0, 1, 2}); setUpGetVirtioScsiExpectations(new int[] {0, 1, 2}); + setUpGetSoundcardExpectations(new int[] {0, 1, 2}); setUpGetRngDeviceExpectations(new int[] {0, 1, 2}); } @@ -195,6 +197,16 @@ } } + protected void setUpGetSoundcardExpectations(int ... idxs) throws Exception { + for (int i = 0; i < idxs.length; i++) { + setUpGetEntityExpectations(VdcQueryType.GetSoundDevices, + IdQueryParameters.class, + new String[] { "Id" }, + new Object[] { GUIDS[idxs[i]] }, + new ArrayList<>()); + } + } + protected void setUpGetEntityExpectations(int index) throws Exception { setUpGetEntityExpectations(VdcQueryType.GetVmTemplate, GetVmTemplateParameters.class, diff --git a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendTemplatesResourceTest.java b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendTemplatesResourceTest.java index 09a581d..9b2ff1b 100644 --- a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendTemplatesResourceTest.java +++ b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendTemplatesResourceTest.java @@ -68,6 +68,7 @@ setUpGetEntityExpectations(0); setUpGetConsoleExpectations(new int[]{0, 0, 0}); setUpGetVirtioScsiExpectations(new int[]{0, 0}); + setUpGetSoundcardExpectations(new int[]{0, 0, 0}); setUpGetRngDeviceExpectations(new int[]{0, 0}); setUpEntityQueryExpectations(VdcQueryType.GetVdsGroupByVdsGroupId, IdQueryParameters.class, @@ -127,6 +128,7 @@ setUpGetConsoleExpectations(new int[]{0, 0}); setUpGetVirtioScsiExpectations(new int[]{0}); + setUpGetSoundcardExpectations(new int[]{0, 0}); setUpGetRngDeviceExpectations(new int[]{0}); setUpGetEntityExpectations(VdcQueryType.GetVmByVmId, IdQueryParameters.class, @@ -160,6 +162,7 @@ public void testAdd() throws Exception { setUpGetConsoleExpectations(new int[]{0, 0, 0}); + setUpGetSoundcardExpectations(new int[]{0}); setUpGetEntityExpectations(VdcQueryType.GetVmByVmId, IdQueryParameters.class, @@ -209,6 +212,7 @@ setUpGetConsoleExpectations(new int[]{2, 0, 2}); setUpGetVirtioScsiExpectations(new int[]{2, 2}); + setUpGetSoundcardExpectations(new int[]{2, 2, 0}); setUpGetRngDeviceExpectations(new int[]{2, 2}); setUpGetEntityExpectations(VdcQueryType.GetVmByVmId, IdQueryParameters.class, @@ -265,6 +269,7 @@ setUpGetEntityExpectations(0); setUpGetConsoleExpectations(new int[] {0, 0, 0}); setUpGetVirtioScsiExpectations(new int[] {0, 0}); + setUpGetSoundcardExpectations(new int[] {0, 0, 0}); setUpGetRngDeviceExpectations(new int[]{0, 0}); setUpCreationExpectations(VdcActionType.AddVmTemplate, @@ -314,6 +319,7 @@ setUpGetEntityExpectations(0); setUpGetConsoleExpectations(new int[] {0, 0, 0}); setUpGetVirtioScsiExpectations(new int[] {0, 0}); + setUpGetSoundcardExpectations(new int[] {0, 0, 0}); setUpGetRngDeviceExpectations(new int[] {0, 0}); setUpCreationExpectations(VdcActionType.AddVmTemplate, @@ -361,6 +367,7 @@ setUpGetConsoleExpectations(new int[] {0, 0, 0}); setUpGetVirtioScsiExpectations(new int[] {0, 0}); + setUpGetSoundcardExpectations(new int[] {0, 0, 0}); setUpGetRngDeviceExpectations(new int[]{0, 0}); setUpCreationExpectations(VdcActionType.AddVmTemplate, @@ -408,6 +415,7 @@ setUpGetConsoleExpectations(new int[] {0, 0, 0}); setUpGetVirtioScsiExpectations(new int[] {0, 0}); + setUpGetSoundcardExpectations(new int[] {0, 0, 0}); setUpGetRngDeviceExpectations(new int[]{0, 0}); setUpGetEntityExpectations(VdcQueryType.GetVdsGroupByName, @@ -473,6 +481,7 @@ setUpVm(GUIDS[1])); setUpGetConsoleExpectations(new int[] {0}); + setUpGetSoundcardExpectations(new int[] {0}); super.doTestBadAdd(canDo, success, detail); } diff --git a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendVmPoolsResourceTest.java b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendVmPoolsResourceTest.java index e88770d..e7235bd 100644 --- a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendVmPoolsResourceTest.java +++ b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendVmPoolsResourceTest.java @@ -98,6 +98,12 @@ new Object[] { GUIDS[1] }, new ArrayList<>()); + setUpGetEntityExpectations(VdcQueryType.GetSoundDevices, + IdQueryParameters.class, + new String[] { "Id" }, + new Object[] { GUIDS[1] }, + new ArrayList<>()); + setUpGetRngDeviceExpectations(new int[] {0}); setUpCreationExpectations(VdcActionType.AddVmPoolWithVms, @@ -138,6 +144,12 @@ new Object[] { GUIDS[1] }, new ArrayList<>()); + setUpGetEntityExpectations(VdcQueryType.GetSoundDevices, + IdQueryParameters.class, + new String[] { "Id" }, + new Object[] { GUIDS[1] }, + new ArrayList<>()); + setUpCreationExpectations(VdcActionType.AddVmPoolWithVms, VmPoolParametersBase.class, new String[] { "StorageDomainId" }, diff --git a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendVmResourceTest.java b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendVmResourceTest.java index b3a28b5..dac0da7 100644 --- a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendVmResourceTest.java +++ b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendVmResourceTest.java @@ -192,6 +192,7 @@ expect(httpHeaders.getRequestHeader(BackendResource.POPULATE)).andReturn(populates).anyTimes(); setUpGetConsoleExpectations(new int[]{0}); setUpGetVirtioScsiExpectations(new int[]{0}); + setUpGetSoundcardExpectations(new int[]{0}); setUpGetRngDeviceExpectations(new int[]{0}); setUpGetVmOvfExpectations(new int[]{0}); } @@ -237,6 +238,7 @@ setUpGetConsoleExpectations(new int[]{0}); setUpGetVmOvfExpectations(new int[]{0}); setUpGetVirtioScsiExpectations(new int[] {0}); + setUpGetSoundcardExpectations(new int[] {0}); setUpGetRngDeviceExpectations(new int[]{0}); setUriInfo(setUpActionExpectations(VdcActionType.UpdateVm, VmManagementParametersBase.class, @@ -265,6 +267,7 @@ setUpGetConsoleExpectations(new int[]{0}); setUpGetVmOvfExpectations(new int[]{0}); setUpGetVirtioScsiExpectations(new int[] {0}); + setUpGetSoundcardExpectations(new int[] {0}); setUpGetRngDeviceExpectations(new int[]{0}); setUriInfo(setUpActionExpectations(VdcActionType.UpdateVm, @@ -308,6 +311,7 @@ setUpGetConsoleExpectations(new int[]{0}); setUpGetVmOvfExpectations(new int[]{0}); setUpGetVirtioScsiExpectations(new int[] {0}); + setUpGetSoundcardExpectations(new int[] {0}); setUpGetRngDeviceExpectations(new int[]{0}); setUpEntityQueryExpectations(VdcQueryType.GetVdsStaticByName, NameQueryParameters.class, @@ -350,6 +354,8 @@ setUpGetVmOvfExpectations(new int[]{0}); setUpGetVirtioScsiExpectations(new int[] {0}); setUpGetRngDeviceExpectations(new int[]{0}); + setUpGetSoundcardExpectations(new int[]{0}); + setUriInfo(setUpActionExpectations(VdcActionType.ChangeVMCluster, ChangeVMClusterParameters.class, new String[] {"ClusterId", "VmId"}, @@ -1117,6 +1123,16 @@ } } + private void setUpGetSoundcardExpectations(int ... idxs) throws Exception { + for (int i = 0; i < idxs.length; i++) { + setUpGetEntityExpectations(VdcQueryType.GetSoundDevices, + IdQueryParameters.class, + new String[] { "Id" }, + new Object[] { GUIDS[idxs[i]] }, + new ArrayList<>()); + } + } + private void setUpGetVmOvfExpectations(int ... idxs) throws Exception { for (int i = 0; i < idxs.length; i++) { setUpGetEntityExpectations(VdcQueryType.GetVmOvfByVmId, diff --git a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendVmsResourceTest.java b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendVmsResourceTest.java index cc1f692..dd9e1a5 100644 --- a/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendVmsResourceTest.java +++ b/backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendVmsResourceTest.java @@ -241,6 +241,7 @@ setUpGetBallooningExpectations(1, 0); setUpGetConsoleExpectations(new int[]{0}); setUpGetVirtioScsiExpectations(new int[]{0}); + setUpGetSoundcardExpectations(new int[]{0}); setUpGetRngDeviceExpectations(new int[]{0}); setUpGetVmOvfExpectations(new int[]{0}); setUpGetCertuficateExpectations(1, 0); @@ -292,6 +293,7 @@ setUpGetConsoleExpectations(new int[]{0, 0}); setUpGetVmOvfExpectations(new int[]{0, 0}); setUpGetVirtioScsiExpectations(new int[]{0, 0}); + setUpGetSoundcardExpectations(new int[]{0, 0}); setUpGetRngDeviceExpectations(new int[]{0, 0}); setUpGetBallooningExpectations(2, 0); setUpGetCertuficateExpectations(2, 0); @@ -350,6 +352,7 @@ setUpGetConsoleExpectations(new int[]{0, 0}); setUpGetVmOvfExpectations(new int[]{0, 0}); setUpGetVirtioScsiExpectations(new int[]{0, 0}); + setUpGetSoundcardExpectations(new int[]{0, 0}); setUpGetRngDeviceExpectations(new int[]{0, 0}); setUpGetCertuficateExpectations(2, 0); setUpEntityQueryExpectations(VdcQueryType.GetVmByVmId, @@ -403,6 +406,7 @@ setUpGetConsoleExpectations(new int[]{0, 0}); setUpGetVmOvfExpectations(new int[]{0, 0}); setUpGetVirtioScsiExpectations(new int[]{0, 0}); + setUpGetSoundcardExpectations(new int[]{0, 0}); setUpGetRngDeviceExpectations(new int[]{0, 0}); setUpGetCertuficateExpectations(2, 0); setUpHttpHeaderExpectations("Expect", "201-created"); @@ -506,6 +510,7 @@ setUpGetConsoleExpectations(new int[]{1, 2}); setUpGetVmOvfExpectations(new int[]{2}); setUpGetVirtioScsiExpectations(new int[]{2}); + setUpGetSoundcardExpectations(new int[]{2, 1}); setUpGetRngDeviceExpectations(new int[]{2}); setUpGetCertuficateExpectations(1, 2); setUpEntityQueryExpectations(VdcQueryType.GetVmTemplate, @@ -557,6 +562,7 @@ setUpGetVmOvfExpectations(new int[]{2}); setUpGetVirtioScsiExpectations(new int[]{2}); setUpGetRngDeviceExpectations(new int[]{2}); + setUpGetSoundcardExpectations(new int[]{2}); setUpEntityQueryExpectations(VdcQueryType.GetVmConfigurationBySnapshot, IdQueryParameters.class, new String[] { "Id" }, @@ -593,6 +599,7 @@ setUpGetVmOvfExpectations(new int[]{2}); setUpGetVirtioScsiExpectations(new int[]{2}); setUpGetRngDeviceExpectations(new int[]{2}); + setUpGetSoundcardExpectations(new int[]{2, 1}); setUpGetCertuficateExpectations(1, 2); setUpEntityQueryExpectations(VdcQueryType.GetVmTemplate, GetVmTemplateParameters.class, @@ -632,6 +639,7 @@ setUpGetConsoleExpectations(new int[]{1, 2}); setUpGetVmOvfExpectations(new int[]{2}); setUpGetVirtioScsiExpectations(new int[]{2}); + setUpGetSoundcardExpectations(new int[]{2, 1}); setUpGetRngDeviceExpectations(new int[]{2}); setUpEntityQueryExpectations(VdcQueryType.GetVmTemplate, GetVmTemplateParameters.class, @@ -679,6 +687,7 @@ setUpGetCertuficateExpectations(1, 2); setUpGetConsoleExpectations(new int[] { 1, 2 }); setUpGetVirtioScsiExpectations(new int[] { 2 }); + setUpGetSoundcardExpectations(new int[] { 2, 1 }); setUpGetRngDeviceExpectations(new int[]{2}); setUpGetVmOvfExpectations(new int[] { 2 }); setUpEntityQueryExpectations(VdcQueryType.GetVmTemplate, @@ -718,6 +727,7 @@ setUpGetConsoleExpectations(new int[] { 3 }); setUpGetVmOvfExpectations(new int[] { 3 }); setUpGetVirtioScsiExpectations(new int[] { 3 }); + setUpGetSoundcardExpectations(new int[] { 3 }); setUpGetRngDeviceExpectations(new int[]{3}); VM model = createModel(null); org.ovirt.engine.core.common.businessentities.VM returnedVM = getEntity(2); @@ -762,6 +772,7 @@ setUpGetConsoleExpectations(new int[]{2}); setUpGetVmOvfExpectations(new int[]{2}); setUpGetVirtioScsiExpectations(new int[]{2}); + setUpGetSoundcardExpectations(new int[]{2}); setUpGetRngDeviceExpectations(new int[]{2}); VM model = createModel(null); org.ovirt.engine.core.common.businessentities.VM returnedVM = getEntity(2); @@ -801,6 +812,7 @@ setUpGetConsoleExpectations(new int[]{2}); setUpGetVmOvfExpectations(new int[]{2}); setUpGetVirtioScsiExpectations(new int[]{2}); + setUpGetSoundcardExpectations(new int[]{2}); setUpGetRngDeviceExpectations(new int[]{2}); VM model = createModel(null); org.ovirt.engine.core.common.businessentities.VM returnedVM = getEntity(2); @@ -899,6 +911,7 @@ setUpGetConsoleExpectations(new int[]{1, 2}); setUpGetVmOvfExpectations(new int[]{2}); setUpGetVirtioScsiExpectations(new int[]{2}); + setUpGetSoundcardExpectations(new int[]{2, 1}); setUpGetRngDeviceExpectations(new int[]{2}); setUpGetCertuficateExpectations(1, 2); setUpEntityQueryExpectations(VdcQueryType.GetVdsStaticByName, @@ -954,6 +967,7 @@ setUpGetConsoleExpectations(new int[]{1, 2}); setUpGetVmOvfExpectations(new int[]{2}); setUpGetVirtioScsiExpectations(new int[]{2}); + setUpGetSoundcardExpectations(new int[]{2, 1}); setUpGetRngDeviceExpectations(new int[]{2}); setUpGetCertuficateExpectations(1, 2); setUpEntityQueryExpectations(VdcQueryType.GetVmTemplate, @@ -996,6 +1010,7 @@ setUpGetConsoleExpectations(new int[]{1, 2}); setUpGetVmOvfExpectations(new int[]{2}); setUpGetVirtioScsiExpectations(new int[]{2}); + setUpGetSoundcardExpectations(new int[]{2, 1}); setUpGetRngDeviceExpectations(new int[]{2}); setUpGetCertuficateExpectations(1, 2); setUpEntityQueryExpectations(VdcQueryType.GetVmTemplate, @@ -1061,6 +1076,7 @@ setUpGetConsoleExpectations(new int[]{1, 2}); setUpGetVmOvfExpectations(new int[]{2}); setUpGetVirtioScsiExpectations(new int[]{2}); + setUpGetSoundcardExpectations(new int[]{2, 1}); setUpGetRngDeviceExpectations(new int[]{2}); setUpEntityQueryExpectations(VdcQueryType.GetVmTemplate, GetVmTemplateParameters.class, @@ -1114,6 +1130,7 @@ setUpGetConsoleExpectations(new int[]{1, 2}); setUpGetVmOvfExpectations(new int[]{2}); setUpGetVirtioScsiExpectations(new int[]{2}); + setUpGetSoundcardExpectations(new int[]{2, 1}); setUpGetRngDeviceExpectations(new int[]{2}); setUpEntityQueryExpectations(VdcQueryType.GetVmTemplate, GetVmTemplateParameters.class, @@ -1186,6 +1203,7 @@ setUpGetConsoleExpectations(new int[]{0, 1, 2}); setUpGetVmOvfExpectations(new int[]{0, 1, 2}); setUpGetVirtioScsiExpectations(new int[]{0, 1, 2}); + setUpGetSoundcardExpectations(new int[]{0, 1, 2}); setUpGetRngDeviceExpectations(new int[]{0, 1, 2}); setUpGetCertuficateExpectations(3); } @@ -1206,6 +1224,7 @@ setUpGetConsoleExpectations(new int[]{0, 1, 2}); setUpGetVmOvfExpectations(new int[]{0, 1, 2}); setUpGetVirtioScsiExpectations(new int[]{0, 1, 2}); + setUpGetSoundcardExpectations(new int[]{0, 1, 2}); setUpGetRngDeviceExpectations(new int[]{0, 1, 2}); setUpGetCertuficateExpectations(3); setUpQueryExpectations(""); @@ -1258,6 +1277,7 @@ new Object[] { GUIDS[1] }, getTemplateEntity(0)); setUpGetConsoleExpectations(new int[]{1}); + setUpGetSoundcardExpectations(new int[]{1}); setUpEntityQueryExpectations(VdcQueryType.GetVdsGroupByVdsGroupId, IdQueryParameters.class, new String[] { "Id" }, @@ -1568,6 +1588,16 @@ } } + private void setUpGetSoundcardExpectations(int ... idxs) throws Exception { + for (int i = 0; i < idxs.length; i++) { + setUpGetEntityExpectations(VdcQueryType.GetSoundDevices, + IdQueryParameters.class, + new String[] { "Id" }, + new Object[] { GUIDS[idxs[i]] }, + new ArrayList<>()); + } + } + private void setUpGetVmOvfExpectations(int ... idxs) throws Exception { for (int i = 0; i < idxs.length; i++) { setUpGetEntityExpectations(VdcQueryType.GetVmOvfByVmId, -- To view, visit http://gerrit.ovirt.org/32255 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I598cf89b6a5fd4755958cf7b597484c225166460 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.5 Gerrit-Owner: Eldan Shachar <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
