1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Rename consul variable to consul_client

Since the module is also named consul, pyflakes emit a warning
about it since the variable shadow the module.
This commit is contained in:
Michael Scherer 2016-02-24 12:15:02 +01:00 committed by Matt Clay
parent 78571c053b
commit fabd619070

View file

@ -136,10 +136,10 @@ def lookup_sessions(module):
datacenter = module.params.get('datacenter') datacenter = module.params.get('datacenter')
state = module.params.get('state') state = module.params.get('state')
consul = get_consul_api(module) consul_client = get_consul_api(module)
try: try:
if state == 'list': if state == 'list':
sessions_list = consul.session.list(dc=datacenter) sessions_list = consul_client.session.list(dc=datacenter)
#ditch the index, this can be grabbed from the results #ditch the index, this can be grabbed from the results
if sessions_list and sessions_list[1]: if sessions_list and sessions_list[1]:
sessions_list = sessions_list[1] sessions_list = sessions_list[1]
@ -150,7 +150,7 @@ def lookup_sessions(module):
if not node: if not node:
module.fail_json( module.fail_json(
msg="node name is required to retrieve sessions for node") msg="node name is required to retrieve sessions for node")
sessions = consul.session.node(node, dc=datacenter) sessions = consul_client.session.node(node, dc=datacenter)
module.exit_json(changed=True, module.exit_json(changed=True,
node=node, node=node,
sessions=sessions) sessions=sessions)
@ -160,7 +160,7 @@ def lookup_sessions(module):
module.fail_json( module.fail_json(
msg="session_id is required to retrieve indvidual session info") msg="session_id is required to retrieve indvidual session info")
session_by_id = consul.session.info(session_id, dc=datacenter) session_by_id = consul_client.session.info(session_id, dc=datacenter)
module.exit_json(changed=True, module.exit_json(changed=True,
session_id=session_id, session_id=session_id,
sessions=session_by_id) sessions=session_by_id)
@ -178,12 +178,12 @@ def update_session(module):
datacenter = module.params.get('datacenter') datacenter = module.params.get('datacenter')
node = module.params.get('node') node = module.params.get('node')
consul = get_consul_api(module) consul_client = get_consul_api(module)
changed = True changed = True
try: try:
session = consul.session.create( session = consul_client.session.create(
name=name, name=name,
node=node, node=node,
lock_delay=validate_duration('delay', delay), lock_delay=validate_duration('delay', delay),
@ -207,11 +207,11 @@ def remove_session(module):
module.fail_json(msg="""A session id must be supplied in order to module.fail_json(msg="""A session id must be supplied in order to
remove a session.""") remove a session.""")
consul = get_consul_api(module) consul_client = get_consul_api(module)
changed = False changed = False
try: try:
session = consul.session.destroy(session_id) session = consul_client.session.destroy(session_id)
module.exit_json(changed=True, module.exit_json(changed=True,
session_id=session_id) session_id=session_id)