Arik Hadas has uploaded a new change for review. Change subject: userportal: allow connection to guest with non resp agent ......................................................................
userportal: allow connection to guest with non resp agent Change the way we treat non responding agent error received from VDSM when trying to connect to guest using spice. Instead of showing an error dialog and canceling the spice connection, we now present a confirmation dialog (saying that the user will have reduced capabilities due to the fact the agent is non-responsibe) - if the user choose to cancel, the spice console won't opened, and if the user choose to continue, spice console will be opened without SSO. FrontendEventsHandlerImpl was changed such that it won't show error dialog in case the error which is received from the backend shouldn't trigger error dialog. In addition, the confirmation dialog described above for the spice console connection operation was added. Change-Id: I4eaf009f5ff99946dbb421459ccdec9c536aea58 Bug-Url: https://bugzilla.redhat.com/871083 Signed-off-by: Arik Hadas <aha...@redhat.com> --- M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/uicommon/FrontendEventsHandlerImpl.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/IUserPortalListModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalBasicListModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/SpiceConsoleModel.java A frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/SpiceToGuestWithNonRespAgentModel.java M frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/Constants.java M frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/Messages.java M frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/uicommon/model/basic/UserPortalBasicListProvider.java M frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/uicommon/model/vm/UserPortalListProvider.java 9 files changed, 119 insertions(+), 23 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/30/10030/1 diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/uicommon/FrontendEventsHandlerImpl.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/uicommon/FrontendEventsHandlerImpl.java index 6fa6194..ce0b694 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/uicommon/FrontendEventsHandlerImpl.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/uicommon/FrontendEventsHandlerImpl.java @@ -5,6 +5,7 @@ import org.ovirt.engine.core.common.action.VdcActionType; import org.ovirt.engine.core.common.action.VdcReturnValueBase; +import org.ovirt.engine.core.common.errors.VdcBllErrors; import org.ovirt.engine.core.common.errors.VdcFault; import org.ovirt.engine.core.common.queries.VdcQueryReturnValue; import org.ovirt.engine.core.common.queries.VdcQueryType; @@ -44,8 +45,9 @@ @Override public void runActionExecutionFailed(VdcActionType action, VdcFault fault) { - errorPopupManager.show(messages.uiCommonRunActionExecutionFailed( - EnumTranslator.createAndTranslate(action), fault.getMessage())); + if (shouldRaiseErrorDialog(action, fault)) + errorPopupManager.show(messages.uiCommonRunActionExecutionFailed( + EnumTranslator.createAndTranslate(action), fault.getMessage())); } @Override @@ -56,16 +58,22 @@ List<String> errors = new ArrayList<String>(); for (VdcReturnValueBase v : returnValues) { - errors.add(messages.uiCommonRunActionFailed(v.getCanDoActionMessages().iterator().next())); + if (shouldRaiseErrorDialog(action, v.getFault())) + errors.add(messages.uiCommonRunActionFailed(v.getCanDoActionMessages().iterator().next())); } for (VdcFault fault : faults) { - errors.add(messages.uiCommonRunActionExecutionFailed(actionStr, fault.getMessage())); + if (shouldRaiseErrorDialog(action, fault)) + errors.add(messages.uiCommonRunActionExecutionFailed(actionStr, fault.getMessage())); } errorPopupManager.show(ErrorMessageFormatter.formatErrorMessages(errors)); } + private boolean shouldRaiseErrorDialog(VdcActionType actionType, VdcFault fault) { + return !(actionType == VdcActionType.VmLogon && fault.getError() == VdcBllErrors.nonresp); + } + @Override public void runQueryFailed(List<VdcQueryReturnValue> returnValue) { errorPopupManager.show( diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/IUserPortalListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/IUserPortalListModel.java index 93a9643..1d60c0e 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/IUserPortalListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/IUserPortalListModel.java @@ -171,6 +171,7 @@ { SpiceConsoleModel spiceConsoleModel = new SpiceConsoleModel(); spiceConsoleModel.getErrorEvent().addListener(this); + spiceConsoleModel.setModel(this); VncConsoleModel vncConsoleModel = new VncConsoleModel(); vncConsoleModel.setModel(this); RdpConsoleModel rdpConsoleModel = new RdpConsoleModel(); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalBasicListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalBasicListModel.java index 544cb27..ea87078 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalBasicListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/userportal/UserPortalBasicListModel.java @@ -347,7 +347,6 @@ protected void updateConsoleModel(UserPortalItemModel item) { super.updateConsoleModel(item); - if (item.getEntity() != null) { // Adjust item's default console for userportal 'Basic View' item.getDefaultConsole().setForceVmStatusUp(true); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/SpiceConsoleModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/SpiceConsoleModel.java index 9cb3e7d..d8bf868 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/SpiceConsoleModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/SpiceConsoleModel.java @@ -21,6 +21,7 @@ import org.ovirt.engine.core.common.businessentities.VMStatus; import org.ovirt.engine.core.common.businessentities.storage_domains; import org.ovirt.engine.core.common.config.Config; +import org.ovirt.engine.core.common.errors.VdcBllErrors; import org.ovirt.engine.core.common.queries.ConfigurationValues; import org.ovirt.engine.core.common.queries.GetAllImagesListByStoragePoolIdParameters; import org.ovirt.engine.core.common.queries.GetConfigurationValueParameters; @@ -36,10 +37,13 @@ import org.ovirt.engine.ui.frontend.AsyncQuery; import org.ovirt.engine.ui.frontend.Frontend; import org.ovirt.engine.ui.frontend.INewAsyncCallback; +import org.ovirt.engine.ui.uicommonweb.BaseCommandTarget; import org.ovirt.engine.ui.uicommonweb.DataProvider; +import org.ovirt.engine.ui.uicommonweb.ILogger; import org.ovirt.engine.ui.uicommonweb.TypeResolver; import org.ovirt.engine.ui.uicommonweb.UICommand; import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider; +import org.ovirt.engine.ui.uicommonweb.models.Model; import org.ovirt.engine.ui.uicompat.ConstantsManager; import org.ovirt.engine.ui.uicompat.FrontendActionAsyncResult; import org.ovirt.engine.ui.uicompat.FrontendMultipleQueryAsyncResult; @@ -58,6 +62,7 @@ private SpiceMenu menu; private ISpice privatespice; + private Model model; public ISpice getspice() { @@ -563,8 +568,8 @@ @Override public void Executed(FrontendActionAsyncResult result) { - SpiceConsoleModel model = (SpiceConsoleModel) result.getState(); - model.PostSendVmTicket(result.getReturnValue()); + SpiceConsoleModel spiceConsoleModel = (SpiceConsoleModel) result.getState(); + spiceConsoleModel.PostSendVmTicket(result.getReturnValue()); } }, this); @@ -582,8 +587,7 @@ // Only if the VM has agent and we connect through user-portal // we attempt to perform SSO (otherwise an error will be thrown) if (!getConfigurator().getIsAdmin() && getEntity().getGuestAgentVersion() != null - && getEntity().getStatus() == VMStatus.Up) - { + && getEntity().getStatus() == VMStatus.Up) { getLogger().Info("SpiceConsoleManager::Connect: Attempting to perform SSO on Desktop " //$NON-NLS-1$ + getEntity().getVmName()); @@ -592,29 +596,82 @@ @Override public void Executed(FrontendActionAsyncResult result) { - SpiceConsoleModel model = (SpiceConsoleModel) result.getState(); - VdcReturnValueBase returnValue1 = result.getReturnValue(); - boolean success1 = returnValue1 != null && returnValue1.getSucceeded(); - if (success1) - { - model.ExecuteQuery(getEntity()); + final SpiceConsoleModel spiceConsoleModel = (SpiceConsoleModel) result.getState(); + final VdcReturnValueBase logonCommandReturnValue = result.getReturnValue(); + boolean isLogonSucceeded = logonCommandReturnValue != null && logonCommandReturnValue.getSucceeded(); + if (isLogonSucceeded) { + spiceConsoleModel.ExecuteQuery(getEntity()); } - else - { - String vmName = returnValue1 != null ? returnValue1.getDescription() : ""; //$NON-NLS-1$ - model.getLogger() - .Info("SpiceConsoleManager::Connect: Failed to perform SSO on Destkop " //$NON-NLS-1$ - + vmName + " continuing without SSO."); //$NON-NLS-1$ + else { + if (logonCommandReturnValue != null && logonCommandReturnValue.getFault().getError() == VdcBllErrors.nonresp) { + UICommand okCommand = + new UICommand("SpiceWithoutAgentOK", new BaseCommandTarget() { //$NON-NLS-1$ + @Override + public void ExecuteCommand(UICommand uiCommand) { + logSsoOnDesktopFailedAgentNonResp(spiceConsoleModel.getLogger(), + logonCommandReturnValue != null ? + logonCommandReturnValue.getDescription() + : ""); //$NON-NLS-1$ + spiceConsoleModel.ExecuteQuery(getEntity()); + model.setWindow(null); + } + }); + + UICommand cancelCommand = new UICommand("SpiceWithoutAgentCancel", new BaseCommandTarget() { //$NON-NLS-1$ + @Override + public void ExecuteCommand(UICommand uiCommand) { + model.setWindow(null); + } + }); + + createConnectWithoutAgentConfirmationPopup(okCommand, cancelCommand); + } + else { + logSsoOnDesktopFailed(spiceConsoleModel.getLogger(), + logonCommandReturnValue != null ? logonCommandReturnValue.getDescription() + : ""); //$NON-NLS-1$ + } } } }, this); } - else - { + else { ExecuteQuery(getEntity()); } + } + + private void createConnectWithoutAgentConfirmationPopup(UICommand okCommand, UICommand cancelCommand){ + SpiceToGuestWithNonRespAgentModel spiceWithoutAgentModel = new SpiceToGuestWithNonRespAgentModel(); + spiceWithoutAgentModel.setTitle(ConstantsManager.getInstance() + .getConstants() + .guestAgentNotResponsiveTitle()); + spiceWithoutAgentModel.setHashName("sso_did_not_succeeded"); //$NON-NLS-1$ + + spiceWithoutAgentModel.setMessage(ConstantsManager.getInstance() + .getMessages() + .connectingToGuestWithNotResponsiveAgentMsg()); + + okCommand.setTitle(ConstantsManager.getInstance().getConstants().ok()); + okCommand.setIsDefault(true); + spiceWithoutAgentModel.getCommands().add(okCommand); + + cancelCommand.setTitle(ConstantsManager.getInstance().getConstants().cancel()); + cancelCommand.setIsCancel(true); + spiceWithoutAgentModel.getCommands().add(cancelCommand); + + model.setWindow(spiceWithoutAgentModel); + } + + private void logSsoOnDesktopFailedAgentNonResp(ILogger logger, String vmName) { + logger.Info("SpiceConsoleManager::Connect: Failed to perform SSO on Destkop " //$NON-NLS-1$ + + vmName + " because agent is non-responsive, continuing without SSO."); //$NON-NLS-1$ + } + + private void logSsoOnDesktopFailed(ILogger logger, String vmName) { + logger.Info("SpiceConsoleManager::Connect: Failed to perform SSO on Destkop " //$NON-NLS-1$ + + vmName + ", cancel open spice console request."); //$NON-NLS-1$ } public void SpiceConnect() @@ -628,6 +685,10 @@ } } + public void setModel(Model model) { + this.model = model; + } + private static final String CommandStop = "Stop"; //$NON-NLS-1$ private static final String CommandPlay = "Play"; //$NON-NLS-1$ private static final String CommandSuspend = "Suspend"; //$NON-NLS-1$ diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/SpiceToGuestWithNonRespAgentModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/SpiceToGuestWithNonRespAgentModel.java new file mode 100644 index 0000000..cc30590 --- /dev/null +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/SpiceToGuestWithNonRespAgentModel.java @@ -0,0 +1,7 @@ +package org.ovirt.engine.ui.uicommonweb.models.vms; + +import org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel; + +public class SpiceToGuestWithNonRespAgentModel extends ConfirmationModel { + +} diff --git a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/Constants.java b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/Constants.java index 4b4cfa5..88b25bc 100644 --- a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/Constants.java +++ b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/Constants.java @@ -242,6 +242,9 @@ @DefaultStringValue("Remove Template(s)") String removeTemplatesTitle(); + @DefaultStringValue("Guest Agent is not responsive") + String guestAgentNotResponsiveTitle(); + @DefaultStringValue("Data Center") String dataCenterTitle(); diff --git a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/Messages.java b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/Messages.java index d7f3074..b4e2421 100644 --- a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/Messages.java +++ b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/Messages.java @@ -27,6 +27,9 @@ + "Are you sure you want to disconnect the Management Interface?") String youAreAboutToDisconnectHostInterfaceMsg(String nicName); + @DefaultMessage("Could not connect to the agent on the guest, it may be unresponsive or not installed.\nAs a result, some features may not work.") + String connectingToGuestWithNotResponsiveAgentMsg(); + @DefaultMessage("This field can''t contain blanks or special characters, must be at least one character long, legal values are 0-9, a-z, ''_'', ''.'' and a length of up to {0} characters.") String hostNameMsg(int hostNameMaxLength); diff --git a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/uicommon/model/basic/UserPortalBasicListProvider.java b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/uicommon/model/basic/UserPortalBasicListProvider.java index c004cee..ad5ba9e 100644 --- a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/uicommon/model/basic/UserPortalBasicListProvider.java +++ b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/uicommon/model/basic/UserPortalBasicListProvider.java @@ -2,10 +2,12 @@ import org.ovirt.engine.ui.common.auth.CurrentUser; import org.ovirt.engine.ui.common.presenter.AbstractModelBoundPopupPresenterWidget; +import org.ovirt.engine.ui.common.presenter.popup.DefaultConfirmationPopupPresenterWidget; import org.ovirt.engine.ui.uicommonweb.UICommand; import org.ovirt.engine.ui.uicommonweb.models.Model; import org.ovirt.engine.ui.uicommonweb.models.userportal.UserPortalBasicListModel; import org.ovirt.engine.ui.uicommonweb.models.userportal.UserPortalItemModel; +import org.ovirt.engine.ui.uicommonweb.models.vms.SpiceToGuestWithNonRespAgentModel; import org.ovirt.engine.ui.uicommonweb.models.vms.VncInfoModel; import org.ovirt.engine.ui.userportal.gin.ClientGinjector; import org.ovirt.engine.ui.userportal.section.main.presenter.popup.console.ConsolePopupPresenterWidget; @@ -19,15 +21,18 @@ private Provider<VncInfoPopupPresenterWidget> vncInfoPopupProvider; private final Provider<ConsolePopupPresenterWidget> consolePopupProvider; + private final Provider<DefaultConfirmationPopupPresenterWidget> spiceToGuestWithNonRespAgentPopupProvider; @Inject public UserPortalBasicListProvider(ClientGinjector ginjector, Provider<VncInfoPopupPresenterWidget> vncInfoPopupProvider, Provider<ConsolePopupPresenterWidget> consolePopupProvider, + Provider<DefaultConfirmationPopupPresenterWidget> spiceToGuestWithNonRespAgentPopupProvider, CurrentUser user) { super(ginjector, user); this.vncInfoPopupProvider = vncInfoPopupProvider; this.consolePopupProvider = consolePopupProvider; + this.spiceToGuestWithNonRespAgentPopupProvider = spiceToGuestWithNonRespAgentPopupProvider; } @Override @@ -41,6 +46,8 @@ Model windowModel) { if (windowModel instanceof VncInfoModel) { return vncInfoPopupProvider.get(); + } else if (windowModel instanceof SpiceToGuestWithNonRespAgentModel) { + return spiceToGuestWithNonRespAgentPopupProvider.get(); } else if (lastExecutedCommand == getModel().getEditConsoleCommand()) { return consolePopupProvider.get(); } diff --git a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/uicommon/model/vm/UserPortalListProvider.java b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/uicommon/model/vm/UserPortalListProvider.java index d68726b..156f0e7 100644 --- a/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/uicommon/model/vm/UserPortalListProvider.java +++ b/frontend/webadmin/modules/userportal-gwtp/src/main/java/org/ovirt/engine/ui/userportal/uicommon/model/vm/UserPortalListProvider.java @@ -3,12 +3,14 @@ import org.ovirt.engine.core.common.businessentities.VmType; import org.ovirt.engine.ui.common.auth.CurrentUser; import org.ovirt.engine.ui.common.presenter.AbstractModelBoundPopupPresenterWidget; +import org.ovirt.engine.ui.common.presenter.popup.DefaultConfirmationPopupPresenterWidget; import org.ovirt.engine.ui.common.presenter.popup.RemoveConfirmationPopupPresenterWidget; import org.ovirt.engine.ui.uicommonweb.UICommand; import org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel; import org.ovirt.engine.ui.uicommonweb.models.Model; import org.ovirt.engine.ui.uicommonweb.models.userportal.UserPortalItemModel; import org.ovirt.engine.ui.uicommonweb.models.userportal.UserPortalListModel; +import org.ovirt.engine.ui.uicommonweb.models.vms.SpiceToGuestWithNonRespAgentModel; import org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel; import org.ovirt.engine.ui.uicommonweb.models.vms.VncInfoModel; import org.ovirt.engine.ui.userportal.gin.ClientGinjector; @@ -34,6 +36,7 @@ private final Provider<RemoveConfirmationPopupPresenterWidget> removeConfirmPopupProvider; private final Provider<VncInfoPopupPresenterWidget> vncInfoPopupProvider; private final Provider<ConsolePopupPresenterWidget> consolePopupProvider; + private final Provider<DefaultConfirmationPopupPresenterWidget> spiceToGuestWithNonRespAgentPopupProvider; @Inject public UserPortalListProvider(ClientGinjector ginjector, @@ -44,6 +47,7 @@ Provider<VmMakeTemplatePopupPresenterWidget> makeTemplatePopupProvider, Provider<RemoveConfirmationPopupPresenterWidget> removeConfirmPopupProvider, Provider<VncInfoPopupPresenterWidget> vncInfoPopupProvider, + Provider<DefaultConfirmationPopupPresenterWidget> spiceToGuestWithNonRespAgentPopupProvider, CurrentUser user, Provider<ConsolePopupPresenterWidget> consolePopupProvider) { super(ginjector, user); @@ -55,6 +59,7 @@ this.removeConfirmPopupProvider = removeConfirmPopupProvider; this.vncInfoPopupProvider = vncInfoPopupProvider; this.consolePopupProvider = consolePopupProvider; + this.spiceToGuestWithNonRespAgentPopupProvider = spiceToGuestWithNonRespAgentPopupProvider; } @Override @@ -84,6 +89,8 @@ } } else if (windowModel instanceof VncInfoModel) { return vncInfoPopupProvider.get(); + } else if (windowModel instanceof SpiceToGuestWithNonRespAgentModel) { + return spiceToGuestWithNonRespAgentPopupProvider.get(); } else if (lastExecutedCommand == getModel().getEditConsoleCommand()) { return consolePopupProvider.get(); } -- To view, visit http://gerrit.ovirt.org/10030 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4eaf009f5ff99946dbb421459ccdec9c536aea58 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Arik Hadas <aha...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches