Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Fix] TCP Monitor and topology #205

Merged
merged 5 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions plugins/module_utils/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,11 @@ def get_object_ref(self, module, ib_obj_type, obj_filter, ib_spec):
except TypeError:
txt = obj_filter['text']
test_obj_filter['text'] = txt

# removing Port param from get params for NIOS_DTC_MONITOR_TCP
if (ib_obj_type == NIOS_DTC_MONITOR_TCP):
test_obj_filter = dict([('name', obj_filter['name'])])

# check if test_obj_filter is empty copy passed obj_filter
else:
test_obj_filter = obj_filter
Expand Down
3 changes: 2 additions & 1 deletion plugins/modules/nios_dtc_monitor_tcp.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
description:
- Configures the port value for TCP requests. The field is required on
creation.
required: true
type: int
interval:
description:
Expand Down Expand Up @@ -128,8 +129,8 @@ def main():

ib_spec = dict(
name=dict(required=True, ib_req=True),
port=dict(type='int', required=True, ib_req=True),

port=dict(type='int'),
interval=dict(type='int', default=5),
retry_down=dict(type='int', default=1),
retry_up=dict(type='int', default=1),
Expand Down
7 changes: 5 additions & 2 deletions plugins/modules/nios_dtc_topology.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,19 +185,22 @@ def sources_transform(sources, module):

def rules_transform(module):
rule_list = list()
dest_obj = None

if not module.params['rules']:
return rule_list

for rule in module.params['rules']:
if rule['dest_type'] == 'POOL':
dest_obj = wapi.get_object('dtc:pool', {'name': rule['destination_link']})
else:
dest_obj = wapi.get_object('dtc:server', {'name': rule['destination_link']})
if not dest_obj:
if not dest_obj and rule['return_type'] == 'REGULAR':
module.fail_json(msg='destination_link %s does not exist' % rule['destination_link'])

tf_rule = dict(
dest_type=rule['dest_type'],
destination_link=dest_obj[0]['_ref'],
destination_link=dest_obj[0]['_ref'] if dest_obj else None,
return_type=rule['return_type']
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- name: Clean up the DTC TCP monitor
infoblox.nios_modules.nios_dtc_monitor_tcp:
name: tcp_monitor
port: 8080
state: absent
provider: "{{ nios_provider }}"

Expand All @@ -35,6 +36,7 @@
- name: Add a comment to an existing DTC TCP monitor
infoblox.nios_modules.nios_dtc_monitor_tcp:
name: tcp_monitor
port: 8080
comment: this is a test comment
state: present
provider: "{{ nios_provider }}"
Expand All @@ -43,6 +45,7 @@
- name: Readd a comment to an existing DTC TCP monitor
infoblox.nios_modules.nios_dtc_monitor_tcp:
name: tcp_monitor
port: 8080
comment: this is a test comment
state: present
provider: "{{ nios_provider }}"
Expand All @@ -51,13 +54,15 @@
- name: Remove a DTC TCP monitor from the system
infoblox.nios_modules.nios_dtc_monitor_tcp:
name: tcp_monitor
port: 8080
state: absent
provider: "{{ nios_provider }}"
register: dtc_monitor_tcp_delete1

- name: Reremove a DTC TCP monitor from the system
infoblox.nios_modules.nios_dtc_monitor_tcp:
name: tcp_monitor
port: 8080
state: absent
provider: "{{ nios_provider }}"
register: dtc_monitor_tcp_delete2
Expand Down
Loading