mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-29 20:39:09 -07:00
Pep8 fixes for ha_proxy module (#24090)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
This commit is contained in:
parent
3d4523f231
commit
ca7616b4a1
2 changed files with 11 additions and 18 deletions
|
@ -187,10 +187,12 @@ ACTION_CHOICES = ['enabled', 'disabled']
|
|||
WAIT_RETRIES = 25
|
||||
WAIT_INTERVAL = 5
|
||||
|
||||
|
||||
######################################################################
|
||||
class TimeoutException(Exception):
|
||||
pass
|
||||
|
||||
|
||||
class HAProxy(object):
|
||||
"""
|
||||
Used for communicating with HAProxy through its local UNIX socket interface.
|
||||
|
@ -237,7 +239,6 @@ class HAProxy(object):
|
|||
self.client.close()
|
||||
return result
|
||||
|
||||
|
||||
def capture_command_output(self, cmd, output):
|
||||
"""
|
||||
Capture the output for a command
|
||||
|
@ -249,7 +250,6 @@ class HAProxy(object):
|
|||
self.command_results['output'] = []
|
||||
self.command_results['output'].append(output)
|
||||
|
||||
|
||||
def discover_all_backends(self):
|
||||
"""
|
||||
Discover all entries with svname = 'BACKEND' and return a list of their corresponding
|
||||
|
@ -259,7 +259,6 @@ class HAProxy(object):
|
|||
r = csv.DictReader(data.splitlines())
|
||||
return tuple(map(lambda d: d['pxname'], filter(lambda d: d['svname'] == 'BACKEND', r)))
|
||||
|
||||
|
||||
def execute_for_backends(self, cmd, pxname, svname, wait_for_status=None):
|
||||
"""
|
||||
Run some command on the specified backends. If no backends are provided they will
|
||||
|
@ -282,7 +281,6 @@ class HAProxy(object):
|
|||
if self.wait:
|
||||
self.wait_until_status(backend, svname, wait_for_status)
|
||||
|
||||
|
||||
def get_state_for(self, pxname, svname):
|
||||
"""
|
||||
Find the state of specific services. When pxname is not set, get all backends for a specific host.
|
||||
|
@ -298,7 +296,6 @@ class HAProxy(object):
|
|||
)
|
||||
return state or None
|
||||
|
||||
|
||||
def wait_until_status(self, pxname, svname, status):
|
||||
"""
|
||||
Wait for a service to reach the specified status. Try RETRIES times
|
||||
|
@ -317,7 +314,6 @@ class HAProxy(object):
|
|||
|
||||
self.module.fail_json(msg="server %s/%s not status '%s' after %d retries. Aborting." % (pxname, svname, status, self.wait_retries))
|
||||
|
||||
|
||||
def enabled(self, host, backend, weight):
|
||||
"""
|
||||
Enabled action, marks server to UP and checks are re-enabled,
|
||||
|
@ -329,7 +325,6 @@ class HAProxy(object):
|
|||
cmd += "; set weight $pxname/$svname %s" % weight
|
||||
self.execute_for_backends(cmd, backend, host, 'UP')
|
||||
|
||||
|
||||
def disabled(self, host, backend, shutdown_sessions):
|
||||
"""
|
||||
Disabled action, marks server to DOWN for maintenance. In this mode, no more checks will be
|
||||
|
@ -341,7 +336,6 @@ class HAProxy(object):
|
|||
cmd += "; shutdown sessions server $pxname/$svname"
|
||||
self.execute_for_backends(cmd, backend, host, 'MAINT')
|
||||
|
||||
|
||||
def act(self):
|
||||
"""
|
||||
Figure out what you want to do from ansible, and then do it.
|
||||
|
@ -396,7 +390,7 @@ def main():
|
|||
ansible_haproxy.act()
|
||||
|
||||
# import module snippets
|
||||
from ansible.module_utils.basic import *
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
|
|
|
@ -498,7 +498,6 @@ lib/ansible/modules/network/f5/bigip_gtm_wide_ip.py
|
|||
lib/ansible/modules/network/f5/bigip_virtual_server.py
|
||||
lib/ansible/modules/network/fortios/fortios_config.py
|
||||
lib/ansible/modules/network/fortios/fortios_ipv4_policy.py
|
||||
lib/ansible/modules/net_tools/haproxy.py
|
||||
lib/ansible/modules/network/illumos/dladm_iptun.py
|
||||
lib/ansible/modules/network/illumos/dladm_linkprop.py
|
||||
lib/ansible/modules/network/ios/_ios_template.py
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue