vcd-cli
vcd-cli copied to clipboard
Error when invoking update-gc-section for customization script
I am trying to upload a customization script using vcd and I am getting the error below. I have tried multiple ways of writing the command. Putting the vapp and vm before and after the options provides the same result.
vcd vm update-gc-section --enable --customization-script "touch" vapp1 test1
Usage: vcd vm update-gc-section [OPTIONS]
Error: Status code: 400/BAD_REQUEST, [ 11d7df7e-de3d-440c-8ec2-00ccd64b95e4 ] HTTP 400 Bad Request
- cvc-complex-type.2.4.a: Invalid content was found starting with element 'CustomizationScript'. One of '{"http://www.vmware.com/vcloud/v1.5":Link, WC[##other:"http://www.vmware.com/vcloud/v1.5"]}' is expected. (request id: 11d7df7e-de3d-440c-8ec2-00ccd64b95e4)
This is looking for a file name on the local filesystem from where I was running vcd-cli. That was not clear in reading the instructions.
The test I made earlier using the filename was invalid. The VM wasn't brand new and it just set the script to the text of the filename.
When running this against a brand new VM I get the following error:
$./vcd vm update-gc-section vapp1 test1 --customization-script "$(cat gc-script.sh)"
Usage: vcd vm update-gc-section [OPTIONS]
Error: Status code: 400/BAD_REQUEST, [ 8f2e6e3b-08c9-4890-bbef-d400a589f84c ] HTTP 400 Bad Request
- cvc-complex-type.2.4.a: Invalid content was found starting with element 'CustomizationScript'. One of '{"http://www.vmware.com/vcloud/v1.5":Link, WC[##other:"http://www.vmware.com/vcloud/v1.5"]}' is expected. (request id: 8f2e6e3b-08c9-4890-bbef-d400a589f84c)
If I go into the UI and type a word into the script dialog, hit save, and then run the same thing again it succeeds.
$ ./vcd vm update-gc-section vapp1 test1 --customization-script "$(cat gc-script.sh)" vappUpdateVm: Updating Virtual Machine test1(ca86d489-4ee5-46b8-a682-eaeead61ca49) task: 355b06e6-048e-47b8-99e9-b838bb8a4a76, Updated Virtual Machine test1(ca86d489-4ee5-46b8-a682-eaeead61ca49), result: success
I am wondering if the script needs to be formatted in some way initially?
In reading the API documentation it seems to state it needs to URL encoded?
https://www.vmware.com/support/vcd/doc/rest-api-doc-1.5-html/types/GuestCustomizationSectionType.html