Ravi Nori has uploaded a new change for review. Change subject: restapi: Default VM display type overrides current VM display type in REST API(#864961) ......................................................................
restapi: Default VM display type overrides current VM display type in REST API(#864961) The api returns the default display type for a VM. When a VM is started with 'Run Once' and the display type is changed for just that session, the api should return the display type of the current VM session not the default display type. Change-Id: Ie838e8096909865647bed2d79e9571059f6095aa Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=864961 Signed-off-by: Ravi Nori <[email protected]> --- M backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java 1 file changed, 14 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/22/8822/1 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 18ef9ca..02a496b 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 @@ -315,7 +315,11 @@ } if (entity.getdefault_display_type() != null) { model.setDisplay(new Display()); - model.getDisplay().setType(map(entity.getdefault_display_type(), null)); + if (isValidSessionState(entity) && entity.getDynamicData() != null) { + model.getDisplay().setType(map(entity.getDynamicData().getdisplay_type(), null)); + } else { + model.getDisplay().setType(map(entity.getdefault_display_type(), null)); + } model.getDisplay().setAddress(entity.getdisplay_ip()); Integer displayPort = entity.getdisplay(); model.getDisplay().setPort(displayPort==null || displayPort==-1 ? null : displayPort); @@ -936,4 +940,13 @@ return pin; } + private static boolean isValidSessionState(org.ovirt.engine.core.common.businessentities.VM entity) { + return entity.getstatus() == VMStatus.Up || + entity.getstatus() == VMStatus.PoweringUp || + entity.getstatus() == VMStatus.WaitForLaunch || + entity.getstatus() == VMStatus.PoweredDown || + entity.getstatus() == VMStatus.RebootInProgress || + entity.getstatus() == VMStatus.RestoringState; + } + } -- To view, visit http://gerrit.ovirt.org/8822 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie838e8096909865647bed2d79e9571059f6095aa Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Ravi Nori <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
