Frank Kobzik has uploaded a new change for review. Change subject: engine: (Cleanup) Remove unused graphics attributes ......................................................................
engine: (Cleanup) Remove unused graphics attributes Removes these attributes (and their persistence) - VmDynamic.display, - VmDynamic.displaySecurePort, - VmDynamic.displayIp, - VmDynamic.displayType as they are replaced with GraphicsInfo. todo - remove atts from vm static too (represented by vm devices) Change-Id: Id4fbd37b2b41b7288f78b60f27427c7b666d83d4 Bug-Url: https://bugzilla.redhat.com/?????? Signed-off-by: Frantisek Kobzik <[email protected]> --- M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDynamic.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDynamicDAODbFacadeImpl.java M backend/manager/modules/restapi/jaxrs/src/test/java/org/ovirt/engine/api/restapi/resource/BackendVmsResourceTest.java M backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java M backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/VmMapperTest.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Cloner.java M packaging/dbscripts/create_views.sql A packaging/dbscripts/upgrade/03_06_0080_remove_deprecated_display_columns.sql M packaging/dbscripts/vms_sp.sql 10 files changed, 49 insertions(+), 88 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/00/31200/1 diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java index bef435c..276ef43 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VM.java @@ -588,28 +588,12 @@ this.vmDynamic.setAppList(value); } - public Integer getDisplay() { - return this.vmDynamic.getDisplay(); - } - - public void setDisplay(Integer value) { - this.vmDynamic.setDisplay(value); - } - public Boolean getAcpiEnable() { return this.vmDynamic.getAcpiEnable(); } public void setAcpiEnable(Boolean value) { this.vmDynamic.setAcpiEnable(value); - } - - public String getDisplayIp() { - return this.vmDynamic.getDisplayIp(); - } - - public void setDisplayIp(String value) { - this.vmDynamic.setDisplayIp(value); } public DisplayType getDisplayType() { @@ -642,14 +626,6 @@ public void setBootSequence(BootSequence value) { this.vmDynamic.setBootSequence(value); - } - - public Integer getDisplaySecurePort() { - return this.vmDynamic.getDisplaySecurePort(); - } - - public void setDisplaySecurePort(Integer value) { - this.vmDynamic.setDisplaySecurePort(value); } public VmExitStatus getExitStatus() { @@ -1257,8 +1233,6 @@ setStatus(vm.getStatus()); setRunOnVds(vdsId); setRunOnVdsName(vdsName); - setDisplay(vm.getDisplay()); - setDisplaySecurePort(vm.getDisplaySecurePort()); setVmHost(vm.getVmHost()); setVmIp(vm.getVmIp()); setVmFQDN(vm.getVmFQDN()); @@ -1274,7 +1248,6 @@ setGuestOs(vm.getGuestOs()); setDisplayType(vm.getDisplayType()); getDynamicData().setVncKeyboardLayout(vm.getVncKeyboardLayout()); - setDisplayIp(vm.getDisplayIp()); setKvmEnable(vm.getKvmEnable()); setAcpiEnable(vm.getAcpiEnable()); setGuestCurrentUserName(vm.getGuestCurrentUserName()); diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDynamic.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDynamic.java index 8a68708..0d029e7 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDynamic.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmDynamic.java @@ -36,14 +36,12 @@ @UnchangeableByVdsm private Guid runOnVds; private String appList; - private Integer display; private Boolean acpiEnabled; private SessionState session; private String displayIp; private DisplayType displayType; private String vncKeyboardLayout; private Boolean kvmEnable; - private Integer displaySecurePort; private Integer utcDiff; @UnchangeableByVdsm private Guid lastVdsRunOn; @@ -90,9 +88,6 @@ result = prime * result + ((appList == null) ? 0 : appList.hashCode()); result = prime * result + bootSequence.hashCode(); result = prime * result + ((clientIp == null) ? 0 : clientIp.hashCode()); - result = prime * result + ((display == null) ? 0 : display.hashCode()); - result = prime * result + ((displayIp == null) ? 0 : displayIp.hashCode()); - result = prime * result + ((displaySecurePort == null) ? 0 : displaySecurePort.hashCode()); result = prime * result + displayType.hashCode(); result = prime * result + ((vncKeyboardLayout == null) ? 0 : vncKeyboardLayout.hashCode()); result = prime * result + ((consoleCurrentUserName == null) ? 0 : consoleCurrentUserName.hashCode()); @@ -148,9 +143,6 @@ && ObjectUtils.objectsEqual(appList, other.appList) && bootSequence == other.bootSequence && ObjectUtils.objectsEqual(clientIp, other.clientIp) - && ObjectUtils.objectsEqual(display, other.display) - && ObjectUtils.objectsEqual(displayIp, other.displayIp) - && ObjectUtils.objectsEqual(displaySecurePort, other.displaySecurePort) && displayType == other.displayType && ObjectUtils.objectsEqual(vncKeyboardLayout, other.vncKeyboardLayout) && ObjectUtils.objectsEqual(consoleCurrentUserName, other.consoleCurrentUserName) @@ -393,14 +385,6 @@ this.vmPid = value; } - public Integer getDisplay() { - return this.display; - } - - public void setDisplay(Integer value) { - this.display = value; - } - public Map<GraphicsType, GraphicsInfo> getGraphicsInfos() { // todo rename this awful thing! lol return graphicsInfos; } @@ -411,10 +395,6 @@ public void setAcpiEnable(Boolean value) { this.acpiEnabled = value; - } - - public String getDisplayIp() { - return this.displayIp; } public void setDisplayIp(String value) { @@ -459,14 +439,6 @@ public void setBootSequence(BootSequence value) { this.bootSequence = value; - } - - public Integer getDisplaySecurePort() { - return this.displaySecurePort; - } - - public void setDisplaySecurePort(Integer value) { - this.displaySecurePort = value; } public Integer getUtcDiff() { diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDynamicDAODbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDynamicDAODbFacadeImpl.java index fd33456..7b727e1 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDynamicDAODbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmDynamicDAODbFacadeImpl.java @@ -99,14 +99,11 @@ .addValue("last_start_time", vm.getLastStartTime()) .addValue("last_stop_time", vm.getLastStopTime()) .addValue("vm_pid", vm.getVmPid()) - .addValue("display", vm.getDisplay()) .addValue("acpi_enable", vm.getAcpiEnable()) .addValue("session", vm.getSession()) - .addValue("display_ip", vm.getDisplayIp()) .addValue("display_type", vm.getDisplayType()) .addValue("kvm_enable", vm.getKvmEnable()) .addValue("boot_sequence", vm.getBootSequence()) - .addValue("display_secure_port", vm.getDisplaySecurePort()) .addValue("utc_diff", vm.getUtcDiff()) .addValue("last_vds_run_on", vm.getLastVdsRunOn()) .addValue("client_ip", vm.getClientIp()) @@ -161,14 +158,11 @@ entity.setLastStartTime(DbFacadeUtils.fromDate(rs.getTimestamp("last_start_time"))); entity.setLastStopTime(DbFacadeUtils.fromDate(rs.getTimestamp("last_stop_time"))); entity.setVmPid((Integer) rs.getObject("vm_pid")); - entity.setDisplay((Integer) rs.getObject("display")); entity.setAcpiEnable((Boolean) rs.getObject("acpi_enable")); entity.setSession(SessionState.forValue(rs.getInt("session"))); - entity.setDisplayIp(rs.getString("display_ip")); entity.setDisplayType(DisplayType.forValue(rs.getInt("display_type"))); entity.setKvmEnable((Boolean) rs.getObject("kvm_enable")); entity.setBootSequence(BootSequence.forValue(rs.getInt("boot_sequence"))); - entity.setDisplaySecurePort((Integer) rs.getObject("display_secure_port")); entity.setUtcDiff((Integer) rs.getObject("utc_diff")); entity.setLastVdsRunOn(getGuid(rs, "last_vds_run_on")); entity.setClientIp(rs.getString("client_ip")); 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 034e509..398fa75 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 @@ -1336,7 +1336,6 @@ expect(entity.getNumOfSockets()).andReturn(2).anyTimes(); expect(entity.getUsageMemPercent()).andReturn(Integer.valueOf(20)).anyTimes(); expect(entity.getDisplayType()).andReturn(DisplayType.vga).anyTimes(); - expect(entity.getDisplaySecurePort()).andReturn(5900).anyTimes(); expect(entity.getNumOfMonitors()).andReturn(2).anyTimes(); expect(entity.getVmType()).andReturn(VmType.Server).anyTimes(); expect(entity.getRunOnVdsName()).andReturn(NAMES[NAMES.length -1]).anyTimes(); diff --git a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java index a08db60..b972fa1 100644 --- a/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java +++ b/backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java @@ -66,6 +66,8 @@ import org.ovirt.engine.api.restapi.utils.UsbMapperUtils; import org.ovirt.engine.core.common.action.RunVmOnceParams; import org.ovirt.engine.core.common.businessentities.BootSequence; +import org.ovirt.engine.core.common.businessentities.GraphicsInfo; +import org.ovirt.engine.core.common.businessentities.GraphicsType; import org.ovirt.engine.core.common.businessentities.MigrationSupport; import org.ovirt.engine.core.common.businessentities.OriginType; import org.ovirt.engine.core.common.businessentities.UsbPolicy; @@ -489,10 +491,10 @@ } model.setDisplay(new Display()); model.getDisplay().setType(map(entity.getDisplayType(), null)); - model.getDisplay().setAddress(entity.getDisplayIp()); - Integer displayPort = entity.getDisplay(); + model.getDisplay().setAddress(determineGraphicsIp(entity)); + Integer displayPort = determineGraphicsPort(entity); model.getDisplay().setPort(displayPort==null || displayPort==-1 ? null : displayPort); - Integer displaySecurePort = entity.getDisplaySecurePort(); + Integer displaySecurePort = entity.getGraphicsInfos().get(GraphicsType.SPICE).getTlsPort(); model.getDisplay().setSecurePort(displaySecurePort==null || displaySecurePort==-1 ? null : displaySecurePort); model.getDisplay().setMonitors(entity.getNumOfMonitors()); model.getDisplay().setSingleQxlPci(entity.getSingleQxlPci()); @@ -584,6 +586,36 @@ return model; } + // -- temporary methods for deriving information about graphics from graphics info + // introducing graphics info in entities will lead to API change (todo) + private static Integer determineGraphicsPort(org.ovirt.engine.core.common.businessentities.VM entity) { + GraphicsInfo graphicsInfo = determineActiveGraphics(entity); + return (graphicsInfo == null) + ? null + : graphicsInfo.getPort(); + } + + private static String determineGraphicsIp(org.ovirt.engine.core.common.businessentities.VM entity) { + GraphicsInfo graphicsInfo = determineActiveGraphics(entity); + return (graphicsInfo == null) + ? null + : graphicsInfo.getIp(); + } + + private static GraphicsInfo determineActiveGraphics(org.ovirt.engine.core.common.businessentities.VM entity) { + GraphicsInfo spiceInfo = entity.getGraphicsInfos().get(GraphicsType.SPICE); + GraphicsInfo vncInfo = entity.getGraphicsInfos().get(GraphicsType.VNC); + + if (spiceInfo.isSet()) { + return spiceInfo; + } else if (vncInfo.isSet()) { + return vncInfo; + } + + return null; + } + // -- + @Mapping(from = VM.class, to = RunVmOnceParams.class) public static RunVmOnceParams map(VM vm, RunVmOnceParams template) { RunVmOnceParams params = template != null ? template : new RunVmOnceParams(); diff --git a/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/VmMapperTest.java b/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/VmMapperTest.java index 60805f8..15328ba 100644 --- a/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/VmMapperTest.java +++ b/backend/manager/modules/restapi/types/src/test/java/org/ovirt/engine/api/restapi/types/VmMapperTest.java @@ -22,6 +22,7 @@ import org.ovirt.engine.api.model.VmPlacementPolicy; import org.ovirt.engine.api.model.VmType; import org.ovirt.engine.api.restapi.utils.OsTypeMockUtils; +import org.ovirt.engine.core.common.businessentities.GraphicsType; import org.ovirt.engine.core.common.businessentities.OriginType; import org.ovirt.engine.core.common.businessentities.UsbPolicy; import org.ovirt.engine.core.common.businessentities.VDSGroup; @@ -225,17 +226,17 @@ } @Test - public void testDisplayPort() { + public void testDisplayPort() { // todo refactor to use GI org.ovirt.engine.core.common.businessentities.VM entity = new org.ovirt.engine.core.common.businessentities.VM(); entity.setStatus(VMStatus.Up); - entity.setDisplay(5900); - entity.setDisplaySecurePort(9999); + entity.getGraphicsInfos().get(GraphicsType.SPICE).setPort(5900); + entity.getGraphicsInfos().get(GraphicsType.SPICE).setTlsPort(9999); VM model = VmMapper.map(entity, (VM) null); assertTrue(model.getDisplay().getPort() == 5900); assertTrue(model.getDisplay().getSecurePort() == 9999); - entity.setDisplay(-1); - entity.setDisplaySecurePort(-1); + entity.getGraphicsInfos().get(GraphicsType.SPICE).setPort(null); + entity.getGraphicsInfos().get(GraphicsType.SPICE).setTlsPort(null); model = VmMapper.map(entity, (VM) null); assertNull(model.getDisplay().getPort()); assertNull(model.getDisplay().getSecurePort()); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Cloner.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Cloner.java index 47fbb1c..7b421e8 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Cloner.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Cloner.java @@ -128,9 +128,6 @@ // TODO: this is also an object, so needs to be cloned as well. while it is only accessed via VM.DiskMap, which // creates a dictionary // from it - actually the DiskImage's themselves are probably sharing the same reference... - vm.setDisplay(instance.getDisplay()); - vm.setDisplayIp(instance.getDisplayIp()); - vm.setDisplaySecurePort(instance.getDisplaySecurePort()); vm.setDisplayType(instance.getDisplayType()); vm.getGraphicsInfos().putAll(instance.getGraphicsInfos()); vm.getDynamicData().setVncKeyboardLayout(instance.getDynamicData().getVncKeyboardLayout()); diff --git a/packaging/dbscripts/create_views.sql b/packaging/dbscripts/create_views.sql index 8815e52..132b717 100644 --- a/packaging/dbscripts/create_views.sql +++ b/packaging/dbscripts/create_views.sql @@ -629,7 +629,6 @@ vm_dynamic.guest_last_login_time as guest_last_login_time, vm_dynamic.guest_last_logout_time as guest_last_logout_time, vm_dynamic.guest_os as guest_os, vm_dynamic.console_user_id as console_user_id, vm_dynamic.guest_agent_nics_hash as guest_agent_nics_hash, vm_dynamic.run_on_vds as run_on_vds, vm_dynamic.migrating_to_vds as migrating_to_vds, vm_dynamic.app_list as app_list, - vm_dynamic.display as display, vm_dynamic.spice_port as spice_port, vm_dynamic.spice_tls_port as spice_tls_port, vm_dynamic.spice_ip as spice_ip, @@ -641,10 +640,8 @@ vm_static.num_of_sockets as num_of_sockets, vm_static.cpu_per_socket as cpu_per_socket, vm_static.usb_policy as usb_policy, vm_dynamic.acpi_enable as acpi_enable, vm_dynamic.session as session, vm_static.num_of_sockets*vm_static.cpu_per_socket as num_of_cpus, vm_static.quota_id as quota_id, quota.quota_name as quota_name, storage_pool.quota_enforcement_type as quota_enforcement_type, - vm_dynamic.display_ip as display_ip, vm_dynamic.display_type as display_type, vm_dynamic.kvm_enable as kvm_enable, vm_dynamic.boot_sequence as boot_sequence, - vm_dynamic.display_secure_port as display_secure_port, vm_dynamic.utc_diff as utc_diff, vm_dynamic.last_vds_run_on as last_vds_run_on, vm_dynamic.client_ip as client_ip,vm_dynamic.guest_requested_memory as guest_requested_memory, vm_static.time_zone as time_zone, vm_statistics.cpu_user as cpu_user, vm_statistics.cpu_sys as cpu_sys, vm_statistics.elapsed_time as elapsed_time, vm_statistics.usage_network_percent as usage_network_percent, vm_statistics.disks_usage as disks_usage, @@ -687,7 +684,6 @@ vms.vm_host, vms.vmt_num_of_sockets * vms.vmt_cpu_per_socket AS vmt_num_of_cpus, vms.vm_pid, vms.last_start_time, vms.last_stop_time, vms.guest_cur_user_name, vms.console_cur_user_name, vms.guest_last_login_time, vms.console_user_id, vms.guest_last_logout_time, vms.guest_os, vms.run_on_vds, vms.migrating_to_vds, vms.app_list, - vms.display, vms.spice_port as spice_port, vms.spice_tls_port as spice_tls_port, vms.spice_ip as spice_ip, @@ -698,10 +694,8 @@ vms.allow_console_reconnect, vms.is_initialized, vms.num_of_sockets, vms.cpu_per_socket, vms.usb_policy, vms.acpi_enable, vms.session, vms.num_of_sockets * vms.cpu_per_socket AS num_of_cpus, - vms.display_ip, vms.display_type, vms.kvm_enable, vms.boot_sequence, - vms.display_secure_port, vms.utc_diff, vms.last_vds_run_on, vms.client_ip, vms.guest_requested_memory, vms.time_zone, vms.cpu_user, vms.cpu_sys, vms.elapsed_time, vms.usage_network_percent, vms.disks_usage, vms.usage_mem_percent, vms.migration_progress_percent, vms.usage_cpu_percent, vms.run_on_vds_name, diff --git a/packaging/dbscripts/upgrade/03_06_0080_remove_deprecated_display_columns.sql b/packaging/dbscripts/upgrade/03_06_0080_remove_deprecated_display_columns.sql new file mode 100644 index 0000000..505113c --- /dev/null +++ b/packaging/dbscripts/upgrade/03_06_0080_remove_deprecated_display_columns.sql @@ -0,0 +1,6 @@ +-- Drops unused graphics-related column superseded by graphics info + +select fn_db_drop_column('vm_dynamic', 'display'); +select fn_db_drop_column('vm_dynamic', 'display_secure_port'); +select fn_db_drop_column('vm_dynamic', 'display_ip'); + diff --git a/packaging/dbscripts/vms_sp.sql b/packaging/dbscripts/vms_sp.sql index 7f6dd35..44d6f8a 100644 --- a/packaging/dbscripts/vms_sp.sql +++ b/packaging/dbscripts/vms_sp.sql @@ -243,14 +243,11 @@ v_last_start_time TIMESTAMP WITH TIME ZONE , v_last_stop_time TIMESTAMP WITH TIME ZONE , v_vm_pid INTEGER , - v_display INTEGER , v_acpi_enable BOOLEAN , v_session INTEGER , - v_display_ip VARCHAR(255) , v_display_type INTEGER , v_kvm_enable BOOLEAN , v_boot_sequence INTEGER , - v_display_secure_port INTEGER , v_utc_diff INTEGER , v_last_vds_run_on UUID , v_client_ip VARCHAR(255), @@ -312,14 +309,11 @@ v_last_start_time TIMESTAMP WITH TIME ZONE , v_last_stop_time TIMESTAMP WITH TIME ZONE , v_vm_pid INTEGER , - v_display INTEGER , v_acpi_enable BOOLEAN , v_session INTEGER , - v_display_ip VARCHAR(255) , v_display_type INTEGER , v_kvm_enable BOOLEAN , v_boot_sequence INTEGER , - v_display_secure_port INTEGER , v_utc_diff INTEGER , v_last_vds_run_on UUID , v_client_ip VARCHAR(255) , @@ -358,10 +352,9 @@ status = v_status,vm_host = v_vm_host,vm_ip = v_vm_ip,vm_fqdn = v_vm_fqdn, last_start_time = v_last_start_time, last_stop_time = v_last_stop_time, - vm_pid = v_vm_pid,display = v_display,acpi_enable = v_acpi_enable, - session = v_session,display_ip = v_display_ip, + vm_pid = v_vm_pid,acpi_enable = v_acpi_enable, + session = v_session, display_type = v_display_type,kvm_enable = v_kvm_enable,boot_sequence = v_boot_sequence, - display_secure_port = v_display_secure_port, utc_diff = v_utc_diff,last_vds_run_on = v_last_vds_run_on,client_ip = v_client_ip, guest_requested_memory = v_guest_requested_memory, hibernation_vol_handle = v_hibernation_vol_handle,exit_status = v_exit_status, -- To view, visit http://gerrit.ovirt.org/31200 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id4fbd37b2b41b7288f78b60f27427c7b666d83d4 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Frank Kobzik <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
