Ask Your Question

How to get instance_action from python-novaclient?

asked 2015-04-02 07:57:49 -0500

Lera gravatar image

I have find code to get from novaclient.v2 instance_action.list, but this do not work:

 from novaclient.v2 import client as nova_v2
 nova=nova_v2.Client("*****", "**********", "*********", "*****************")
 server = nova.servers.get('8322c5d8-b925-0091-bbff-dac361260b50')

I have next mistake:

AttributeError: 'Client' object has no attribute 'instance_action'

How I can get this Instance_action?? Thank you!

edit retag flag offensive close merge delete

2 answers

Sort by » oldest newest most voted

answered 2015-04-02 09:59:57 -0500

Ranjit gravatar image

updated 2015-04-02 10:00:36 -0500

There is no API instance_action() for nova object.

you have to use REST API mentioned in the .

API: /v2.1/servers/​{server_id}​/os-instance-actions

get the keystone token and call curl request.

curl request: 
curl -H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token:TOKEN" http://openstackJuno:8774/v2/TENANT_ID/servers/SERVER_ID/os-instance-actions

curl -H "Content-Type: application/json" -H "Accept: application/json" -H "X-Auth-Token:139737f049f14acaaa6cee278a4c45f8" http://openstackJuno:8774/v2/1d4bc7c6d14b4e01b85e906e3dcce806/servers/0ee0b42e-cd2f-46c6-8038-f9c2e0359dcc/os-instance-actions  | python -m json.tool

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   611  100   611    0     0  10461      0 --:--:-- --:--:-- --:--:-- 10534
    "instanceActions": [
            "action": "reboot",
            "instance_uuid": "0ee0b42e-cd2f-46c6-8038-f9c2e0359dcc",
            "message": null,
            "project_id": "1d4bc7c6d14b4e01b85e906e3dcce806",
            "request_id": "req-2eccb5d4-c2d8-461f-8bf6-a1fd7440a92f",
            "start_time": "2015-04-02T14:21:23.000000",
            "user_id": "fb611d3c2c554b258d8c2f9dd88fbed0"
            "action": "create",
            "instance_uuid": "0ee0b42e-cd2f-46c6-8038-f9c2e0359dcc",
            "message": null,
            "project_id": "1d4bc7c6d14b4e01b85e906e3dcce806",
            "request_id": "req-6d255b38-b70e-4096-9cf6-a60f0f53dab3",
            "start_time": "2015-04-01T07:21:36.000000",
            "user_id": "fb611d3c2c554b258d8c2f9dd88fbed0"
edit flag offensive delete link more


But how can I get it using Python?

Lera gravatar imageLera ( 2015-04-07 02:27:57 -0500 )edit

answered 2016-04-12 15:23:51 -0500

zarkone gravatar image

updated 2016-07-15 00:33:17 -0500

To use it from Python, you need to plug extension (because it's from contrib, as I understood):

from novaclient import extension
from novaclient.v2.contrib import instance_action

ia_extensions = [
nova = client.Client(some,auth,params,


Also: (example usage in test for novaclient) (source code)

edit flag offensive delete link more

Get to know Ask OpenStack

Resources for moderators

Question Tools

1 follower


Asked: 2015-04-02 07:57:49 -0500

Seen: 1,057 times

Last updated: Jul 15 '16