Skip to content

Commit

Permalink
fix: Add lb_preferred_topology option to dtc:pools (#193)
Browse files Browse the repository at this point in the history
* fix: topology for dtc pools

* fix: trailing whitespace

* fix: better error handling
  • Loading branch information
jbisabel authored Nov 29, 2023
1 parent bd5df2d commit 0195dd8
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions plugins/modules/nios_dtc_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,12 @@
- TOPOLOGY
required: true
type: str
lb_preferred_topology:
description:
- Configures the topology rules for the C(TOPOLOGY) load balancing method.
- Required only when I(lb_preferred_method) is set to C(TOPOLOGY).
required: false
type: str
servers:
description:
- Configure the DTC Servers related to the pool
Expand Down Expand Up @@ -185,6 +191,16 @@ def monitors_transform(module):
monitor_list.append(monitor_obj[0]['_ref'])
return monitor_list

def topology_transform(module):
topology = module.params['lb_preferred_topology']
if topology:
topo_obj = wapi.get_object('dtc:topology', {'name': topology})
if topo_obj:
return topo_obj[0]['_ref']
else:
module.fail_json(
msg='topology %s cannot be found.' % topology)

servers_spec = dict(
server=dict(required=True),
ratio=dict(type='int', default=1)
Expand All @@ -203,6 +219,7 @@ def monitors_transform(module):
'RATIO',
'ROUND_ROBIN',
'TOPOLOGY']),
lb_preferred_topology=dict(type='str', transform=topology_transform),

servers=dict(type='list', elements='dict', options=servers_spec,
transform=servers_transform),
Expand Down

0 comments on commit 0195dd8

Please sign in to comment.