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 6 files changed, 85 insertions(+), 3 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/03/24503/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..85d19d8 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; @@ -286,8 +287,13 @@ public static void updateVmInitFromDB(VmBase vm, boolean secure) { VmInitDAO db = DbFacade.getInstance().getVmInitDao(); vm.setVmInit(db.get(vm.getId())); - if (secure && vm.getVmInit() != null) { - vm.getVmInit().setRootPassword(null); + if (vm.getVmInit() != null) { + if (secure) { + vm.getVmInit().setPasswordAlreadyStored(!StringUtils.isEmpty(vm.getVmInit().getRootPassword())); + vm.getVmInit().setRootPassword(null); + } else { + vm.getVmInit().setPasswordAlreadyStored(false); + } } } @@ -295,9 +301,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().isPasswordAlreadyStored()) { + // 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..03d1beb 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 passwordAlreadyStored; private String customScript; public VmInit() { @@ -116,4 +117,12 @@ public void setWinKey(String winKey) { this.winKey = winKey; } + + public boolean isPasswordAlreadyStored() { + return passwordAlreadyStored; + } + + public void setPasswordAlreadyStored(boolean passwordAlreadyStored) { + this.passwordAlreadyStored = passwordAlreadyStored; + } } 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 6cea775..748bcc3 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..90ba968 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.isPasswordAlreadyStored()); + getPasswordSet().setIsChangable(vmInit.isPasswordAlreadyStored()); + 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.setPasswordAlreadyStored((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); -- To view, visit http://gerrit.ovirt.org/24503 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iedfea8520e885c948772dd0d1b612296aeced895 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.4 Gerrit-Owner: Shahar Havivi <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
