Juan Hernandez has uploaded a new change for review.

Change subject: restapi: Set cloud-init user name
......................................................................

restapi: Set cloud-init user name

Before version 3.5 we used to add a "user: root" line to the generated
cloud-init file if the caller provided a password for the "root" user.  For
example, if the caller sent something like this:

  <action>
    <vm>
      <initialization>
        <cloud_init>
          <users>
            <user>root</user>
            <user>mypass</user>
          </users>
        </cloud_init>
      </initialization>
    </vm>
  </action>

We used to generate this cloud-init file:

  #cloud-config
  ssh_pwauth: true
  disable_root: 0
  output:
    all: '>> /var/log/cloud-init-output.log'
  user: root
  password: mypass
  ...

But starting with 3.5 we no longer generate the "user:root" line. This means
that cloud-init will assume that it has to change the password for its default
user, as defined in "/etc/cloud/cloud.cfg". For Fedora it is "fedora" and for
CentOS and RHEL it is "cloud-user".

The net result is that where we used to change the "root" password we now
change the "fedora" or "cloud-init" password.

To avoid this issue this patch restores the old behaviour.

Change-Id: Id18d614612c7143a81c3d14894c9fce88de41601
Bug-Url: https://bugzilla.redhat.com/1156155
Signed-off-by: Juan Hernandez <juan.hernan...@redhat.com>
---
M 
backend/manager/modules/restapi/types/src/main/java/org/ovirt/engine/api/restapi/types/VmMapper.java
1 file changed, 8 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/17/34417/1

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 9397118..4a6a4f7 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
@@ -1161,7 +1161,14 @@
 
         if (model.isSetUsers()) {
             for (User user : model.getUsers().getUsers()) {
-                entity.setRootPassword(user.getPassword());
+                String userName = user.getUserName();
+                if (StringUtils.equals(userName, "root")) {
+                    entity.setUserName(userName);
+                    String userPassword = user.getPassword();
+                    if (userPassword != null) {
+                        entity.setRootPassword(userPassword);
+                    }
+                }
             }
         }
 


-- 
To view, visit http://gerrit.ovirt.org/34417
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Id18d614612c7143a81c3d14894c9fce88de41601
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Juan Hernandez <juan.hernan...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to