Shahar Havivi has uploaded a new change for review. Change subject: UI: add indication the VMInit root password is set ......................................................................
UI: add indication the VMInit root password is set Since we are not returning the password on edit VM, we need to let the user know that the password is set. Bug-Url: https://bugzilla.redhat.com/1051041 Change-Id: Iedfea8520e885c948772dd0d1b612296aeced895 Signed-off-by: Shahar Havivi <[email protected]> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmInit.java M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmInitWidget.java M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmInitWidget.ui.xml M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInitModel.java M frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java 7 files changed, 80 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/88/23988/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java index 7dfe9ff..616f73a 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VmHandler.java @@ -37,6 +37,7 @@ import org.ovirt.engine.core.common.businessentities.VmDevice; import org.ovirt.engine.core.common.businessentities.VmDeviceGeneralType; import org.ovirt.engine.core.common.businessentities.VmDynamic; +import org.ovirt.engine.core.common.businessentities.VmInit; import org.ovirt.engine.core.common.businessentities.VmStatic; import org.ovirt.engine.core.common.businessentities.network.VmNetworkInterface; import org.ovirt.engine.core.common.businessentities.network.VmNic; @@ -287,6 +288,7 @@ VmInitDAO db = DbFacade.getInstance().getVmInitDao(); vm.setVmInit(db.get(vm.getId())); if (secure && vm.getVmInit() != null) { + vm.getVmInit().setPasswordSet(!StringUtils.isEmpty(vm.getVmInit().getRootPassword())); vm.getVmInit().setRootPassword(null); } } @@ -295,9 +297,18 @@ if (vm.getVmInit() != null) { vm.getVmInit().setId(vm.getId()); VmInitDAO db = DbFacade.getInstance().getVmInitDao(); - if (db.get(vm.getId()) == null) { + VmInit oldVmInit = db.get(vm.getId()); + if (oldVmInit == null) { db.save(vm.getVmInit()); } else { + if (vm.getVmInit().isPasswordSet()) { + // since we are not always returning the password in + // updateVmInitFromDB() + // method (we don't want to display it in the UI/API) we + // don't want to override + // the password if the flag is on + vm.getVmInit().setRootPassword(oldVmInit.getRootPassword()); + } db.update(vm.getVmInit()); } } diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmInit.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmInit.java index 2457cdb..e7075b0 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmInit.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmInit.java @@ -20,6 +20,7 @@ private String winKey; private String rootPassword; + private boolean passwordSet; private String customScript; public VmInit() { @@ -116,4 +117,12 @@ public void setWinKey(String winKey) { this.winKey = winKey; } + + public boolean isPasswordSet() { + return passwordSet; + } + + public void setPasswordSet(boolean passwordSet) { + this.passwordSet = passwordSet; + } } diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java index 8832c68..c768a13 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java @@ -232,6 +232,15 @@ @DefaultStringValue("Remove selected") String cloudInitObjectRemoveLabel(); + @DefaultStringValue("Use already configured password") + String vmInitPasswordSetLabel(); + + @DefaultStringValue("Password is set, uncheck to change password") + String vmInitPasswordSetToolTip(); + + @DefaultStringValue("Password is not set") + String vmInitPasswordNotSetToolTip(); + @DefaultStringValue("Enter the hostname to be assigned to the guest") String cloudInitHostnameToolTip(); diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmInitWidget.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmInitWidget.java index 003b284..64e6f28 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmInitWidget.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmInitWidget.java @@ -31,6 +31,7 @@ import org.ovirt.engine.ui.uicompat.Event; import org.ovirt.engine.ui.uicompat.EventArgs; import org.ovirt.engine.ui.uicompat.IEventListener; +import org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs; import java.util.Map; @@ -111,6 +112,11 @@ @Path(value = "authorizedKeys.entity") @WithElementId EntityModelTextAreaEditor authorizedKeysEditor; + + @UiField + @Path(value = "passwordSet.entity") + @WithElementId + EntityModelCheckBoxEditor passwordSetEditor; @UiField @Path(value = "customScript.entity") @@ -304,6 +310,7 @@ void localize() { hostnameEditor.setLabel(constants.cloudInitHostnameLabel()); authorizedKeysEditor.setLabel(constants.cloudInitAuthorizedKeysLabel()); + passwordSetEditor.setLabel(constants.vmInitPasswordSetLabel()); regenerateKeysEnabledEditor.setLabel(constants.cloudInitRegenerateKeysLabel()); timeZoneEnabledEditor.setLabel(constants.cloudInitConfigureTimeZoneLabel()); timeZoneEditor.setLabel(constants.cloudInitTimeZoneLabel()); @@ -333,6 +340,7 @@ hostnameEditor.setTitle(constants.cloudInitHostnameToolTip()); authorizedKeysEditor.setTitle(constants.cloudInitAuthorizedKeysToolTip()); + passwordSetEditor.setTitle(constants.vmInitPasswordSetToolTip()); customScriptEditor.setTitle(constants.customScriptToolTip()); regenerateKeysEnabledEditor.setTitle(constants.cloudInitRegenerateKeysToolTip()); timeZoneEditor.setTitle(constants.cloudInitTimeZoneToolTip()); @@ -374,6 +382,7 @@ rootPasswordEditor.addStyleName(customizableStyle.primaryOption()); rootPasswordVerificationEditor.addStyleName(customizableStyle.primaryOption()); authorizedKeysEditor.addStyleName(customizableStyle.primaryOption()); + passwordSetEditor.addStyleName(customizableStyle.primaryOption()); regenerateKeysEnabledEditor.addStyleName(customizableStyle.primaryOption()); networkExpanderContent.addStyleName(customizableStyle.primaryOption()); @@ -447,6 +456,19 @@ } }); + model.getPasswordSet().getPropertyChangedEvent().addListener(new IEventListener() { + @Override + public void eventRaised(Event ev, Object sender, EventArgs args) { + String propName = ((PropertyChangedEventArgs) args).propertyName; + if ("IsChangable".equals(propName)) { //$NON-NLS-1$ + passwordSetEditor.setTitle( + model.getPasswordSet().getIsChangable() ? + constants.vmInitPasswordSetToolTip() : constants.vmInitPasswordNotSetToolTip() + ); + } + } + }); + } void initializeEnabledCBBehavior(final VmInitModel model) { diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmInitWidget.ui.xml b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmInitWidget.ui.xml index a1b5c3b..52251c6 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmInitWidget.ui.xml +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/widget/uicommon/popup/vm/VmInitWidget.ui.xml @@ -67,6 +67,7 @@ <d:AdvancedParametersExpander ui:field="authenticationExpander"/> <g:FlowPanel ui:field="authenticationExpanderContent"> + <e:EntityModelCheckBoxEditor ui:field="passwordSetEditor" /> <e:EntityModelPasswordBoxEditor ui:field="rootPasswordEditor" /> <e:EntityModelPasswordBoxEditor ui:field="rootPasswordVerificationEditor" /> <e:EntityModelTextAreaEditor ui:field="authorizedKeysEditor" /> diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInitModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInitModel.java index 336b04b..7cbec8e 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInitModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/vms/VmInitModel.java @@ -132,6 +132,15 @@ privateRootPassword = value; } + private EntityModel privatePasswordSet; + public EntityModel getPasswordSet() { + return privatePasswordSet; + } + + private void setPasswordSet(EntityModel value) { + privatePasswordSet = value; + } + private EntityModel privateRootPasswordVerification; public EntityModel getRootPasswordVerification() { return privateRootPasswordVerification; @@ -330,6 +339,8 @@ setTimeZoneList(new ListModel()); setRootPassword(new EntityModel()); setRootPasswordVerification(new EntityModel()); + setPasswordSet(new EntityModel()); + getPasswordSet().getEntityChangedEvent().addListener(this); setNetworkEnabled(new EntityModel()); setNetworkSelectedName(new EntityModel()); @@ -374,6 +385,9 @@ getTimeZoneEnabled().setEntity(false); getNetworkEnabled().setEntity(false); getAttachmentEnabled().setEntity(false); + + getPasswordSet().setEntity(false); + getPasswordSet().setIsChangable(false); getHostname().setEntity(""); getDomain().setEntity(""); @@ -428,6 +442,9 @@ getRootPassword().setEntity(vmInit.getRootPassword()); getRootPasswordVerification().setEntity(vmInit.getRootPassword()); } + getPasswordSet().setEntity(vmInit.isPasswordSet()); + getPasswordSet().setIsChangable(vmInit.isPasswordSet()); + if (!StringHelper.isNullOrEmpty(vmInit.getAuthorizedKeys())) { getAuthorizedKeys().setEntity(vmInit.getAuthorizedKeys()); } @@ -688,6 +705,7 @@ vmInit.setDnsServers((String) getDnsServers().getEntity()); vmInit.setDnsSearch((String) getDnsSearchDomains().getEntity()); vmInit.setCustomScript((String) getCustomScript().getEntity()); + vmInit.setPasswordSet((Boolean) getPasswordSet().getEntity()); return vmInit; } @@ -713,10 +731,18 @@ else if (ev.matchesDefinition(EntityModel.entityChangedEventDefinition)) { if (sender == getNetworkSelectedName()) { networkSelectedName_SelectionChanged(); + } else if (sender == getPasswordSet()) { + passwordSetChanged(); } } } + private void passwordSetChanged() { + Boolean passwordChangable = !(Boolean) getPasswordSet().getEntity(); + getRootPassword().setIsChangable(passwordChangable); + getRootPasswordVerification().setIsChangable(passwordChangable); + } + @Override public void executeCommand(UICommand command) { super.executeCommand(command); diff --git a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java index 96ad995..5765837 100644 --- a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java +++ b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java @@ -2173,5 +2173,6 @@ @DefaultStringValue("VirtIO-SCSI is not supported for the selected OS") String cannotEnableVirtioScsiForOs(); + } -- To view, visit http://gerrit.ovirt.org/23988 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iedfea8520e885c948772dd0d1b612296aeced895 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Shahar Havivi <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
