How do I suspend/resume a VM?

Asked by Jared Berghold

How do I suspend/resume a VM using the python openstacksdk module?

I can't find suspend/resume documented anywhere. Nor can I get reboot SOFT/HARD to work.

I've been looking at using something like conn.compute.update_server(server.id, action={"reboot": {"type": "SOFT"}}) but this doesn't seem to work.

Question information

Language:
English Edit question
Status:
Solved
For:
OpenStack SDK Edit question
Assignee:
No assignee Edit question
Solved by:
Jared Berghold
Solved:
Last query:
Last reply:
Revision history for this message
Jared Berghold (jared-9) said :
#1

Managed to suspend/resume and reboot using the code below, however, I discovered a bug that prevents it working correctly. Bug is #1509141

from openstack import connection

conn = connection.Connection(auth_url='https://keystone.rc.nectar.org.au:5000/v2.0/',
                             project_name='my_project_name',
                             username='my_username',
                             password='my_password')

actionBody = {"reboot": {"type": "SOFT"}}
#actionBody = {"suspend": None}
#actionBody = {"resume": None}

servers = conn.compute.servers(details=False, name="my_vm")

for server in servers:
    server.action(session=conn.session,body=actionBody)