[PR #9599/1c0b487b backport][stable-10] apache2-mod-proxy: refactor BalancerMember serialization (#9607)
apache2-mod-proxy: refactor BalancerMember serialization (#9599)
* apache2-mod-proxy: refactor BalancerMember serialization
* add changelog frag
(cherry picked from commit 1c0b487b41
)
Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
pull/9610/head
parent
c72d8d4b56
commit
ed472d8291
|
@ -0,0 +1,2 @@
|
||||||
|
minor_changes:
|
||||||
|
- apache2_mod_proxy - refactor repeated code into method (https://github.com/ansible-collections/community.general/pull/9599).
|
|
@ -302,6 +302,18 @@ class BalancerMember(object):
|
||||||
attributes = property(get_member_attributes)
|
attributes = property(get_member_attributes)
|
||||||
status = property(get_member_status, set_member_status)
|
status = property(get_member_status, set_member_status)
|
||||||
|
|
||||||
|
def as_dict(self):
|
||||||
|
return {
|
||||||
|
"host": self.host,
|
||||||
|
"status": self.status,
|
||||||
|
"protocol": self.protocol,
|
||||||
|
"port": self.port,
|
||||||
|
"path": self.path,
|
||||||
|
"attributes": self.attributes,
|
||||||
|
"management_url": self.management_url,
|
||||||
|
"balancer_url": self.balancer_url
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class Balancer(object):
|
class Balancer(object):
|
||||||
""" Apache httpd 2.4 mod_proxy balancer object"""
|
""" Apache httpd 2.4 mod_proxy balancer object"""
|
||||||
|
@ -388,16 +400,7 @@ def main():
|
||||||
if module.params['member_host'] is None:
|
if module.params['member_host'] is None:
|
||||||
json_output_list = []
|
json_output_list = []
|
||||||
for member in mybalancer.members:
|
for member in mybalancer.members:
|
||||||
json_output_list.append({
|
json_output_list.append(member.as_dict())
|
||||||
"host": member.host,
|
|
||||||
"status": member.status,
|
|
||||||
"protocol": member.protocol,
|
|
||||||
"port": member.port,
|
|
||||||
"path": member.path,
|
|
||||||
"attributes": member.attributes,
|
|
||||||
"management_url": member.management_url,
|
|
||||||
"balancer_url": member.balancer_url
|
|
||||||
})
|
|
||||||
module.exit_json(
|
module.exit_json(
|
||||||
changed=False,
|
changed=False,
|
||||||
members=json_output_list
|
members=json_output_list
|
||||||
|
@ -424,16 +427,7 @@ def main():
|
||||||
member_status_after = member_status
|
member_status_after = member_status
|
||||||
if member_status_before != member_status_after:
|
if member_status_before != member_status_after:
|
||||||
changed = True
|
changed = True
|
||||||
json_output = {
|
json_output = member.as_dict()
|
||||||
"host": member.host,
|
|
||||||
"status": member.status,
|
|
||||||
"protocol": member.protocol,
|
|
||||||
"port": member.port,
|
|
||||||
"path": member.path,
|
|
||||||
"attributes": member.attributes,
|
|
||||||
"management_url": member.management_url,
|
|
||||||
"balancer_url": member.balancer_url
|
|
||||||
}
|
|
||||||
if member_exists:
|
if member_exists:
|
||||||
module.exit_json(
|
module.exit_json(
|
||||||
changed=changed,
|
changed=changed,
|
||||||
|
|
Loading…
Reference in New Issue