Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

VCLOUD_STATUS_MAP table does not contain "Partially Powered Off" #780

Open
doug-baer opened this issue Sep 30, 2021 · 1 comment
Open

VCLOUD_STATUS_MAP table does not contain "Partially Powered Off" #780

doug-baer opened this issue Sep 30, 2021 · 1 comment

Comments

@doug-baer
Copy link

doug-baer commented Sep 30, 2021

A VM will return a status that is currently undefined in the pyvcloud VCLOUD_STATUS_MAP table… To be more specific, if I shut down a VM from within the Guest OS, the VM goes into a “Partially powered off” state in VCD (at least as of 10.3.0) .. the numeric code is 20

Since that value is not present in the VCLOUD_STATUS_MAP table, when calling _perform_power_operation() on the VM, it tosses an KeyError when attempting to raise the OperationNotSupportedException because that attempts to use power_state variable containing the 20 as the key into the table:

raise OperationNotSupportedException(
'Can't {0} vm. Current state of vm: {1}.'.format(
operation_name, VCLOUD_STATUS_MAP[power_state]))

I do not know if simply updating the VCLOUD_STATUS_MAP with this value is enough, but it is probably a start since that table is incomplete.

@doug-baer
Copy link
Author

as an example trace, when I shut down my VM within the guest OS and attempt to power it off, which I believe should be acceptable... it seems that we are raising OperationNotSupported, but I get a KeyError instead due to the missing key in the table.

my_vm.get_power_state()
Out[9]: 20
my_vm.is_powered_on()
Out[10]: False
my_vm.power_off()

Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyvcloud/vcd/client.py", line 1438, in post_linked_resource
find_link(resource, rel, media_type).href, contents,
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyvcloud/vcd/client.py", line 1740, in find_link
raise MissingLinkException(resource.get('href'), rel, media_type)
pyvcloud.vcd.exceptions.MissingLinkException: ('https://az1-vcd01.oc.vmware.com/api/vApp/vm-c323ea04-2db2-4574-8922-daf2b4168894', <RelationType.POWER_OFF: 'power:powerOff'>, None); href: https://az1-vcd01.oc.vmware.com/api/vApp/vm-c323ea04-2db2-4574-8922-daf2b4168894, rel: RelationType.POWER_OFF, mediaType: None
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyvcloud/vcd/vm.py", line 390, in _perform_power_operation
media_type, contents)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyvcloud/vcd/client.py", line 1442, in post_linked_resource
"Operation is not supported").with_traceback(e.traceback)
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyvcloud/vcd/client.py", line 1438, in post_linked_resource
find_link(resource, rel, media_type).href, contents,
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyvcloud/vcd/client.py", line 1740, in find_link
raise MissingLinkException(resource.get('href'), rel, media_type)
pyvcloud.vcd.exceptions.OperationNotSupportedException: Operation is not supported
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/IPython/core/interactiveshell.py", line 3427, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 1, in
vms['Main Console'].power_off()
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyvcloud/vcd/vm.py", line 439, in power_off
rel=RelationType.POWER_OFF, operation_name='power off')
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/pyvcloud/vcd/vm.py", line 395, in _perform_power_operation
operation_name, VCLOUD_STATUS_MAP[power_state]))
KeyError: 20

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant