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 ios_service issues #1068

Merged
merged 10 commits into from
May 13, 2024
4 changes: 4 additions & 0 deletions changelogs/fragments/ios_service_fix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
bugfixes:
- ios_service - Fix timestamps attribute, to generate right configuration.
- ios_service - Add tcp_small_servers and udp_small_servers attributes, to generate configuration.
61 changes: 52 additions & 9 deletions docs/cisco.ios.ios_service_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Parameters
<td>
</td>
<td>
<div>A dictionnary of service configuration</div>
<div>A dictionary of service configuration</div>
</td>
</tr>
<tr>
Expand Down Expand Up @@ -658,7 +658,7 @@ Parameters
<td>
</td>
<td>
<div>TCP and UDP small servers are servers (daemons, in Unix parlance) that run in the router which are useful for diagnostics.</div>
<div>TCP small servers are servers (daemons, in Unix parlance) that run in the router which are useful for diagnostics.</div>
</td>
</tr>
<tr>
Expand Down Expand Up @@ -690,14 +690,35 @@ Parameters
<b>max_servers</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
<span style="color: purple">integer</span>
</div>
</td>
<td>
</td>
<td>
<div>Set number of allowable TCP small servers</div>
<div>1 to 2147483647 or no-limit</div>
<div>1 to 2147483647</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td class="elbow-placeholder"></td>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>no_limit</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">boolean</span>
</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li>no</li>
<li>yes</li>
</ul>
</td>
<td>
<div>No limit on number of allowable TCP small servers</div>
</td>
</tr>

Expand Down Expand Up @@ -921,7 +942,7 @@ Parameters
<td>
</td>
<td>
<div>TCP and UDP small servers are servers (daemons, in Unix parlance) that run in the router which are useful for diagnostics.</div>
<div>UDP small servers are servers (daemons, in Unix parlance) that run in the router which are useful for diagnostics.</div>
</td>
</tr>
<tr>
Expand Down Expand Up @@ -953,14 +974,35 @@ Parameters
<b>max_servers</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">string</span>
<span style="color: purple">integer</span>
</div>
</td>
<td>
</td>
<td>
<div>Set number of allowable TCP small servers</div>
<div>1 to 2147483647 or no-limit</div>
<div>Set number of allowable UDP small servers</div>
<div>1 to 2147483647</div>
</td>
</tr>
<tr>
<td class="elbow-placeholder"></td>
<td class="elbow-placeholder"></td>
<td colspan="2">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>no_limit</b>
<a class="ansibleOptionLink" href="#parameter-" title="Permalink to this option"></a>
<div style="font-size: small">
<span style="color: purple">boolean</span>
</div>
</td>
<td>
<ul style="margin: 0; padding: 0"><b>Choices:</b>
<li>no</li>
<li>yes</li>
</ul>
</td>
<td>
<div>No limit on number of allowable UDP small servers</div>
</td>
</tr>

Expand Down Expand Up @@ -1036,7 +1078,7 @@ Notes
-----

.. note::
- Tested against Cisco IOSXE Version 16.9
- Tested against Cisco IOSXE Version 17.9.1a on CML.
- This module works with connection ``network_cli``. See https://docs.ansible.com/ansible/latest/network/user_guide/platform_ios.html


Expand Down Expand Up @@ -1556,3 +1598,4 @@ Authors
~~~~~~~

- Ambroise Rosset (@earendilfr)
- Sagar Paul (@KB-perByte)
6 changes: 4 additions & 2 deletions plugins/module_utils/network/ios/argspec/service/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ class ServiceArgs(object): # pylint: disable=R0903
"tcp_small_servers": {
"options": {
"enable": {"type": "bool"},
"max_servers": {"type": "str"},
"max_servers": {"type": "int"},
"no_limit": {"type": "bool"},
},
"type": "dict",
},
Expand Down Expand Up @@ -97,7 +98,8 @@ class ServiceArgs(object): # pylint: disable=R0903
"udp_small_servers": {
"options": {
"enable": {"type": "bool"},
"max_servers": {"type": "str"},
"max_servers": {"type": "int"},
"no_limit": {"type": "bool"},
},
"type": "dict",
},
Expand Down
6 changes: 4 additions & 2 deletions plugins/module_utils/network/ios/config/service/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ def __init__(self, module):
"slave_log",
"tcp_keepalives_in",
"tcp_keepalives_out",
"tcp_small_servers",
"telnet_zeroidle",
"udp_small_servers",
"unsupported_transceiver",
]

Expand Down Expand Up @@ -138,9 +140,9 @@ def _compare_lists_attrs(self, want, have):
for key, wanting in iteritems(i_want):
haveing = i_have.pop(key, {})
if wanting != haveing:
self.addcmd(wanting, "timestamps")
self.addcmd(wanting, key + "_timestamps", False)
for key, haveing in iteritems(i_have):
self.addcmd(haveing, "timestamps", negate=True)
self.addcmd(haveing, key + "_timestamps", negate=True)

def _service_list_to_dict(self, data):
"""Convert all list of dicts to dicts of dicts"""
Expand Down
8 changes: 6 additions & 2 deletions plugins/module_utils/network/ios/facts/service/service.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self, module, subspec="config", options="options"):
self.argument_spec = ServiceArgs.argument_spec

def get_service_data(self, connection):
return connection.get("show running-config all | section ^service ")
return connection.get("show running-config all | section ^service")

def populate_facts(self, connection, ansible_facts, data=None):
"""Populate the facts for Service network resource
Expand All @@ -59,7 +59,11 @@ def populate_facts(self, connection, ansible_facts, data=None):
ansible_facts["ansible_network_resources"].pop("service", None)

params = utils.remove_empties(
service_parser.validate_config(self.argument_spec, {"config": objs}, redact=True),
service_parser.validate_config(
self.argument_spec,
{"config": objs},
redact=True,
),
)

facts["service"] = params.get("config", {})
Expand Down
Loading
Loading