diff --git a/cloud/virt b/cloud/virt index 8cbf7fc895a..3400c3ff727 100644 --- a/cloud/virt +++ b/cloud/virt @@ -36,7 +36,7 @@ options: since these refer only to VM states. After starting a guest, it may not be immediately accessible. required: false - choices: [ "running", "shutdown" ] + choices: [ "running", "shutdown", "destroyed", "paused" ] default: "no" command: description: @@ -416,13 +416,24 @@ def core(module): res['changed'] = False if state == 'running': - if v.status(guest) is not 'running': + if v.status(guest) is 'paused': + res['changed'] = True + res['msg'] = v.unpause(guest) + elif v.status(guest) is not 'running': res['changed'] = True res['msg'] = v.start(guest) elif state == 'shutdown': if v.status(guest) is not 'shutdown': res['changed'] = True res['msg'] = v.shutdown(guest) + elif state == 'destroyed': + if v.status(guest) is not 'shutdown': + res['changed'] = True + res['msg'] = v.destroy(guest) + elif state == 'paused': + if v.status(guest) is 'running': + res['changed'] = True + res['msg'] = v.pause(guest) else: module.fail_json(msg="unexpected state") @@ -461,7 +472,7 @@ def main(): module = AnsibleModule(argument_spec=dict( name = dict(aliases=['guest']), - state = dict(choices=['running', 'shutdown']), + state = dict(choices=['running', 'shutdown', 'destroyed', 'paused']), command = dict(choices=ALL_COMMANDS), uri = dict(default='qemu:///system'), xml = dict(),