vmware-archive / vcd-cli

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

Problems with spaces (%2520) in name of catalog or firewall #520

Open fnoorden-vs opened 4 years ago

fnoorden-vs commented 4 years ago

I found the following problems with spaces in name of catalog or firewall:

This command is OK: vcd gateway services firewall list Transit-VE004 ID name ruleType


131074 firewall internal_high 133123 highAvailability internal_high 131073 default rule for ingress traffic default_policy

This command gives an ERROR: vcd gateway services firewall list "V Internet Firewall" Usage: vcd gateway services firewall list [OPTIONS] Try "vcd gateway services firewall list -h" for help.

Error: 'x-vmware-vcloud-request-id'

The resulting URL according to vcd.log: Request uri (GET): https://some_url/api/query?type=edgeGateway&format=records&page=1&filterEncoded=true&filter=name%3D%3DV%2520Internet%2520Firewall Request headers: {'User-Agent': 'python-requests/2.22.0', 'Accept-Encoding': 'gzip, deflate', 'Accept': 'application/*+xml;version=32.0', 'Connection': 'keep-alive', 'x-vcloud-authorization': '[REDACTED]'} Response status code: 500

It seems that the url is encoded twice, giving an erroneous result with spaces becoming %2520.

This problem seems to be equal to https://github.com/vmware/vcd-cli/issues/114, but this ticket gives more info about the problem.

fnoorden-vs commented 4 years ago

Solution: I have changed the following statement in pyvcloud/vcd/client.py: uri += urllib.parse.quote(qfilter) to uri += qfilter

Now everything works.

fnoorden-vs commented 4 years ago

Better keep it open, it should be solved in the code,