[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
patchback[bot] 2025-01-22 20:51:20 +01:00 committed by GitHub
parent c72d8d4b56
commit ed472d8291
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 16 additions and 20 deletions

View File

@ -0,0 +1,2 @@
minor_changes:
- apache2_mod_proxy - refactor repeated code into method (https://github.com/ansible-collections/community.general/pull/9599).

View File

@ -302,6 +302,18 @@ class BalancerMember(object):
attributes = property(get_member_attributes)
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):
""" Apache httpd 2.4 mod_proxy balancer object"""
@ -388,16 +400,7 @@ def main():
if module.params['member_host'] is None:
json_output_list = []
for member in mybalancer.members:
json_output_list.append({
"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
})
json_output_list.append(member.as_dict())
module.exit_json(
changed=False,
members=json_output_list
@ -424,16 +427,7 @@ def main():
member_status_after = member_status
if member_status_before != member_status_after:
changed = True
json_output = {
"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
}
json_output = member.as_dict()
if member_exists:
module.exit_json(
changed=changed,