Make consul modules pass sanity test for python 3
parent
d4157095f3
commit
2a83eefaae
|
@ -219,7 +219,7 @@ try:
|
||||||
import consul
|
import consul
|
||||||
from requests.exceptions import ConnectionError
|
from requests.exceptions import ConnectionError
|
||||||
python_consul_installed = True
|
python_consul_installed = True
|
||||||
except ImportError, e:
|
except ImportError:
|
||||||
python_consul_installed = False
|
python_consul_installed = False
|
||||||
|
|
||||||
def register_with_consul(module):
|
def register_with_consul(module):
|
||||||
|
@ -560,10 +560,10 @@ def main():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
register_with_consul(module)
|
register_with_consul(module)
|
||||||
except ConnectionError, e:
|
except ConnectionError as e:
|
||||||
module.fail_json(msg='Could not connect to consul agent at %s:%s, error was %s' % (
|
module.fail_json(msg='Could not connect to consul agent at %s:%s, error was %s' % (
|
||||||
module.params.get('host'), module.params.get('port'), str(e)))
|
module.params.get('host'), module.params.get('port'), str(e)))
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
module.fail_json(msg=str(e))
|
module.fail_json(msg=str(e))
|
||||||
|
|
||||||
# import module snippets
|
# import module snippets
|
||||||
|
|
|
@ -124,7 +124,7 @@ try:
|
||||||
import consul
|
import consul
|
||||||
from requests.exceptions import ConnectionError
|
from requests.exceptions import ConnectionError
|
||||||
python_consul_installed = True
|
python_consul_installed = True
|
||||||
except ImportError, e:
|
except ImportError:
|
||||||
python_consul_installed = False
|
python_consul_installed = False
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
@ -180,11 +180,11 @@ def update_acl(module):
|
||||||
token = consul.acl.create(
|
token = consul.acl.create(
|
||||||
name=name, type=token_type, rules=rules)
|
name=name, type=token_type, rules=rules)
|
||||||
changed = True
|
changed = True
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
module.fail_json(
|
module.fail_json(
|
||||||
msg="No token returned, check your managment key and that \
|
msg="No token returned, check your managment key and that \
|
||||||
the host is in the acl datacenter %s" % e)
|
the host is in the acl datacenter %s" % e)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
module.fail_json(msg="Could not create/update acl %s" % e)
|
module.fail_json(msg="Could not create/update acl %s" % e)
|
||||||
|
|
||||||
module.exit_json(changed=changed,
|
module.exit_json(changed=changed,
|
||||||
|
@ -216,7 +216,7 @@ def load_rules_for_token(module, consul_api, token):
|
||||||
for pattern, policy in rule_set[rule_type].iteritems():
|
for pattern, policy in rule_set[rule_type].iteritems():
|
||||||
rules.add_rule(rule_type, Rule(pattern, policy['policy']))
|
rules.add_rule(rule_type, Rule(pattern, policy['policy']))
|
||||||
return rules
|
return rules
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
module.fail_json(
|
module.fail_json(
|
||||||
msg="Could not load rule list from retrieved rule data %s, %s" % (
|
msg="Could not load rule list from retrieved rule data %s, %s" % (
|
||||||
token, e))
|
token, e))
|
||||||
|
@ -351,10 +351,10 @@ def main():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
execute(module)
|
execute(module)
|
||||||
except ConnectionError, e:
|
except ConnectionError as e:
|
||||||
module.fail_json(msg='Could not connect to consul agent at %s:%s, error was %s' % (
|
module.fail_json(msg='Could not connect to consul agent at %s:%s, error was %s' % (
|
||||||
module.params.get('host'), module.params.get('port'), str(e)))
|
module.params.get('host'), module.params.get('port'), str(e)))
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
module.fail_json(msg=str(e))
|
module.fail_json(msg=str(e))
|
||||||
|
|
||||||
# import module snippets
|
# import module snippets
|
||||||
|
|
|
@ -145,7 +145,7 @@ try:
|
||||||
import consul
|
import consul
|
||||||
from requests.exceptions import ConnectionError
|
from requests.exceptions import ConnectionError
|
||||||
python_consul_installed = True
|
python_consul_installed = True
|
||||||
except ImportError, e:
|
except ImportError:
|
||||||
python_consul_installed = False
|
python_consul_installed = False
|
||||||
|
|
||||||
from requests.exceptions import ConnectionError
|
from requests.exceptions import ConnectionError
|
||||||
|
@ -276,10 +276,10 @@ def main():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
execute(module)
|
execute(module)
|
||||||
except ConnectionError, e:
|
except ConnectionError as e:
|
||||||
module.fail_json(msg='Could not connect to consul agent at %s:%s, error was %s' % (
|
module.fail_json(msg='Could not connect to consul agent at %s:%s, error was %s' % (
|
||||||
module.params.get('host'), module.params.get('port'), str(e)))
|
module.params.get('host'), module.params.get('port'), str(e)))
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
module.fail_json(msg=str(e))
|
module.fail_json(msg=str(e))
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -137,7 +137,7 @@ try:
|
||||||
import consul
|
import consul
|
||||||
from requests.exceptions import ConnectionError
|
from requests.exceptions import ConnectionError
|
||||||
python_consul_installed = True
|
python_consul_installed = True
|
||||||
except ImportError, e:
|
except ImportError:
|
||||||
python_consul_installed = False
|
python_consul_installed = False
|
||||||
|
|
||||||
def execute(module):
|
def execute(module):
|
||||||
|
@ -185,7 +185,7 @@ def lookup_sessions(module):
|
||||||
session_id=session_id,
|
session_id=session_id,
|
||||||
sessions=session_by_id)
|
sessions=session_by_id)
|
||||||
|
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
module.fail_json(msg="Could not retrieve session info %s" % e)
|
module.fail_json(msg="Could not retrieve session info %s" % e)
|
||||||
|
|
||||||
|
|
||||||
|
@ -216,7 +216,7 @@ def update_session(module):
|
||||||
delay=delay,
|
delay=delay,
|
||||||
checks=checks,
|
checks=checks,
|
||||||
node=node)
|
node=node)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
module.fail_json(msg="Could not create/update session %s" % e)
|
module.fail_json(msg="Could not create/update session %s" % e)
|
||||||
|
|
||||||
|
|
||||||
|
@ -233,7 +233,7 @@ def remove_session(module):
|
||||||
|
|
||||||
module.exit_json(changed=True,
|
module.exit_json(changed=True,
|
||||||
session_id=session_id)
|
session_id=session_id)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
module.fail_json(msg="Could not remove session with id '%s' %s" % (
|
module.fail_json(msg="Could not remove session with id '%s' %s" % (
|
||||||
session_id, e))
|
session_id, e))
|
||||||
|
|
||||||
|
@ -270,10 +270,10 @@ def main():
|
||||||
|
|
||||||
try:
|
try:
|
||||||
execute(module)
|
execute(module)
|
||||||
except ConnectionError, e:
|
except ConnectionError as e:
|
||||||
module.fail_json(msg='Could not connect to consul agent at %s:%s, error was %s' % (
|
module.fail_json(msg='Could not connect to consul agent at %s:%s, error was %s' % (
|
||||||
module.params.get('host'), module.params.get('port'), str(e)))
|
module.params.get('host'), module.params.get('port'), str(e)))
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
module.fail_json(msg=str(e))
|
module.fail_json(msg=str(e))
|
||||||
|
|
||||||
# import module snippets
|
# import module snippets
|
||||||
|
|
|
@ -35,10 +35,6 @@
|
||||||
/cloud/misc/virt_pool.py
|
/cloud/misc/virt_pool.py
|
||||||
/cloud/profitbricks/profitbricks.py
|
/cloud/profitbricks/profitbricks.py
|
||||||
/cloud/profitbricks/profitbricks_volume.py
|
/cloud/profitbricks/profitbricks_volume.py
|
||||||
/clustering/consul.py
|
|
||||||
/clustering/consul_acl.py
|
|
||||||
/clustering/consul_kv.py
|
|
||||||
/clustering/consul_session.py
|
|
||||||
/database/mysql/mysql_replication.py
|
/database/mysql/mysql_replication.py
|
||||||
/database/vertica/vertica_configuration.py
|
/database/vertica/vertica_configuration.py
|
||||||
/database/vertica/vertica_facts.py
|
/database/vertica/vertica_facts.py
|
||||||
|
|
Loading…
Reference in New Issue