vmware-archive / vcd-cli

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

Error when invoking update-gc-section for customization script #508

Open mikelitka opened 4 years ago

mikelitka commented 4 years ago

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] Try "vcd vm update-gc-section -h" for help.

Error: Status code: 400/BAD_REQUEST, [ 11d7df7e-de3d-440c-8ec2-00ccd64b95e4 ] HTTP 400 Bad Request

mikelitka commented 4 years ago

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.

mikelitka commented 4 years ago

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] Try "vcd vm update-gc-section -h" for help.

Error: Status code: 400/BAD_REQUEST, [ 8f2e6e3b-08c9-4890-bbef-d400a589f84c ] HTTP 400 Bad Request

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