vmware-archive / vcd-cli

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

vcd --json vapp info fails: "Object of type BoolElement is not JSON serializable" #517

Open chder opened 4 years ago

chder commented 4 years ago

After logging in, selecting a vdc, I'm getting this error trying to get vapp info as json.

# vcd version
vcd-cli, VMware vCloud Director Command Line Interface, 23.0.0
# vcd --json vapp info 'SomeVapp'
{
    "error": "Object of type BoolElement is not JSON serializable"
}

Omitting the --json, the only property that looks like it is a bool is is_shared_to_everyone False.

I'm on Fedora 31 and tested with the latest that pip3 install --upgrade --user vcd-cli provides.

It looks like this is using lxml https://github.com/vmware/vcd-cli/blob/4543c76d3a4988f049c293c80458bd8e9b66895e/vcd_cli/utils.py#L23 and it's likely the source of this BoolElement https://lxml.de/api/lxml.objectify.BoolElement-class.html

https://github.com/vmware/vcd-cli/blob/4543c76d3a4988f049c293c80458bd8e9b66895e/vcd_cli/utils.py#L171

chder commented 4 years ago

Looks like vcd --json vdc info is also similarly affected:

# vcd --json version
{
    "description": "VMware vCloud Director Command Line Interface",
    "product": "vcd-cli",
    "python": "3.7.6",
    "version": "23.0.0"
}

# vcd --json vdc info "some-vdc"
{
    "error": "Object of type StringElement is not JSON serializable"
}