mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-10-08 17:34:01 -07:00
Fix undefined variables, basestring usage, and some associated python3 issues
This commit is contained in:
parent
9f7b0dfc30
commit
225fa5d092
84 changed files with 652 additions and 963 deletions
|
@ -89,6 +89,9 @@ try:
|
|||
except ImportError:
|
||||
HAS_SHADE = False
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.openstack import openstack_full_argument_spec, openstack_module_kwargs
|
||||
|
||||
|
||||
_action_map = {'stop': 'SHUTOFF',
|
||||
'start': 'ACTIVE',
|
||||
|
@ -102,7 +105,7 @@ _action_map = {'stop': 'SHUTOFF',
|
|||
|
||||
_admin_actions = ['pause', 'unpause', 'suspend', 'resume', 'lock', 'unlock']
|
||||
|
||||
def _wait(timeout, cloud, server, action):
|
||||
def _wait(timeout, cloud, server, action, module):
|
||||
"""Wait for the server to reach the desired state for the given action."""
|
||||
|
||||
for count in shade._utils._iterate_timeout(
|
||||
|
@ -166,7 +169,7 @@ def main():
|
|||
|
||||
cloud.nova_client.servers.stop(server=server.id)
|
||||
if wait:
|
||||
_wait(timeout, cloud, server, action)
|
||||
_wait(timeout, cloud, server, action, module)
|
||||
module.exit_json(changed=True)
|
||||
|
||||
if action == 'start':
|
||||
|
@ -175,7 +178,7 @@ def main():
|
|||
|
||||
cloud.nova_client.servers.start(server=server.id)
|
||||
if wait:
|
||||
_wait(timeout, cloud, server, action)
|
||||
_wait(timeout, cloud, server, action, module)
|
||||
module.exit_json(changed=True)
|
||||
|
||||
if action == 'pause':
|
||||
|
@ -184,7 +187,7 @@ def main():
|
|||
|
||||
cloud.nova_client.servers.pause(server=server.id)
|
||||
if wait:
|
||||
_wait(timeout, cloud, server, action)
|
||||
_wait(timeout, cloud, server, action, module)
|
||||
module.exit_json(changed=True)
|
||||
|
||||
elif action == 'unpause':
|
||||
|
@ -193,7 +196,7 @@ def main():
|
|||
|
||||
cloud.nova_client.servers.unpause(server=server.id)
|
||||
if wait:
|
||||
_wait(timeout, cloud, server, action)
|
||||
_wait(timeout, cloud, server, action, module)
|
||||
module.exit_json(changed=True)
|
||||
|
||||
elif action == 'lock':
|
||||
|
@ -212,7 +215,7 @@ def main():
|
|||
|
||||
cloud.nova_client.servers.suspend(server=server.id)
|
||||
if wait:
|
||||
_wait(timeout, cloud, server, action)
|
||||
_wait(timeout, cloud, server, action, module)
|
||||
module.exit_json(changed=True)
|
||||
|
||||
elif action == 'resume':
|
||||
|
@ -221,7 +224,7 @@ def main():
|
|||
|
||||
cloud.nova_client.servers.resume(server=server.id)
|
||||
if wait:
|
||||
_wait(timeout, cloud, server, action)
|
||||
_wait(timeout, cloud, server, action, module)
|
||||
module.exit_json(changed=True)
|
||||
|
||||
elif action == 'rebuild':
|
||||
|
@ -233,14 +236,12 @@ def main():
|
|||
# rebuild doesn't set a state, just do it
|
||||
cloud.nova_client.servers.rebuild(server=server.id, image=image.id)
|
||||
if wait:
|
||||
_wait(timeout, cloud, server, action)
|
||||
_wait(timeout, cloud, server, action, module)
|
||||
module.exit_json(changed=True)
|
||||
|
||||
except shade.OpenStackCloudException as e:
|
||||
module.fail_json(msg=str(e), extra_data=e.extra_data)
|
||||
|
||||
# this is magic, see lib/ansible/module_common.py
|
||||
from ansible.module_utils.basic import *
|
||||
from ansible.module_utils.openstack import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue