Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ Usage
servers = await nova.servers.list(name='testvm')
vm = await nova.servers.get(server_id)

action_spec = {'os-stop': None}
await nova.servers.run_action(server_id, **action_spec)

@evemorgen evemorgen Aug 17, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I'm missing the point, but I don't think unpacking action_spec to kwargs is desirable behavior here. Maybe you meant action=action_spec as stated later?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that await nova.servers.run_action(server_id, os-stop=None) is not valid Python. Unpacking does the trick. Somehow ugly, but the only way to send {'os-stop': null} to OpenStack.

@evemorgen evemorgen Aug 18, 2018

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha, I though it would be similar to volumes api, that you pass whole chunk to one action kwarg or something, didn't read the docs tho 😉 Looks good to me then



specs = {
"name": 'some_name',
Expand Down Expand Up @@ -87,6 +90,7 @@ Available functions
- servers.get(id)
- servers.create(server=server_spec)
- servers.force_delete(id)
- servers.run_action(id, action=action_spec)
- flavors.list()
- metadata.get(server_id)
- metadata.set(server_id, meta=meta_spec)
Expand Down
2 changes: 2 additions & 0 deletions src/asyncopenstackclient/nova.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ async def init_api(self, timeout=60):
self.api.servers.actions["force_delete"] = {"method": "DELETE", "url": "servers/{}"}
self.api.servers.actions["get"] = {"method": "GET", "url": "servers/{}"}
self.api.servers.actions["list"] = {"method": "GET", "url": "servers/detail"}
self.api.servers.actions["run_action"] = {"method": "POST", "url": "servers/{}/action"}
self.api.servers.add_action("force_delete")
self.api.servers.add_action("get")
self.api.servers.add_action("run_action")
self.api.flavors.actions["list"] = {"method": "GET", "url": "flavors/detail"}
self.api.metadata.actions['get'] = {"method": "GET", "url": "servers/{}/metadata"}
self.api.metadata.actions['set'] = {"method": "POST", "url": "servers/{}/metadata"}
Expand Down