pyvcloud
pyvcloud copied to clipboard
Unable to get VDC vAPPs by name due to characters within vAPP name
Unable to use get_vapp in pyvcloud.vcd.vdc.VDC when vAPP names contain opening parenthesis without a closing parenthesis.
Example exception: pyvcloud.vcd.vdc.VDC.get_vapp('Discovered VM Name (')
Exception: %sStatus code: 400/BAD_REQUEST, Bad request: Unmatched opening and closing brackets in expression vdc==https://-vCD URI-/api/vdc/-vdc uuid-;name==Discovered VM Name (. (request id: -uuid-)
IMHO, this is rather a bug in vCloud (server-side) than from the pyvcloud module. In pyvcloud the query filter is correctly encoded using urllib.parse.quote(). Have you already opened a ticket at VMware support?
Having a similar problem: pyvcloud.vcd.vdc.get_vapp_href(vapp_name) Generates the same exception, when vapp_name contains opening parenthesis without a closing parenthesis.
A little workaround helped me: parsing vapp href from API response when getting a VDC resource.
+1, hitting this problem through vcd-cli
IMHO, this is rather a bug in vCloud (server-side) than from the pyvcloud module. In pyvcloud the query filter is correctly encoded using
urllib.parse.quote(). Have you already opened a ticket at VMware support?
Upd. The cause of the error is the function "def _escape_special_characters(self, single_encoded_value_string):" in module "client.py". This causes escaping of parentheses, both opening and closing. After disabling parenthesis escaping the error does not appear.