Question

Nutanix clone VM api and unattend.xml

  • 26 June 2018
  • 4 replies
  • 8219 views

Need some pointers on how to add unattend.xml to API for VM customization.

"uuid": "string",
"vm_customization_config": {
"datasource_type": "CONFIG_DRIVE_V2",
"files_to_inject_list": [
{
"destination_path": "string",
"source_path": "string"
}

4 replies

Userlevel 3
Badge +12
@RaphaelBubble the spec list the body of the request. An example with curl will look like this

Replace , with the uuid of the vm to clone and with your custom spec.
code:
curl -k -s -u admin https://:9440/api/nutanix/v2/PrismGateway/services/rest/v2.0/vms//clone --header "accept:application/json" --header "Content-type:application/json" -d ''
Hello

Do you have a fully example on how to put directly the XML file in the API call? I don't get where "spec_list" should go

Thanks 😃

Raphaël
Userlevel 3
Badge +12
the XML spec is getting modified when i post it as reply in the forum.
Userlevel 3
Badge +12
@manubalasree

if you are not specifically looking to upload as a file you can use like below,

You can use http://jagt.github.io/python-single-line-convert/ to convert multi-line xml file to single line

code:
{"spec_list":[
{"name":"windows2016"}
],
"vm_customization_config":
{
"userdata": "\n\n \n \n en-US\n en-US\n en-US\n en-US\n en-US\n \n \n \n \n bgB1AHQAYQBuAGkAeAAvADQAdQBQAGEAcwBzAHcAbwByAGQA\n false</PlainText>\n </Password>\n <Enabled>true</Enabled>\n <Username>Administrator</Username>\n </AutoLogon>\n <OOBE>\n <HideEULAPage>true</HideEULAPage>\n <HideLocalAccountScreen>true</HideLocalAccountScreen>\n <HideOEMRegistrationScreen>true</HideOEMRegistrationScreen>\n <NetworkLocation>Work</NetworkLocation>\n <SkipMachineOOBE>true</SkipMachineOOBE>\n <SkipUserOOBE>true</SkipUserOOBE>\n </OOBE>\n <UserAccounts>\n <AdministratorPassword>\n <Value>bgB1AHQAYQBuAGkAeAAvADQAdQBBAGQAbQBpAG4AaQBzAHQAcgBhAHQAbwByAFAAYQBzAHMAdwBvAHIAZAA=</Value>\n <PlainText>false</PlainText>\n </AdministratorPassword>\n </UserAccounts>\n </component>\n </settings>\n <settings pass="specialize">\n <component name="Microsoft-Windows-Shell-Setup" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\n <ComputerName>RobClone-@@{calm_random}@@</ComputerName>\n <RegisteredOwner>Nutanix</RegisteredOwner>\n </component>\n <component name="Microsoft-Windows-UnattendedJoin" processorArchitecture="amd64" publicKeyToken="31bf3856ad364e35" language="neutral" versionScope="nonSxS" xmlns:wcm="http://schemas.microsoft.com/WMIConfig/2002/State" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">\n <Identification>\n <Credentials>\n <Domain>tsapac.local</Domain>\n <Password>nutanix/4u</Password>\n <Username>administrator</Username>\n </Credentials>\n <JoinDomain>tsapac.local</JoinDomain>\n </Identification>\n </component>\n </settings>\n <cpi:offlineImage cpi:source="wim:f:/install.wim#Windows Server 2016 SERVERSTANDARD" xmlns:cpi="urn:schemas-microsoft-com:cpi" ></cpi:offlineImage>\n</unattend>"
}
}

&lt;/pre&gt;</plaintext></password></autologon></component></settings></unattend></pre>

Reply