[sdk]: Check instance error message

melanie witt melwittt at gmail.com
Wed Nov 17 22:20:41 UTC 2021


On Tue Nov 16 2021 09:55:32 GMT-0800 (Pacific Standard Time), dmeng 
<dmeng at uvic.ca> wrote:
> I'm wondering if there is any method that could check the error message 
> of an instance whose status is "ERROR"? Like from openstack cli, 
> "openstack server show server_name", if the server is in "ERROR" status, 
> this will return a field "fault" with a message shows the error. I tried 
> the compute service get_server and find_server, but neither of them show 
> the error messages of an instance.

Hi, it looks like currently the sdk doesn't have the 'fault' field in 
the Server model [1] so AFAICT you can't get the fault message 
out-of-the-box. A patch upstream will be needed to add it.

This can be hacked around by, for example:

import openstack
from openstack.compute.v2 import server
from openstack import resource


class MyServer(server.Server):
     fault = resource.Body('fault', type=dict)


conn = openstack.connect(cloud='devstack')
s = conn.compute._get(MyServer, '9282db95-801f-4f43-90fb-e86d9bfb6785')
s.fault
{'code': 500, 'created': '2021-09-17T02:23:16Z', 'message': 'No valid 
host was found. '}

HTH,
-melanie

[1] https://docs.openstack.org/openstacksdk/latest/user/model.html#server



More information about the openstack-discuss mailing list