vmware-archive / vcd-cli

Command Line Interface for VMware vCloud Director
https://vmware.github.io/vcd-cli
Other
165 stars 108 forks source link

When use add-vm with SUSE SLES15, "auto generate password" always have been set #404

Open gm12367 opened 5 years ago

gm12367 commented 5 years ago

Dear author We just upgrade our VCD to version9.5, because there is an bug with version9.1, cause network and VM address can not be set after VM provisioning.

But another issue still persist, the "Auto generate password" parameter always have been set after VM provisioning.

Environment: OS: CentOS Linux release 7.6.1810 (Core) Kernel: 3.10.0-957.5.1.el7.x86_64 vcd version: vcd-cli, VMware vCloud Director Command Line Interface, 21.1.0 pyvcloud version: 20.1.0

My execution command as below: vcd vapp add-vm -c KaaS -t SLES15-test -o SLES15-test -n network001 -i pool SUSE-test SUSE SLES15-4.12.14-25.28-default My template have not set that parameter, and command not include "--password-auto", but it always set. I found below code in vapp.py in module pyvcloud:

        if needs_customization:
            guest_customization_param = E.GuestCustomizationSection(
                E_OVF.Info(),
                E.Enabled(True),
            )
            if 'password' in spec:
                guest_customization_param.append(E.AdminPasswordEnabled(True))
                guest_customization_param.append(E.AdminPasswordAuto(False))
                guest_customization_param.append(
                    E.AdminPassword(spec['password']))
            else:
                if 'password_auto' in spec:
                    guest_customization_param.append(
                        E.AdminPasswordEnabled(True))
                    guest_customization_param.append(E.AdminPasswordAuto(True))
                else:
                    guest_customization_param.append(
                        E.AdminPasswordEnabled(False))

Then I set both False in the judgement, then the parameter password auto generate have not been set.

            else:
                if 'password_auto' in spec:
                    guest_customization_param.append(
                        E.AdminPasswordEnabled(False))
                    guest_customization_param.append(E.AdminPasswordAuto(False))

Usually if we don't use "--password-auto" in "vcd vapp add-vm", this parameter should not be set, so I suppose this is a bug. If I am wrong or missed anything, please correct me.

Appreciated

matt-horwood-mayden commented 5 years ago

I too have this issue, after looking at the code I cant work out how this happens.

Please review and fix?