Shahar Havivi has uploaded a new change for review. Change subject: core: Enable log-in for a regular user via cloud-init ......................................................................
core: Enable log-in for a regular user via cloud-init Change-Id: Iebfe44ec68e8bcfae5087504bf5cd29b29aad49b Signed-off-by: Shahar Havivi <[email protected]> --- 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/CloudInitHandler.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 packaging/dbscripts/upgrade/03_05_0160_vm_init_add_user_name.sql M packaging/dbscripts/vms_sp.sql 12 files changed, 69 insertions(+), 8 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/11/26011/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 8383f85..7710fa5 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 @@ -19,6 +19,7 @@ private List<VmInitNetwork> networks; private String winKey; + private String userName; private String rootPassword; private boolean passwordAlreadyStored; private String customScript; @@ -27,6 +28,7 @@ private String uiLanguage; private String systemLocale; private String userLocale; + public VmInit() { } @@ -162,4 +164,12 @@ public void setUserLocale(String userLocale) { this.userLocale = userLocale; } + + public String getUserName() { + return userName; + } + + public void setUserName(String userName) { + this.userName = userName; + } } 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 6173b1c..b463799 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 @@ -72,7 +72,8 @@ .addValue("input_locale", vmInit.getInputLocale()) .addValue("ui_language", vmInit.getUiLanguage()) .addValue("system_locale", vmInit.getSystemLocale()) - .addValue("user_locale", vmInit.getUserLocale()); + .addValue("user_locale", vmInit.getUserLocale()) + .addValue("user_name", vmInit.getUserName()); } private static class VMInitRowMapper implements RowMapper<VmInit> { @@ -98,6 +99,7 @@ entity.setUiLanguage(rs.getString("ui_language")); entity.setSystemLocale(rs.getString("system_locale")); entity.setUserLocale(rs.getString("user_locale")); + entity.setUserName(rs.getString("user_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 0a5d062..6858c84 100644 --- a/backend/manager/modules/dal/src/test/resources/fixtures.xml +++ b/backend/manager/modules/dal/src/test/resources/fixtures.xml @@ -6153,6 +6153,7 @@ <column>ui_language</column> <column>system_locale</column> <column>user_locale</column> + <column>user_name</column> <row> <value>77296e00-0cad-4e5a-9299-008a7b6f4354</value> <value>users.mydomain.com</value> @@ -6170,6 +6171,7 @@ <value>en_US</value> <value>en_US</value> <value>en_US</value> + <value>ec2</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 3a82ad0..8453e0f 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 @@ -2564,6 +2564,7 @@ <xs:element name="ui_language" type="xs:string" minOccurs="0" maxOccurs="1"/> <xs:element name="system_locale" type="xs:string" minOccurs="0" maxOccurs="1"/> <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: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 2def14f..d2ddba7 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 @@ -1058,6 +1058,10 @@ if (model.isSetUserLocale()) { entity.setUserLocale(model.getUserLocale()); } + + if (model.isSetUserName()) { + entity.setUserName(model.getUserName()); + } return entity; } @@ -1114,6 +1118,9 @@ if (entity.getUserLocale() != null) { model.setUserLocale(entity.getUserLocale()); } + if (entity.getUserName() != null) { + model.setUserName(entity.getUserName()); + } return model; } diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/CloudInitHandler.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/CloudInitHandler.java index 29f9d34..26937de 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/CloudInitHandler.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/vdsbroker/CloudInitHandler.java @@ -56,6 +56,7 @@ storeNetwork(); storeTimeZone(); storeRootPassword(); + storeUserName(); } catch (IllegalArgumentException ex) { throw new IllegalArgumentException("Malformed input", ex); } @@ -183,6 +184,12 @@ } } + private void storeUserName() { + if (!StringUtils.isEmpty(vmInit.getUserName())) { + userData.put("user", vmInit.getUserName()); + } + } + private void storeExecutionParameters() { // Store defaults in meta-data and user-data that apply regardless // of parameters passed in from the user. @@ -200,8 +207,6 @@ metaData.put("launch_index", "0"); metaData.put("availability_zone", "nova"); - // Don't create ec2-user - userData.put("user", "root"); userData.put("disable_root", 0); // Redirect log output from cloud-init execution from terminal 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 99222c3..1c3a40c 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 @@ -169,6 +169,9 @@ @DefaultStringValue("User Locale") String userLocaleLabel(); + @DefaultStringValue("User Name") + String cloudInitUserNameLabel(); + @DefaultStringValue("VM Hostname") String cloudInitHostnameLabel(); 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 6a232d0..fd2a0a1 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 @@ -131,6 +131,11 @@ EntityModelTextBoxEditor userLocaleEditor; @UiField + @Path(value = "userName.entity") + @WithElementId + EntityModelTextBoxEditor userNameEditor; + + @UiField @Path(value = "hostname.entity") @WithElementId EntityModelTextBoxEditor hostnameEditor; @@ -352,6 +357,7 @@ uiLanguageEditor.setLabel(constants.uiLanguageLabel()); systemLocaleEditor.setLabel(constants.systemLocaleLabel()); userLocaleEditor.setLabel(constants.userLocaleLabel()); + userNameEditor.setLabel(constants.cloudInitUserNameLabel()); authorizedKeysEditor.setLabel(constants.cloudInitAuthorizedKeysLabel()); passwordSetEditor.setLabel(constants.vmInitPasswordSetLabel()); regenerateKeysEnabledEditor.setLabel(constants.cloudInitRegenerateKeysLabel()); @@ -424,6 +430,7 @@ uiLanguageEditor.addStyleName(customizableStyle.primaryOption()); systemLocaleEditor.addStyleName(customizableStyle.primaryOption()); userLocaleEditor.addStyleName(customizableStyle.primaryOption()); + userNameEditor.addStyleName(customizableStyle.primaryOption()); hostnameEditor.addStyleName(customizableStyle.primaryOption()); windowsHostnameEditor.addStyleName(customizableStyle.primaryOption()); domainEditor.addStyleName(customizableStyle.primaryOption()); 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 1ca489e..eced546 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 @@ -77,6 +77,7 @@ <d:AdvancedParametersExpander ui:field="authenticationExpander"/> <g:FlowPanel ui:field="authenticationExpanderContent"> + <e:EntityModelTextBoxEditor ui:field="userNameEditor" /> <e:EntityModelCheckBoxEditor ui:field="passwordSetEditor" /> <e:EntityModelPasswordBoxEditor ui:field="rootPasswordEditor" /> <e:EntityModelPasswordBoxEditor ui:field="rootPasswordVerificationEditor" /> 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 6ca6337..701cb6f 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 @@ -103,6 +103,14 @@ privateUserLocale = value; } + private EntityModel privateUserName; + public EntityModel getUserName() { + return privateUserName; + } + private void setUserName(EntityModel value) { + privateUserName = value; + } + private EntityModel privateHostname; public EntityModel getHostname() { return privateHostname; @@ -387,6 +395,7 @@ setRegenerateKeysEnabled(new EntityModel()); setTimeZoneEnabled(new EntityModel()); setTimeZoneList(new ListModel()); + setUserName(new EntityModel()); setRootPassword(new EntityModel()); setRootPasswordVerification(new EntityModel()); setPasswordSet(new EntityModel()); @@ -446,6 +455,7 @@ getUserLocale().setEntity(""); getHostname().setEntity(""); getDomain().setEntity(""); + getUserName().setEntity(""); getRootPassword().setEntity(""); getRootPasswordVerification().setEntity(""); getAuthorizedKeys().setEntity(""); @@ -502,6 +512,10 @@ getTimeZoneEnabled().setEntity(true); selectTimeZone(getTimeZoneList(), timezones, tz); } + } + + if (!StringHelper.isNullOrEmpty(vmInit.getUserName())) { + getUserName().setEntity(vmInit.getUserName()); } if (!StringHelper.isNullOrEmpty(vmInit.getRootPassword())) { @@ -757,6 +771,8 @@ vmInit.setUserLocale((String)getUserLocale().getEntity()); } + vmInit.setUserName((String) getUserName().getEntity()); + if (getRootPasswordEnabled()) { vmInit.setRootPassword((String) getRootPassword().getEntity()); } diff --git a/packaging/dbscripts/upgrade/03_05_0160_vm_init_add_user_name.sql b/packaging/dbscripts/upgrade/03_05_0160_vm_init_add_user_name.sql new file mode 100644 index 0000000..3950acf --- /dev/null +++ b/packaging/dbscripts/upgrade/03_05_0160_vm_init_add_user_name.sql @@ -0,0 +1,5 @@ +-- ---------------------------------------------------------------------- +-- Adding user name for vm_init table (cloud-init usage) +-- ---------------------------------------------------------------------- +alter table vm_init +add column user_name VARCHAR(256) DEFAULT NULL; diff --git a/packaging/dbscripts/vms_sp.sql b/packaging/dbscripts/vms_sp.sql index b126653..f82e3f6 100644 --- a/packaging/dbscripts/vms_sp.sql +++ b/packaging/dbscripts/vms_sp.sql @@ -1220,7 +1220,8 @@ v_input_locale VARCHAR(256), v_ui_language VARCHAR(256), v_system_locale VARCHAR(256), - v_user_locale VARCHAR(256)) + v_user_locale VARCHAR(256), + v_user_name VARCHAR(256)) RETURNS VOID @@ -1231,7 +1232,7 @@ 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_locale=v_user_locale, user_name=v_user_name WHERE vm_id = v_vm_id; END; $procedure$ LANGUAGE plpgsql; @@ -1264,16 +1265,17 @@ v_input_locale VARCHAR(256), v_ui_language VARCHAR(256), v_system_locale VARCHAR(256), - v_user_locale VARCHAR(256)) + v_user_locale VARCHAR(256), + v_user_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) + system_locale, user_locale, user_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_system_locale, v_user_locale, v_user_name); END; $procedure$ LANGUAGE plpgsql; -- To view, visit http://gerrit.ovirt.org/26011 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iebfe44ec68e8bcfae5087504bf5cd29b29aad49b 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
