mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 05:42:50 +00:00
Fix undefined variables, basestring usage, and some associated python3 issues
This commit is contained in:
@@ -240,12 +240,24 @@ EXAMPLES = '''
|
||||
register: rax
|
||||
'''
|
||||
|
||||
import os
|
||||
import json
|
||||
import re
|
||||
import time
|
||||
|
||||
try:
|
||||
import pyrax
|
||||
HAS_PYRAX = True
|
||||
except ImportError:
|
||||
HAS_PYRAX = False
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.rax import (FINAL_STATUSES, rax_argument_spec, rax_find_bootable_volume,
|
||||
rax_find_image, rax_find_network, rax_find_volume,
|
||||
rax_required_together, rax_to_dict, setup_rax_module)
|
||||
from ansible.module_utils.six.moves import xrange
|
||||
from ansible.module_utils.six import string_types
|
||||
|
||||
|
||||
def rax_find_server_image(module, server, image, boot_volume):
|
||||
if not image and boot_volume:
|
||||
@@ -515,7 +527,7 @@ def cloudservers(module, state=None, name=None, flavor=None, image=None,
|
||||
meta[k] = ','.join(['%s' % i for i in v])
|
||||
elif isinstance(v, dict):
|
||||
meta[k] = json.dumps(v)
|
||||
elif not isinstance(v, basestring):
|
||||
elif not isinstance(v, string_types):
|
||||
meta[k] = '%s' % v
|
||||
|
||||
# When using state=absent with group, the absent block won't match the
|
||||
@@ -890,11 +902,5 @@ def main():
|
||||
boot_volume_terminate=boot_volume_terminate)
|
||||
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import *
|
||||
from ansible.module_utils.rax import *
|
||||
|
||||
# invoke the module
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -131,7 +131,9 @@ except ImportError:
|
||||
def _activate_virtualenv(path):
|
||||
path = os.path.expanduser(path)
|
||||
activate_this = os.path.join(path, 'bin', 'activate_this.py')
|
||||
execfile(activate_this, dict(__file__=activate_this))
|
||||
with open(activate_this) as f:
|
||||
code = compile(f.read(), activate_this, 'exec')
|
||||
exec(code)
|
||||
|
||||
|
||||
def _get_node(lb, node_id=None, address=None, port=None):
|
||||
|
||||
@@ -74,12 +74,18 @@ EXAMPLES = '''
|
||||
region: DFW
|
||||
'''
|
||||
|
||||
import json
|
||||
|
||||
try:
|
||||
import pyrax
|
||||
HAS_PYRAX = True
|
||||
except ImportError:
|
||||
HAS_PYRAX = False
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.rax import rax_argument_spec, rax_required_together, setup_rax_module
|
||||
from ansible.module_utils.six import string_types
|
||||
|
||||
|
||||
def rax_meta(module, address, name, server_id, meta):
|
||||
changed = False
|
||||
@@ -128,7 +134,7 @@ def rax_meta(module, address, name, server_id, meta):
|
||||
meta[k] = ','.join(['%s' % i for i in v])
|
||||
elif isinstance(v, dict):
|
||||
meta[k] = json.dumps(v)
|
||||
elif not isinstance(v, basestring):
|
||||
elif not isinstance(v, string_types):
|
||||
meta[k] = '%s' % v
|
||||
|
||||
server = servers[0]
|
||||
@@ -175,11 +181,5 @@ def main():
|
||||
rax_meta(module, address, name, server_id, meta)
|
||||
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import *
|
||||
from ansible.module_utils.rax import *
|
||||
|
||||
### invoke the module
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
@@ -149,6 +149,9 @@ EXAMPLES = '''
|
||||
'''
|
||||
|
||||
import base64
|
||||
import json
|
||||
import os
|
||||
import time
|
||||
|
||||
try:
|
||||
import pyrax
|
||||
@@ -156,6 +159,11 @@ try:
|
||||
except ImportError:
|
||||
HAS_PYRAX = False
|
||||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.rax import (rax_argument_spec, rax_find_image, rax_find_network,
|
||||
rax_required_together, rax_to_dict, setup_rax_module)
|
||||
from ansible.module_utils.six import string_types
|
||||
|
||||
|
||||
def rax_asg(module, cooldown=300, disk_config=None, files={}, flavor=None,
|
||||
image=None, key_name=None, loadbalancers=[], meta={},
|
||||
@@ -189,7 +197,7 @@ def rax_asg(module, cooldown=300, disk_config=None, files={}, flavor=None,
|
||||
meta[k] = ','.join(['%s' % i for i in v])
|
||||
elif isinstance(v, dict):
|
||||
meta[k] = json.dumps(v)
|
||||
elif not isinstance(v, basestring):
|
||||
elif not isinstance(v, string_types):
|
||||
meta[k] = '%s' % v
|
||||
|
||||
if image:
|
||||
@@ -426,11 +434,5 @@ def main():
|
||||
state=state, config_drive=config_drive, user_data=user_data)
|
||||
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import *
|
||||
from ansible.module_utils.rax import *
|
||||
|
||||
# invoke the module
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user