mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-23 13:20:23 -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
|
@ -147,15 +147,12 @@ url_map:
|
|||
'''
|
||||
|
||||
|
||||
try:
|
||||
from ast import literal_eval
|
||||
HAS_PYTHON26 = True
|
||||
except ImportError:
|
||||
HAS_PYTHON26 = False
|
||||
from ast import literal_eval
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.gcp import check_params, get_google_api_client, GCPUtils
|
||||
from ansible.module_utils.six import string_types
|
||||
|
||||
|
||||
USER_AGENT_PRODUCT = 'ansible-url_map'
|
||||
USER_AGENT_VERSION = '0.0.1'
|
||||
|
@ -258,7 +255,7 @@ def _validate_host_rules_params(host_rules):
|
|||
try:
|
||||
check_params(hr, fields)
|
||||
for host in hr['hosts']:
|
||||
if not isinstance(host, basestring):
|
||||
if not isinstance(host, string_types):
|
||||
raise ValueError("host in hostrules must be a string")
|
||||
elif '*' in host:
|
||||
if host.index('*') != 0:
|
||||
|
@ -459,10 +456,6 @@ def main():
|
|||
project_id=dict(), ), required_together=[
|
||||
['path_matchers', 'host_rules'], ])
|
||||
|
||||
if not HAS_PYTHON26:
|
||||
module.fail_json(
|
||||
msg="GCE module requires python's 'ast' module, python v2.6+")
|
||||
|
||||
client, conn_params = get_google_api_client(module, 'compute', user_agent_product=USER_AGENT_PRODUCT,
|
||||
user_agent_version=USER_AGENT_VERSION)
|
||||
|
||||
|
@ -515,5 +508,6 @@ def main():
|
|||
json_output.update(params)
|
||||
module.exit_json(**json_output)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -139,6 +139,7 @@ except ImportError as e:
|
|||
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils.gcp import check_min_pkg_version, get_google_cloud_credentials
|
||||
from ansible.module_utils.six import string_types
|
||||
|
||||
CLOUD_CLIENT = 'google-cloud-spanner'
|
||||
CLOUD_CLIENT_MINIMUM_VERSION = '0.23.0'
|
||||
|
@ -169,7 +170,7 @@ def instance_update(instance):
|
|||
errmsg = 'node_count must be an integer %s (%s)' % (
|
||||
instance.node_count, type(instance.node_count))
|
||||
if instance.display_name and not isinstance(instance.display_name,
|
||||
basestring):
|
||||
string_types):
|
||||
errmsg = 'instance_display_name must be an string %s (%s)' % (
|
||||
instance.display_name, type(instance.display_name))
|
||||
if errmsg:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue