[sdk]: Check instance error message
Hello there, Hope everything is going well. 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. Thanks and have a great day! Catherine
On 11/16/21 18:55, dmeng 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.
Haven't I answered this a week ago? Look in the archives
On Tue Nov 16 2021 09:55:32 GMT-0800 (Pacific Standard Time), dmeng <dmeng@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
On 11/17/21 23:20, melanie witt wrote:
On Tue Nov 16 2021 09:55:32 GMT-0800 (Pacific Standard Time), dmeng <dmeng@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.
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. '}
In my (not OP) case the problems were mostly python or sudo errors So journalctl still needed
participants (3)
-
dmeng
-
melanie witt
-
tjoen