Shahar Havivi has uploaded a new change for review. Change subject: Engine: add Admin password and OrgName for Sysprep ......................................................................
Engine: add Admin password and OrgName for Sysprep Change-Id: Ie33cce7b395ba8e7e7a46bc31a7564410f808888 Signed-off-by: Shahar Havivi <shah...@redhat.com> --- M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/VmInit.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmInitDAODbFacadeImpl.java M backend/manager/modules/dal/src/test/resources/fixtures.xml M backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd M backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/SysprepHandler.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 A frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/validation/MatchFieldsValidator.java A packaging/dbscripts/upgrade/03_05_0430_add_org_name_for_sysprep.sql M packaging/dbscripts/vms_sp.sql 13 files changed, 338 insertions(+), 101 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/42/27642/1 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 7ad6120..20b43dc 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 @@ -14,6 +14,7 @@ private String authorizedKeys; private Boolean regenerateKeys; private String activeDirectoryOU; + private String orgName; private String dnsServers; private String dnsSearch; @@ -181,4 +182,12 @@ public void setActiveDirectoryOU(String activeDirectoryOU) { this.activeDirectoryOU = activeDirectoryOU; } + + public String getOrgName() { + return orgName; + } + + public void setOrgName(String orgName) { + this.orgName = orgName; + } } diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmInitDAODbFacadeImpl.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmInitDAODbFacadeImpl.java index 896a9d1..e560972 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmInitDAODbFacadeImpl.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dao/VmInitDAODbFacadeImpl.java @@ -74,7 +74,8 @@ .addValue("system_locale", vmInit.getSystemLocale()) .addValue("user_locale", vmInit.getUserLocale()) .addValue("user_name", vmInit.getUserName()) - .addValue("active_directory_ou", vmInit.getActiveDirectoryOU()); + .addValue("active_directory_ou", vmInit.getActiveDirectoryOU()) + .addValue("org_name", vmInit.getOrgName()); } private static class VMInitRowMapper implements RowMapper<VmInit> { @@ -102,6 +103,7 @@ entity.setUserLocale(rs.getString("user_locale")); entity.setUserName(rs.getString("user_name")); entity.setActiveDirectoryOU(rs.getString("active_directory_ou")); + entity.setOrgName(rs.getString("org_name")); return entity; } diff --git a/backend/manager/modules/dal/src/test/resources/fixtures.xml b/backend/manager/modules/dal/src/test/resources/fixtures.xml index eb77dab..f5a5132 100644 --- a/backend/manager/modules/dal/src/test/resources/fixtures.xml +++ b/backend/manager/modules/dal/src/test/resources/fixtures.xml @@ -6288,6 +6288,7 @@ <column>user_locale</column> <column>user_name</column> <column>active_directory_ou</column> + <column>org_name</column> <row> <value>77296e00-0cad-4e5a-9299-008a7b6f4354</value> <value>users.mydomain.com</value> @@ -6307,6 +6308,7 @@ <value>en_US</value> <value>ec2</value> <value></value> + <value></value> </row> </table> </dataset> diff --git a/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd b/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd index 103211d..58fcca8 100644 --- a/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd +++ b/backend/manager/modules/restapi/interface/definition/src/main/resources/api.xsd @@ -2663,6 +2663,7 @@ <xs:element name="user_locale" type="xs:string" minOccurs="0" maxOccurs="1"/> <xs:element name="user_name" type="xs:string" minOccurs="0" maxOccurs="1"/> <xs:element name="active_directory_ou" type="xs:string" minOccurs="0" maxOccurs="1"/> + <xs:element name="org_name" type="xs:string" minOccurs="0" maxOccurs="1"/> </xs:sequence> </xs:complexType> 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 5f75b41..9ba44e5 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 @@ -1,5 +1,7 @@ package org.ovirt.engine.api.restapi.types; +import static org.ovirt.engine.api.restapi.types.IntegerMapper.mapMinusOneToNull; +import static org.ovirt.engine.api.restapi.types.IntegerMapper.mapNullToMinusOne; import static org.ovirt.engine.core.compat.Guid.createGuidFromString; import java.util.ArrayList; @@ -79,9 +81,6 @@ import org.ovirt.engine.core.common.utils.VmDeviceType; import org.ovirt.engine.core.compat.Guid; import org.ovirt.engine.core.compat.Version; - -import static org.ovirt.engine.api.restapi.types.IntegerMapper.mapNullToMinusOne; -import static org.ovirt.engine.api.restapi.types.IntegerMapper.mapMinusOneToNull; public class VmMapper { @@ -1084,6 +1083,10 @@ if (model.isSetActiveDirectoryOu()) { entity.setUserName(model.getActiveDirectoryOu()); } + + if (model.isSetOrgName()) { + entity.setUserName(model.getOrgName()); + } return entity; } @@ -1146,6 +1149,9 @@ if (entity.getActiveDirectoryOU() != null) { model.setActiveDirectoryOu(entity.getActiveDirectoryOU()); } + if (entity.getOrgName() != null) { + model.setActiveDirectoryOu(entity.getOrgName()); + } return model; } diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/SysprepHandler.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/SysprepHandler.java index c466290..1a8c774 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/SysprepHandler.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/SysprepHandler.java @@ -78,19 +78,16 @@ sysPrepContent = populateSysPrepDomainProperties(sysPrepContent, domain, sysPrepParams); sysPrepContent = replace(sysPrepContent, "$ComputerName$", hostName != null ? hostName : ""); - sysPrepContent = replace(sysPrepContent, "$AdminPassword$", Config.<String> getValue(ConfigValues.LocalAdminPassword)); - String timeZone = getTimeZone(vm); - sysPrepContent = replace(sysPrepContent, "$TimeZone$", timeZone); - sysPrepContent = replace(sysPrepContent, "$OrgName$", Config.<String> getValue(ConfigValues.OrganizationName)); - String inputLocale = Config.<String> getValue(ConfigValues.DefaultSysprepLocale); String uiLanguage = Config.<String> getValue(ConfigValues.DefaultSysprepLocale); String systemLocale = Config.<String> getValue(ConfigValues.DefaultSysprepLocale); String userLocale = Config.<String> getValue(ConfigValues.DefaultSysprepLocale); String activeDirectoryOU = ""; + String adminPassword = Config.<String> getValue(ConfigValues.LocalAdminPassword); + String orgName = Config.<String> getValue(ConfigValues.OrganizationName); if (vm.getVmInit() != null) { if (!StringUtils.isEmpty(vm.getVmInit().getInputLocale())) { @@ -108,6 +105,12 @@ if (!StringUtils.isEmpty(vm.getVmInit().getActiveDirectoryOU())) { activeDirectoryOU = vm.getVmInit().getActiveDirectoryOU(); } + if (!StringUtils.isEmpty(vm.getVmInit().getRootPassword())) { + adminPassword = vm.getVmInit().getRootPassword(); + } + if (!StringUtils.isEmpty(vm.getVmInit().getOrgName())) { + orgName = vm.getVmInit().getOrgName(); + } } sysPrepContent = replace(sysPrepContent, "$SetupUiLanguageUiLanguage$", inputLocale); @@ -116,6 +119,8 @@ sysPrepContent = replace(sysPrepContent, "$SystemLocale$", systemLocale); sysPrepContent = replace(sysPrepContent, "$UserLocale$", userLocale); sysPrepContent = replace(sysPrepContent, "$MachineObjectOU$", activeDirectoryOU); + sysPrepContent = replace(sysPrepContent, "$OrgName$", orgName); + sysPrepContent = replace(sysPrepContent, "$AdminPassword$", adminPassword); } return sysPrepContent; 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 db758c0..ff2e62c 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 @@ -172,6 +172,9 @@ @DefaultStringValue("User Locale") String userLocaleLabel(); + @DefaultStringValue("Custom Locale") + String customLocaleLabel(); + @DefaultStringValue("Sysprep") String sysprepLabel(); @@ -186,6 +189,9 @@ @DefaultStringValue("VM Hostname") String cloudInitHostnameLabel(); + + @DefaultStringValue("Organization Name") + String sysprepOrgNameLabel(); @DefaultStringValue("Authentication") String cloudInitAuthenticationLabel(); @@ -207,6 +213,12 @@ @DefaultStringValue("Verify Root Password") String cloudInitRootPasswordVerificationLabel(); + + @DefaultStringValue("Admin Password") + String sysprepAdminPasswordLabel(); + + @DefaultStringValue("Verify Admin Password") + String sysprepAdminPasswordVerificationLabel(); @DefaultStringValue("Networks") String cloudInitNetworskLabel(); @@ -289,6 +301,12 @@ @DefaultStringValue("Verify the root password for the guest") String cloudInitRootPasswordVerificationToolTip(); + @DefaultStringValue("Choose a password for the admin login") + String sysprepAdminPasswordToolTip(); + + @DefaultStringValue("Verify the password") + String sysprepAdminPasswordVerificationToolTip(); + @DefaultStringValue("Enter the name of a network interface, e.g. \"eth0\"") String cloudInitNetworkToolTip(); 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 95e5f44..114944d 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 @@ -112,6 +112,11 @@ StringEntityModelTextBoxEditor windowsHostnameEditor; @UiField + @Path(value = "sysprepOrgName.entity") + @WithElementId + StringEntityModelTextBoxEditor sysprepOrgNameEditor; + + @UiField @Path(value = "sysprepDomain.selectedItem") @WithElementId ListModelSuggestBoxEditor sysprepDomainEditor; @@ -162,11 +167,6 @@ StringEntityModelTextAreaEditor authorizedKeysEditor; @UiField - @Path(value = "passwordSet.entity") - @WithElementId - EntityModelCheckBoxEditor passwordSetEditor; - - @UiField @Path(value = "customScript.entity") @WithElementId StringEntityModelTextAreaEditor customScriptEditor; @@ -199,15 +199,34 @@ FlowPanel authenticationExpanderContent; @UiField - @Path(value = "rootPassword.entity") + @Path(value = "cloudInitPasswordSet.entity") @WithElementId - StringEntityModelPasswordBoxEditor rootPasswordEditor; + EntityModelCheckBoxEditor cloudInitPasswordSetEditor; @UiField - @Path(value = "rootPasswordVerification.entity") + @Path(value = "cloudInitRootPassword.entity") @WithElementId - StringEntityModelPasswordBoxEditor rootPasswordVerificationEditor; + StringEntityModelPasswordBoxEditor cloudInitRootPasswordEditor; + @UiField + @Path(value = "cloudInitRootPasswordVerification.entity") + @WithElementId + StringEntityModelPasswordBoxEditor cloudInitRootPasswordVerificationEditor; + + @UiField + @Path(value = "sysprepPasswordSet.entity") + @WithElementId + EntityModelCheckBoxEditor sysprepPasswordSetEditor; + + @UiField + @Path(value = "sysprepAdminPassword.entity") + @WithElementId + StringEntityModelPasswordBoxEditor sysprepAdminPasswordEditor; + + @UiField + @Path(value = "sysprepAdminPasswordVerification.entity") + @WithElementId + StringEntityModelPasswordBoxEditor sysprepAdminPasswordVerificationEditor; @UiField @Ignore @@ -264,6 +283,23 @@ @UiField @Ignore FlowPanel sysprepScriptExpanderContent; + + @UiField + @Ignore + AdvancedParametersExpander sysprepPasswordExpander; + + @UiField + @Ignore + FlowPanel sysprepPasswordExpanderContent; + + + @UiField + @Ignore + AdvancedParametersExpander sysprepInputsExpander; + + @UiField + @Ignore + FlowPanel sysprepInputsExpanderContent; @UiField @Ignore @@ -342,6 +378,8 @@ networkExpander.initWithContent(networkExpanderContent.getElement()); customScriptExpander.initWithContent(customScriptExpanderContent.getElement()); sysprepScriptExpander.initWithContent(sysprepScriptExpanderContent.getElement()); + sysprepPasswordExpander.initWithContent(sysprepPasswordExpanderContent.getElement()); + sysprepInputsExpander.initWithContent(sysprepInputsExpanderContent.getElement()); } void initCheckBoxEditors() { @@ -378,6 +416,7 @@ void localize() { hostnameEditor.setLabel(constants.cloudInitHostnameLabel()); windowsHostnameEditor.setLabel(constants.cloudInitHostnameLabel()); + sysprepOrgNameEditor.setLabel(constants.sysprepOrgNameLabel()); sysprepDomainEditor.setLabel(constants.domainVmPopup()); inputLocaleEditor.setLabel(constants.inputLocaleLabel()); uiLanguageEditor.setLabel(constants.uiLanguageLabel()); @@ -388,14 +427,17 @@ userLocaleEditor.setLabel(constants.userLocaleLabel()); userNameEditor.setLabel(constants.cloudInitUserNameLabel()); authorizedKeysEditor.setLabel(constants.cloudInitAuthorizedKeysLabel()); - passwordSetEditor.setLabel(constants.vmInitPasswordSetLabel()); + cloudInitPasswordSetEditor.setLabel(constants.vmInitPasswordSetLabel()); + sysprepPasswordSetEditor.setLabel(constants.vmInitPasswordSetLabel()); regenerateKeysEnabledEditor.setLabel(constants.cloudInitRegenerateKeysLabel()); timeZoneEnabledEditor.setLabel(constants.cloudInitConfigureTimeZoneLabel()); timeZoneEditor.setLabel(constants.cloudInitTimeZoneLabel()); windowsSyspreptimeZoneEnabledEditor.setLabel(constants.cloudInitConfigureTimeZoneLabel()); windowsSysprepTimeZoneEditor.setLabel(constants.cloudInitTimeZoneLabel()); - rootPasswordEditor.setLabel(constants.cloudInitRootPasswordLabel()); - rootPasswordVerificationEditor.setLabel(constants.cloudInitRootPasswordVerificationLabel()); + cloudInitRootPasswordEditor.setLabel(constants.cloudInitRootPasswordLabel()); + cloudInitRootPasswordVerificationEditor.setLabel(constants.cloudInitRootPasswordVerificationLabel()); + sysprepAdminPasswordEditor.setLabel(constants.sysprepAdminPasswordLabel()); + sysprepAdminPasswordVerificationEditor.setLabel(constants.sysprepAdminPasswordVerificationLabel()); networkEnabledEditor.setLabel(constants.cloudInitNetworkLabel()); @@ -418,12 +460,15 @@ hostnameEditor.setTitle(constants.cloudInitHostnameToolTip()); windowsHostnameEditor.setTitle(constants.cloudInitHostnameToolTip()); authorizedKeysEditor.setTitle(constants.cloudInitAuthorizedKeysToolTip()); - passwordSetEditor.setTitle(constants.vmInitPasswordSetToolTip()); + cloudInitPasswordSetEditor.setTitle(constants.vmInitPasswordSetToolTip()); + sysprepPasswordSetEditor.setTitle(constants.vmInitPasswordSetToolTip()); customScriptEditor.setTitle(constants.customScriptToolTip()); regenerateKeysEnabledEditor.setTitle(constants.cloudInitRegenerateKeysToolTip()); timeZoneEditor.setTitle(constants.cloudInitTimeZoneToolTip()); - rootPasswordEditor.setTitle(constants.cloudInitRootPasswordToolTip()); - rootPasswordVerificationEditor.setTitle(constants.cloudInitRootPasswordVerificationToolTip()); + cloudInitRootPasswordEditor.setTitle(constants.cloudInitRootPasswordToolTip()); + cloudInitRootPasswordVerificationEditor.setTitle(constants.cloudInitRootPasswordVerificationToolTip()); + sysprepAdminPasswordEditor.setTitle(constants.sysprepAdminPasswordToolTip()); + sysprepAdminPasswordVerificationEditor.setTitle(constants.sysprepAdminPasswordVerificationToolTip()); networkListEditor.setTitle(constants.cloudInitNetworkToolTip()); networkNameEditor.setTitle(constants.cloudInitNetworkToolTip()); @@ -446,6 +491,12 @@ sysprepScriptExpander.setTitleWhenExpended(constants.sysprepLabel()); sysprepScriptExpander.setTitleWhenCollapsed(constants.sysprepLabel()); + + sysprepPasswordExpander.setTitleWhenExpended(constants.sysprepAdminPasswordLabel()); + sysprepPasswordExpander.setTitleWhenCollapsed(constants.sysprepAdminPasswordLabel()); + + sysprepInputsExpander.setTitleWhenExpended(constants.customLocaleLabel()); + sysprepInputsExpander.setTitleWhenCollapsed(constants.customLocaleLabel()); } void addStyles() { @@ -467,12 +518,16 @@ userNameEditor.addStyleName(customizableStyle.primaryOption()); hostnameEditor.addStyleName(customizableStyle.primaryOption()); windowsHostnameEditor.addStyleName(customizableStyle.primaryOption()); + sysprepOrgNameEditor.addStyleName(customizableStyle.primaryOption()); timeZoneEnabledEditor.addStyleName(customizableStyle.primaryOption()); timeZoneEditor.addStyleName(customizableStyle.primaryOption()); - rootPasswordEditor.addStyleName(customizableStyle.primaryOption()); - rootPasswordVerificationEditor.addStyleName(customizableStyle.primaryOption()); + cloudInitRootPasswordEditor.addStyleName(customizableStyle.primaryOption()); + cloudInitRootPasswordVerificationEditor.addStyleName(customizableStyle.primaryOption()); + sysprepAdminPasswordEditor.addStyleName(customizableStyle.primaryOption()); + sysprepAdminPasswordVerificationEditor.addStyleName(customizableStyle.primaryOption()); authorizedKeysEditor.addStyleName(customizableStyle.primaryOption()); - passwordSetEditor.addStyleName(customizableStyle.primaryOption()); + cloudInitPasswordSetEditor.addStyleName(customizableStyle.primaryOption()); + sysprepPasswordSetEditor.addStyleName(customizableStyle.primaryOption()); regenerateKeysEnabledEditor.addStyleName(customizableStyle.primaryOption()); networkExpanderContent.addStyleName(customizableStyle.primaryOption()); @@ -482,6 +537,8 @@ authenticationExpanderContent.addStyleName(customizableStyle.expanderContent()); customScriptExpanderContent.addStyleName(customizableStyle.expanderContent()); sysprepScriptExpanderContent.addStyleName(customizableStyle.expanderContent()); + sysprepPasswordExpanderContent.addStyleName(customizableStyle.expanderContent()); + sysprepInputsExpanderContent.addStyleName(customizableStyle.expanderContent()); } /* Controls style for network options based on network selection */ @@ -546,14 +603,29 @@ } }); - model.getPasswordSet().getPropertyChangedEvent().addListener(new IEventListener() { + model.getCloudInitPasswordSet().getPropertyChangedEvent().addListener(new IEventListener() { @Override public void eventRaised(Event ev, Object sender, EventArgs args) { if (args != null && args instanceof PropertyChangedEventArgs) { String propName = ((PropertyChangedEventArgs) args).propertyName; if ("IsChangable".equals(propName)) { //$NON-NLS-1$ - passwordSetEditor.setTitle( - model.getPasswordSet().getIsChangable() ? + cloudInitPasswordSetEditor.setTitle( + model.getCloudInitPasswordSet().getIsChangable() ? + constants.vmInitPasswordSetToolTip() : constants.vmInitPasswordNotSetToolTip() + ); + } + } + } + }); + + model.getSysprepPasswordSet().getPropertyChangedEvent().addListener(new IEventListener() { + @Override + public void eventRaised(Event ev, Object sender, EventArgs args) { + if (args != null && args instanceof PropertyChangedEventArgs) { + String propName = ((PropertyChangedEventArgs) args).propertyName; + if ("IsChangable".equals(propName)) { //$NON-NLS-1$ + sysprepPasswordSetEditor.setTitle( + model.getSysprepPasswordSet().getIsChangable() ? constants.vmInitPasswordSetToolTip() : constants.vmInitPasswordNotSetToolTip() ); } 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 a822733..d08da8f 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 @@ -60,13 +60,23 @@ <g:FlowPanel ui:field="syspreptOptionsContent"> <ge:StringEntityModelTextBoxEditor ui:field="windowsHostnameEditor" /> <ge:ListModelSuggestBoxEditor ui:field="sysprepDomainEditor" /> + <ge:StringEntityModelTextBoxEditor ui:field="sysprepOrgNameEditor" /> + <ge:StringEntityModelTextBoxEditor ui:field="activeDirectoryOUEditor" /> <ge:EntityModelCheckBoxEditor ui:field="windowsSyspreptimeZoneEnabledEditor" /> <e:ListModelListBoxEditor ui:field="windowsSysprepTimeZoneEditor" /> - <ge:StringEntityModelTextBoxEditor ui:field="inputLocaleEditor" /> - <ge:StringEntityModelTextBoxEditor ui:field="uiLanguageEditor" /> - <ge:StringEntityModelTextBoxEditor ui:field="systemLocaleEditor" /> - <ge:StringEntityModelTextBoxEditor ui:field="userLocaleEditor" /> - <ge:StringEntityModelTextBoxEditor ui:field="activeDirectoryOUEditor" /> + <d:AdvancedParametersExpander ui:field="sysprepPasswordExpander" addStyleNames="{style.verticalPanel}"/> + <g:FlowPanel ui:field="sysprepPasswordExpanderContent" > + <ge:EntityModelCheckBoxEditor ui:field="sysprepPasswordSetEditor" /> + <ge:StringEntityModelPasswordBoxEditor ui:field="sysprepAdminPasswordEditor" /> + <ge:StringEntityModelPasswordBoxEditor ui:field="sysprepAdminPasswordVerificationEditor" /> + </g:FlowPanel> + <d:AdvancedParametersExpander ui:field="sysprepInputsExpander" addStyleNames="{style.verticalPanel}"/> + <g:FlowPanel ui:field="sysprepInputsExpanderContent" > + <ge:StringEntityModelTextBoxEditor ui:field="inputLocaleEditor" /> + <ge:StringEntityModelTextBoxEditor ui:field="uiLanguageEditor" /> + <ge:StringEntityModelTextBoxEditor ui:field="systemLocaleEditor" /> + <ge:StringEntityModelTextBoxEditor ui:field="userLocaleEditor" /> + </g:FlowPanel> <d:AdvancedParametersExpander ui:field="sysprepScriptExpander" addStyleNames="{style.verticalPanel}"/> <g:FlowPanel ui:field="sysprepScriptExpanderContent" > <ge:StringEntityModelTextAreaEditor ui:field="sysprepScriptEditor" labelStyleName="{style.displayNone}" /> @@ -84,9 +94,9 @@ <g:FlowPanel ui:field="authenticationExpanderContent"> <ge:StringEntityModelTextBoxEditor ui:field="userNameEditor" /> - <ge:EntityModelCheckBoxEditor ui:field="passwordSetEditor" /> - <ge:StringEntityModelPasswordBoxEditor ui:field="rootPasswordEditor" /> - <ge:StringEntityModelPasswordBoxEditor ui:field="rootPasswordVerificationEditor" /> + <ge:EntityModelCheckBoxEditor ui:field="cloudInitPasswordSetEditor" /> + <ge:StringEntityModelPasswordBoxEditor ui:field="cloudInitRootPasswordEditor" /> + <ge:StringEntityModelPasswordBoxEditor ui:field="cloudInitRootPasswordVerificationEditor" /> <ge:StringEntityModelTextAreaEditor ui:field="authorizedKeysEditor" /> <ge:EntityModelCheckBoxEditor ui:field="regenerateKeysEnabledEditor" /> </g:FlowPanel> 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 9307623..f760bd8 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 @@ -29,6 +29,7 @@ import org.ovirt.engine.ui.uicommonweb.validation.HostnameValidation; import org.ovirt.engine.ui.uicommonweb.validation.IValidation; import org.ovirt.engine.ui.uicommonweb.validation.IpAddressValidation; +import org.ovirt.engine.ui.uicommonweb.validation.MatchFieldsValidator; import org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation; import org.ovirt.engine.ui.uicommonweb.validation.SubnetMaskValidation; import org.ovirt.engine.ui.uicompat.ConstantsManager; @@ -78,6 +79,14 @@ } private void setWindowsHostname(EntityModel<String> value) { privateWindowsHostname = value; + } + + private EntityModel<String> privateSysprepOrgName; + public EntityModel<String> getSysprepOrgName() { + return privateSysprepOrgName; + } + private void setSysprepOrgName(EntityModel<String> value) { + privateSysprepOrgName = value; } private EntityModel<String> privateHostname; @@ -164,7 +173,7 @@ } public boolean getAuthorizedKeysEnabled() { - return !StringHelper.isNullOrEmpty(getRootPassword().getEntity()); + return !StringHelper.isNullOrEmpty(getCloudInitRootPassword().getEntity()); } private EntityModel<String> privateAuthorizedKeys; @@ -201,33 +210,64 @@ privateTimeZoneList = value; } + public boolean getSysprepPasswordEnabled() { + return !StringHelper.isNullOrEmpty(getSysprepAdminPassword().getEntity()); + } + public boolean getRootPasswordEnabled() { - return !StringHelper.isNullOrEmpty(getRootPassword().getEntity()); + return !StringHelper.isNullOrEmpty(getCloudInitRootPassword().getEntity()); } - private EntityModel<String> privateRootPassword; - public EntityModel<String> getRootPassword() { - return privateRootPassword; + private EntityModel<String> privateCloudInitRootPassword; + public EntityModel<String> getCloudInitRootPassword() { + return privateCloudInitRootPassword; } - private void setRootPassword(EntityModel<String> value) { - privateRootPassword = value; + private void setCloudInitRootPassword(EntityModel<String> value) { + privateCloudInitRootPassword = value; } - private EntityModel<Boolean> privatePasswordSet; - public EntityModel<Boolean> getPasswordSet() { - return privatePasswordSet; + private EntityModel<String> privateCloudInitRootPasswordVerification; + public EntityModel<String> getCloudInitRootPasswordVerification() { + return privateCloudInitRootPasswordVerification; + } + private void setCloudInitRootPasswordVerification(EntityModel<String> value) { + privateCloudInitRootPasswordVerification = value; } - private void setPasswordSet(EntityModel<Boolean> value) { - privatePasswordSet = value; + private EntityModel<Boolean> privateCloudInitPasswordSet; + public EntityModel<Boolean> getCloudInitPasswordSet() { + return privateCloudInitPasswordSet; } - private EntityModel<String> privateRootPasswordVerification; - public EntityModel<String> getRootPasswordVerification() { - return privateRootPasswordVerification; + private void setCloudInitPasswordSet(EntityModel<Boolean> value) { + privateCloudInitPasswordSet = value; } - private void setRootPasswordVerification(EntityModel<String> value) { - privateRootPasswordVerification = value; + + + private EntityModel<String> privateSysprepAdminPassword; + public EntityModel<String> getSysprepAdminPassword() { + return privateSysprepAdminPassword; + } + private void setSysprepAdminPassword(EntityModel<String> value) { + privateSysprepAdminPassword = value; + } + + + private EntityModel<String> privateSysprepAdminPasswordVerification; + public EntityModel<String> getSysprepAdminPasswordVerification() { + return privateSysprepAdminPasswordVerification; + } + private void setSysprepAdminPasswordVerification(EntityModel<String> value) { + privateSysprepAdminPasswordVerification = value; + } + + private EntityModel<Boolean> privateSysprepPasswordSet; + public EntityModel<Boolean> getSysprepPasswordSet() { + return privateSysprepPasswordSet; + } + + private void setSysprepPasswordSet(EntityModel<Boolean> value) { + privateSysprepPasswordSet = value; } @@ -411,6 +451,7 @@ setWindowsSysprepTimeZone(new ListModel<Map.Entry<String, String>>()); setWindowsSysprepTimeZoneEnabled(new EntityModel<Boolean>()); setWindowsHostname(new EntityModel<String>()); + setSysprepOrgName(new EntityModel<String>()); setSysprepDomain(new ListModel<String>()); setInputLocale(new EntityModel<String>()); setUiLanguage(new EntityModel<String>()); @@ -426,10 +467,15 @@ setTimeZoneEnabled(new EntityModel<Boolean>()); setTimeZoneList(new ListModel<Map.Entry<String, String>>()); setUserName(new EntityModel<String>()); - setRootPassword(new EntityModel<String>()); - setRootPasswordVerification(new EntityModel<String>()); - setPasswordSet(new EntityModel<Boolean>()); - getPasswordSet().getEntityChangedEvent().addListener(this); + setCloudInitRootPassword(new EntityModel<String>()); + setCloudInitRootPasswordVerification(new EntityModel<String>()); + setCloudInitPasswordSet(new EntityModel<Boolean>()); + getCloudInitPasswordSet().getEntityChangedEvent().addListener(this); + setSysprepAdminPassword(new EntityModel<String>()); + setSysprepAdminPasswordVerification(new EntityModel<String>()); + setSysprepPasswordSet(new EntityModel<Boolean>()); + getSysprepPasswordSet().getEntityChangedEvent().addListener(this); + setNetworkEnabled(new EntityModel<Boolean>()); setNetworkSelectedName(new EntityModel<String>()); @@ -475,10 +521,13 @@ getNetworkEnabled().setEntity(false); getAttachmentEnabled().setEntity(false); - getPasswordSet().setEntity(false); - getPasswordSet().setIsChangable(false); + getCloudInitPasswordSet().setEntity(false); + getCloudInitPasswordSet().setIsChangable(false); + getSysprepPasswordSet().setEntity(false); + getSysprepPasswordSet().setIsChangable(false); getWindowsHostname().setEntity(""); + getSysprepOrgName().setEntity(""); getInputLocale().setEntity(""); getUiLanguage().setEntity(""); getSystemLocale().setEntity(""); @@ -486,8 +535,10 @@ getSysprepScript().setEntity(""); getHostname().setEntity(""); getUserName().setEntity(""); - getRootPassword().setEntity(""); - getRootPasswordVerification().setEntity(""); + getCloudInitRootPassword().setEntity(""); + getCloudInitRootPasswordVerification().setEntity(""); + getSysprepAdminPassword().setEntity(""); + getSysprepAdminPasswordVerification().setEntity(""); getAuthorizedKeys().setEntity(""); getRegenerateKeysEnabled().setEntity(false); getCustomScript().setEntity(""); @@ -521,6 +572,9 @@ getHostname().setEntity(vmInit.getHostname()); getWindowsHostname().setEntity(vmInit.getHostname()); } + if (!StringHelper.isNullOrEmpty(vmInit.getOrgName())) { + getSysprepOrgName().setEntity(vmInit.getOrgName()); + } updateSysprepDomain(vmInit.getDomain()); if (!StringHelper.isNullOrEmpty(vmInit.getInputLocale())) { getInputLocale().setEntity(vmInit.getInputLocale()); @@ -551,11 +605,16 @@ } if (!StringHelper.isNullOrEmpty(vmInit.getRootPassword())) { - getRootPassword().setEntity(vmInit.getRootPassword()); - getRootPasswordVerification().setEntity(vmInit.getRootPassword()); + getCloudInitRootPassword().setEntity(vmInit.getRootPassword()); + getCloudInitRootPasswordVerification().setEntity(vmInit.getRootPassword()); + getSysprepAdminPassword().setEntity(vmInit.getRootPassword()); + getSysprepAdminPasswordVerification().setEntity(vmInit.getRootPassword()); } - getPasswordSet().setEntity(vmInit.isPasswordAlreadyStored()); - getPasswordSet().setIsChangable(vmInit.isPasswordAlreadyStored()); + getCloudInitPasswordSet().setEntity(vmInit.isPasswordAlreadyStored()); + getCloudInitPasswordSet().setIsChangable(vmInit.isPasswordAlreadyStored()); + getSysprepPasswordSet().setEntity(vmInit.isPasswordAlreadyStored()); + getSysprepPasswordSet().setIsChangable(vmInit.isPasswordAlreadyStored()); + if (!StringHelper.isNullOrEmpty(vmInit.getAuthorizedKeys())) { getAuthorizedKeys().setEntity(vmInit.getAuthorizedKeys()); @@ -642,10 +701,23 @@ public boolean validate() { getHostname().setIsValid(true); getWindowsHostname().setIsValid(true); + getSysprepAdminPassword().setIsValid(true); + getSysprepAdminPasswordVerification().setIsValid(true); + getCloudInitRootPassword().setIsValid(true); + getCloudInitRootPasswordVerification().setIsValid(true); + if (getHostnameEnabled()) { if (this.isWindowsOS) { + if (getSysprepPasswordEnabled()) { + getSysprepAdminPassword().validateEntity(new IValidation[] { new NotEmptyValidation(), new MatchFieldsValidator(getSysprepAdminPassword().getEntity(), + getSysprepAdminPasswordVerification().getEntity()) }); + } getWindowsHostname().validateEntity(new IValidation[] { new HostnameValidation() }); } else { + if (getRootPasswordEnabled()) { + getCloudInitRootPassword().validateEntity(new IValidation[] { new NotEmptyValidation(), new MatchFieldsValidator(getCloudInitRootPassword().getEntity(), + getCloudInitRootPasswordVerification().getEntity()) }); + } getHostname().validateEntity(new IValidation[] { new HostnameValidation() }); } } @@ -661,24 +733,7 @@ getTimeZoneList().validateSelectedItem(new IValidation[] { new NotEmptyValidation() }); } - getRootPassword().setIsValid(true); - getRootPasswordVerification().setIsValid(true); - if (getRootPasswordEnabled()) { - getRootPassword().validateEntity(new IValidation[] { new NotEmptyValidation() }); - if (getRootPassword().getIsValid()) { - if (!(getRootPassword().getEntity()) - .equals(getRootPasswordVerification().getEntity())) { - ArrayList<String> reasons = new ArrayList<String>(); - reasons.add(rootPasswordMatchMessage); - getRootPassword().setInvalidityReasons(reasons); - getRootPassword().setIsValid(false); - } - } - if (!getRootPassword().getIsValid()) { - getRootPasswordVerification().setInvalidityReasons(getRootPassword().getInvalidityReasons()); - getRootPasswordVerification().setIsValid(false); - } - } + boolean networkIsValid = true; getNetworkList().setIsValid(true); @@ -738,7 +793,8 @@ && getSysprepDomain().getIsValid() && getAuthorizedKeys().getIsValid() && getTimeZoneList().getIsValid() - && getRootPassword().getIsValid() + && getCloudInitRootPassword().getIsValid() + && getSysprepAdminPassword().getIsValid() && networkIsValid && dnsIsValid; } @@ -812,15 +868,21 @@ vmInit.setUserLocale((String)getUserLocale().getEntity()); vmInit.setCustomScript((String) getSysprepScript().getEntity()); vmInit.setActiveDirectoryOU((String) getActiveDirectoryOU().getEntity()); + if (getSysprepPasswordEnabled()) { + vmInit.setRootPassword(getCloudInitRootPassword().getEntity()); + } + vmInit.setPasswordAlreadyStored(getSysprepPasswordSet().getEntity()); + vmInit.setOrgName((String) getSysprepOrgName().getEntity()); } else { vmInit.setCustomScript((String) getCustomScript().getEntity()); + if (getRootPasswordEnabled()) { + vmInit.setRootPassword(getCloudInitRootPassword().getEntity()); + } + vmInit.setPasswordAlreadyStored(getCloudInitPasswordSet().getEntity()); } vmInit.setUserName((String) getUserName().getEntity()); - if (getRootPasswordEnabled()) { - vmInit.setRootPassword(getRootPassword().getEntity()); - } vmInit.setAuthorizedKeys(getAuthorizedKeys().getEntity()); if (getRegenerateKeysEnabled().getEntity()) { vmInit.setRegenerateKeys(Boolean.TRUE); @@ -844,7 +906,6 @@ vmInit.setDnsServers(getDnsServers().getEntity()); vmInit.setDnsSearch(getDnsSearchDomains().getEntity()); vmInit.setCustomScript(getCustomScript().getEntity()); - vmInit.setPasswordAlreadyStored(getPasswordSet().getEntity()); return vmInit; } @@ -870,16 +931,24 @@ else if (ev.matchesDefinition(EntityModel.entityChangedEventDefinition)) { if (sender == getNetworkSelectedName()) { networkSelectedName_SelectionChanged(); - } else if (sender == getPasswordSet()) { - passwordSetChanged(); + } else if (sender == getCloudInitPasswordSet()) { + cloudInitPasswordSetChanged(); + } else if (sender == getSysprepPasswordSet()) { + sysprepPasswordSetChanged(); } } } - private void passwordSetChanged() { - Boolean passwordChangable = !getPasswordSet().getEntity(); - getRootPassword().setIsChangable(passwordChangable); - getRootPasswordVerification().setIsChangable(passwordChangable); + private void cloudInitPasswordSetChanged() { + Boolean passwordChangable = !getCloudInitPasswordSet().getEntity(); + getCloudInitRootPassword().setIsChangable(passwordChangable); + getCloudInitRootPasswordVerification().setIsChangable(passwordChangable); + } + + private void sysprepPasswordSetChanged() { + Boolean passwordChangable = !getSysprepPasswordSet().getEntity(); + getSysprepAdminPassword().setIsChangable(passwordChangable); + getSysprepAdminPasswordVerification().setIsChangable(passwordChangable); } @Override diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/validation/MatchFieldsValidator.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/validation/MatchFieldsValidator.java new file mode 100644 index 0000000..00e53ec --- /dev/null +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/validation/MatchFieldsValidator.java @@ -0,0 +1,35 @@ +package org.ovirt.engine.ui.uicommonweb.validation; + +import java.util.ArrayList; + +import org.ovirt.engine.ui.uicompat.ConstantsManager; +/** + * Validates a that Pair of two fields are equal + */ +public class MatchFieldsValidator implements IValidation { + + private String first; + private String second; + + public MatchFieldsValidator(String first, String second) { + this.first = first; + this.second = second; + } + + @Override + public ValidationResult validate(Object value) { + ValidationResult rs = new ValidationResult(); + rs.setSuccess(false); + + if (first != null && second != null && !first.equals(second)) { + ArrayList<String> reasons = new ArrayList<String>(); + reasons.add(ConstantsManager.getInstance().getConstants().cloudInitRootPasswordMatchMessage()); + rs.setReasons(reasons); + } else { + rs.setSuccess(true); + } + return rs; + } +} + + diff --git a/packaging/dbscripts/upgrade/03_05_0430_add_org_name_for_sysprep.sql b/packaging/dbscripts/upgrade/03_05_0430_add_org_name_for_sysprep.sql new file mode 100644 index 0000000..c11d48a --- /dev/null +++ b/packaging/dbscripts/upgrade/03_05_0430_add_org_name_for_sysprep.sql @@ -0,0 +1,5 @@ +-- ---------------------------------------------------------------------- +-- Adding org name for vm_init table (Sysprep usage) +-- ---------------------------------------------------------------------- +alter table vm_init +add column org_name VARCHAR(256) DEFAULT NULL; diff --git a/packaging/dbscripts/vms_sp.sql b/packaging/dbscripts/vms_sp.sql index b98772f..825ba38 100644 --- a/packaging/dbscripts/vms_sp.sql +++ b/packaging/dbscripts/vms_sp.sql @@ -1265,7 +1265,8 @@ v_system_locale VARCHAR(256), v_user_locale VARCHAR(256), v_user_name VARCHAR(256), - v_active_directory_ou VARCHAR(256)) + v_active_directory_ou VARCHAR(256), + v_org_name VARCHAR(256)) RETURNS VOID @@ -1276,7 +1277,8 @@ time_zone=v_time_zone, dns_servers=v_dns_servers, dns_search_domains=v_dns_search_domains, networks=v_networks, password=v_password, winkey=v_winkey, custom_script=v_custom_script, input_locale=v_input_locale, ui_language=v_ui_language, system_locale=v_system_locale, - user_locale=v_user_locale, user_name=v_user_name, active_directory_ou=v_active_directory_ou + user_locale=v_user_locale, user_name=v_user_name, active_directory_ou=v_active_directory_ou, + org_name=v_org_name WHERE vm_id = v_vm_id; END; $procedure$ LANGUAGE plpgsql; @@ -1311,16 +1313,17 @@ v_system_locale VARCHAR(256), v_user_locale VARCHAR(256), v_user_name VARCHAR(256), - v_active_directory_ou VARCHAR(256)) + v_active_directory_ou VARCHAR(256), + v_org_name VARCHAR(256)) RETURNS VOID AS $procedure$ BEGIN INSERT INTO vm_init(vm_id, host_name, domain, authorized_keys, regenerate_keys, time_zone, dns_servers, dns_search_domains, networks, password, winkey, custom_script, input_locale, ui_language, - system_locale, user_locale, user_name, active_directory_ou) + system_locale, user_locale, user_name, active_directory_ou, org_name) VALUES(v_vm_id, v_host_name, v_domain, v_authorized_keys, v_regenerate_keys, v_time_zone, v_dns_servers, v_dns_search_domains, v_networks, v_password, v_winkey, v_custom_script, v_input_locale, v_ui_language, - v_system_locale, v_user_locale, v_user_name, v_active_directory_ou); + v_system_locale, v_user_locale, v_user_name, v_active_directory_ou, v_org_name); END; $procedure$ LANGUAGE plpgsql; -- To view, visit http://gerrit.ovirt.org/27642 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ie33cce7b395ba8e7e7a46bc31a7564410f808888 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Shahar Havivi <shav...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches