VMware {code} Community
marcdevin
Contributor
Contributor
Jump to solution

vCloud Director 5.5 - how to perform "power on and force guest os customization" through rest API ?

Hello,

I am trying to change the password of my vm using rest API call :

<GuestCustomizationSection href="https://xxx/api/vApp/vm-20dad588-96b4-4479-8ddb-91f1cb55df27/guestCustomizationSection/" type="application/vnd.vmware.vcloud.guestCustomizationSection+xml" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns="http://www.vmware.com/vcloud/v1.5">

    <ovf:Info>Specifies Guest OS Customization Settings</ovf:Info>

    <Enabled>true</Enabled>

    <JoinDomainEnabled>false</JoinDomainEnabled>

    <UseOrgSettings>false</UseOrgSettings>

    <AdminPasswordEnabled>true</AdminPasswordEnabled>

    <AdminPasswordAuto>false</AdminPasswordAuto>

    <AdminPassword>***********</AdminPassword>

    <ResetPasswordRequired>true</ResetPasswordRequired>

    <CustomizationScript>

@ECHO OFF

    </CustomizationScript>

    <ComputerName>myvm</ComputerName>

    <Link rel="edit" type="application/vnd.vmware.vcloud.guestCustomizationSection+xml" href="https://xxxx/api/vApp/vm-20dad588-96b4-4479-8ddb-91f1cb55df27/guestCustomizationSection/"/>

</GuestCustomizationSection>

And then I power on the vm using :  https://xxxxxxx/api/vApp/vm-20dad588-96b4-4479-8ddb-91f1cb55df27/power/action/powerOn

VM parameter are correctly set on vCloud Director, vm is powered on, but Guest OS Customization is not happening.

Is there a way to "power on and force guest os customization" using rest API like in vCD UI ? Or do I need to do it differently?

Thanks for your help !

0 Kudos
1 Solution

Accepted Solutions
EcoBassam
Enthusiast
Enthusiast
Jump to solution

Hello Marc,

Here is more explanation on what is happening and why you have this behavior :

  • If you instantiate the vApp with deploy=true, you reserve resources on vCloud and vSphere for the vApp and all of its VMs and load all the configuration, among that is the attribute value of guestCustomization to disabled. So when on the second step you modify the GuestCusto to Enabled, it is changed on the VCD BD but not loaded, because the VM is already on a deployed state this change will not be taken into consideration when you do the poweron on the last step.
  • If you instantiate the vApp with deploy=false, you do not reserve resources on vCloud and vSphere for the vApp and no configuration is loaded. So when on the second step you modify the GuestCusto to Enabled, it is changed on the VCD BD and beacause the VM is not on a deployed state it will load all the information from DB when you initiate the poweron and the GuestCusto is taken into consideration

You may also have the following usecase : you have an already deployed VM and you want to initiate the equivalent of the function “PowerON and Force Recustomization” that is available on the GUI. In order to this on the API, please follow these steps :

  1. PowerOff the VM
  2. Issue a PUT Call to change the attribute needsCustomization to true
  3. Check that the following attributes have these values :
    1. needsCustomization="true"
    2. deployed="false"
  4. PowerOn the VM

This will Recustomize the VM.

View solution in original post

0 Kudos
6 Replies
onappdev
Enthusiast
Enthusiast
Jump to solution

After VM's guest customization has beed done you can just send empty POST request to /vApp/{id}/action/customizeAtNextPowerOn. This feature has worked since vCD version 5.6 as documentation says.

marcdevin
Contributor
Contributor
Jump to solution

Thanks for helping.

Yes I have seen that in the documentation, but my cloud provider is using vCD 5.5

0 Kudos
onappdev
Enthusiast
Enthusiast
Jump to solution

1. Are you sure you have a correct version of VMware tools installed inside the VM?

2. Have you tried powering off/on the whole vApp to see if it forces re-customization?

0 Kudos
marcdevin
Contributor
Contributor
Jump to solution

VMware tools are installed inside the VM but i don't know if it the last version. If I perform the steps directly in vCloud Director UI and power on vm using "power on and force recustomization", it works correctly.

I will try to restart the vapp to see what happens.

0 Kudos
EcoBassam
Enthusiast
Enthusiast
Jump to solution

Hello Marc,

Here is more explanation on what is happening and why you have this behavior :

  • If you instantiate the vApp with deploy=true, you reserve resources on vCloud and vSphere for the vApp and all of its VMs and load all the configuration, among that is the attribute value of guestCustomization to disabled. So when on the second step you modify the GuestCusto to Enabled, it is changed on the VCD BD but not loaded, because the VM is already on a deployed state this change will not be taken into consideration when you do the poweron on the last step.
  • If you instantiate the vApp with deploy=false, you do not reserve resources on vCloud and vSphere for the vApp and no configuration is loaded. So when on the second step you modify the GuestCusto to Enabled, it is changed on the VCD BD and beacause the VM is not on a deployed state it will load all the information from DB when you initiate the poweron and the GuestCusto is taken into consideration

You may also have the following usecase : you have an already deployed VM and you want to initiate the equivalent of the function “PowerON and Force Recustomization” that is available on the GUI. In order to this on the API, please follow these steps :

  1. PowerOff the VM
  2. Issue a PUT Call to change the attribute needsCustomization to true
  3. Check that the following attributes have these values :
    1. needsCustomization="true"
    2. deployed="false"
  4. PowerOn the VM

This will Recustomize the VM.

0 Kudos
marcdevin
Contributor
Contributor
Jump to solution

Thank you, it seems to be fixed now !

0 Kudos