Quantcast
Viewing all articles
Browse latest Browse all 872

Howto change the root password within a linux vm wtih the vcloud api ?

Hello,

 

we are using the sdk php (vcloudPHP-1.0.0-314767) and our vcd director cell is the 1.0.0-285979 build.

 

we are tring to make a recustomization of a vm in a vapp. In our first test we tried to change the root password of a linux vm. To do that we try to use to things.

 

the first one was to push a GuestCustomizationSection (see bellow the xml export) :
<GuestCustomizationSection xmlns="http://www.vmware.com/vcloud/v1" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:vcloud="http://www.vmware.com/vcloud/v1" xmlns:vmext="http://www.vmware.com/vcloud/extension/v1" xmlns:cim="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
    <ovf:Info>Specifies Guest OS Customization Settings</ovf:Info>
    <Enabled>true</Enabled>
    <AdminPasswordEnabled>true</AdminPasswordEnabled>
    <AdminPasswordAuto>false</AdminPasswordAuto>
    <AdminPassword>tutu</AdminPassword>
    <ComputerName>linux_debian</ComputerName>
</GuestCustomizationSection>

 

After executing the modifyGuestCustomizationSettings function on our vm. we saw a change has operated. Using the vcloudirector ihm we saw that the new password was put on the VM.

 


The second one was to execute the recomposition or reconfiguration of the vm to implemente this new root password.

 

To test the password change we use (in a first time) the vcloudDirector functionnality (in the vcloudDirector IHM) "power on and force recustomization" on our vm. And at the end, the new password was implemented on the vm.

 

After that we wanted to do the same thing via the vcloud API. But we didn't find how to do that.

 

we tried to redeploy the vm (sdkvm->deploy() ) and poweron it or to redeploy the vapp (sdkVapp->deploy). nothing happen. The vm was powered but always with the former password.

 

So, we tried to make a recompose of the vapp. We saw in the vcloud API (page 163) that there is a section (customizationSection) usable for a vapp which provide the following parameter :
CustomizeOnInstantiate.
This parameter is a boolean and If true, then customization is executed for all children that include a GuestCustomizationSection.

 

By default, it seems that a vapp does not have this section (if we do a getVapp we don't see that section). So we thought that if we add this section with CustomizeOnInstantiate at true maybe the redeployment of the vapp will force the password change.

 

so we created a vapp recompose object . you can see the xml export bellow:

 

<RecomposeVAppParams xmlns="http://www.vmware.com/vcloud/v1" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:vcloud="http://www.vmware.com/vcloud/v1" xmlns:vmext="http://www.vmware.com/vcloud/extension/v1" xmlns:cim="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_VirtualSystemSettingData" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="">
    <InstantiationParams>
        <CustomizationSection>
            <ovf:Info>Specifies Customization Section</ovf:Info>
            <CustomizeOnInstantiate>true</CustomizeOnInstantiate>
        </CustomizationSection>
    </InstantiationParams>
</RecomposeVAppParams>

 


and when we executed the $sdkVapp->recompose($recomposeObj) function on the vapp where the vm on which we wanted to change the root password was, we got this error message :

 


PHP Fatal error:  Uncaught exception 'VMware_VCloud_SDK_Exception' with message 'POST https://10.170.232.44/api/v1.0/vApp/vapp-2091549350/action/recomposeVApp failed, return code: 400, error: <?xml version="1.0" encoding="UTF-8"?>
<Error xmlns="http://www.vmware.com/vcloud/v1" minorErrorCode="BAD_REQUEST" message="Unsupported instantiation section: {http://www.vmware.com/vcloud/v1}CustomizationSection" majorErrorCode="400" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.vmware.com/vcloud/v1http://10.170.232.44/api/v1.0/schema/master.xsd"></Error>
, request data:
<RecomposeVAppParams xmlns="http://www.vmware.com/vcloud/v1" xmlns:ovf="http://schemas.dmtf.org/ovf/envelope/1" xmlns:vcloud="http://www.vmware.com/vcloud/v1" xmlns:vmext="http://www.vmware.com/vcloud/extension/v1" xmlns:cim="http://schemas.dmtf.org/wbem/wscim/1/common" xmlns:rasd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_ResourceAllocationSettingData" xmlns:vssd="http://schemas.dmtf.org/wbem/wscim/1/cim-schema/2/CIM_V in /home/yconan/e2cdelta/trunk/lib/library/VMware/VCloud-1.0.0-314767/ServiceAbstract.php on line 142

 

we didn't have an "Invalid content was found starting with element " message but an "Unsupported instantiation" message.

 

does that mean the vapp recomposition will definitely unsupport the CustomizationSection ?

 


Is this the good method ? what is the good practice to change the root password on vm via the vcloud API (and more generally to implement a modified guestCustomizationSection) ?

 

Regards,

 

Yann CONAN


Viewing all articles
Browse latest Browse all 872

Trending Articles