Skip to content

Commit

Permalink
Merge branch 'main' into backup_restore
Browse files Browse the repository at this point in the history
  • Loading branch information
rohitthakur2590 authored Sep 19, 2023
2 parents 383b167 + d2eb3d9 commit 794ba0e
Show file tree
Hide file tree
Showing 12 changed files with 669 additions and 611 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.0"
rev: "v3.0.3"
hooks:
- id: prettier
additional_dependencies:
Expand Down
28 changes: 28 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,34 @@ Ansible Netcommon Collection Release Notes
.. contents:: Topics


v5.2.0
======

Minor Changes
-------------

- Add a new cliconf plugin ``default`` that can be used when no cliconf plugin is found for a given network_os. This plugin only supports ``get()``. (https://github.com/ansible-collections/ansible.netcommon/pull/569)
- httpapi - Add additional option ``ca_path``, ``client_cert``, ``client_key``, and ``http_agent`` that are available in open_url but not to httpapi. (https://github.com/ansible-collections/ansible.netcommon/issues/528)
- telnet - add crlf option to send CRLF instead of just LF (https://github.com/ansible-collections/ansible.netcommon/pull/440).

Deprecated Features
-------------------

- libssh - the ssh_*_args options are now marked that they will be removed after 2026-01-01.

Bugfixes
--------

- Ensure that all connection plugin options that should be strings are actually strings (https://github.com/ansible-collections/ansible.netcommon/pull/549).

New Plugins
-----------

Cliconf
~~~~~~~

- default - General purpose cliconf plugin for new platforms

v5.1.3
======

Expand Down
1,166 changes: 594 additions & 572 deletions changelogs/changelog.yaml

Large diffs are not rendered by default.

5 changes: 0 additions & 5 deletions changelogs/fragments/default-cliconf.yaml

This file was deleted.

5 changes: 0 additions & 5 deletions changelogs/fragments/httpapi_options.yaml

This file was deleted.

3 changes: 0 additions & 3 deletions changelogs/fragments/ssh_args.yaml

This file was deleted.

10 changes: 0 additions & 10 deletions changelogs/fragments/vlan_extender.yaml

This file was deleted.

19 changes: 19 additions & 0 deletions docs/ansible.netcommon.telnet_module.rst
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,25 @@ Parameters
<div style="font-size: small; color: darkgreen"><br/>aliases: commands</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
<b>crlf</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><div style="color: blue"><b>no</b>&nbsp;&larr;</div></li>
<li>yes</li>
</ul>
</td>
<td>
<div>Sends a CRLF (Carrage Return) instead of just a LF (Line Feed).</div>
</td>
</tr>
<tr>
<td colspan="1">
<div class="ansibleOptionAnchor" id="parameter-"></div>
Expand Down
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ readme: README.md
repository: https://github.com/ansible-collections/ansible.netcommon
issues: https://github.com/ansible-collections/ansible.netcommon/issues
tags: [networking, security, cloud, network_cli, netconf, httpapi, grpc]
version: 5.1.3
version: 5.2.0
18 changes: 13 additions & 5 deletions plugins/action/telnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,18 @@ def run(self, tmp=None, task_vars=None):
pause = int(self._task.args.get("pause", 1))

send_newline = self._task.args.get("send_newline", False)
clrf = self._task.args.get("clrf", False)

login_prompt = to_text(self._task.args.get("login_prompt", "login: "))
password_prompt = to_text(self._task.args.get("password_prompt", "Password: "))
prompts = self._task.args.get("prompts", ["\\$ "])
commands = self._task.args.get("command") or self._task.args.get("commands")

if clrf:
line_ending = "\r\n"
else:
line_ending = "\n"

if isinstance(commands, text_type):
commands = commands.split(",")

Expand All @@ -64,25 +70,27 @@ def run(self, tmp=None, task_vars=None):
self.output = bytes()
try:
if send_newline:
self.tn.write(b"\n")
self.tn.write(to_bytes(line_ending))

self.await_prompts([login_prompt], timeout)
self.tn.write(to_bytes(user + "\n"))
display.vvvvv(">>>user: %s" % user)
self.tn.write(to_bytes(user + line_ending))

if password:
self.await_prompts([password_prompt], timeout)
self.tn.write(to_bytes(password + "\n"))
display.vvvvv(">>>password: %s" % password)
self.tn.write(to_bytes(password + line_ending))

self.await_prompts(prompts, timeout)

for cmd in commands:
display.vvvvv(">>> %s" % cmd)
self.tn.write(to_bytes(cmd + "\n"))
self.tn.write(to_bytes(cmd + line_ending))
self.await_prompts(prompts, timeout)
display.vvvvv("<<< %s" % cmd)
sleep(pause)

self.tn.write(b"exit\n")
self.tn.write(to_bytes("exit" + line_ending))

except EOFError as e:
result["failed"] = True
Expand Down
16 changes: 7 additions & 9 deletions plugins/module_utils/network/common/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -468,12 +468,12 @@ def load_provider(spec, args):
provider = args.get("provider") or {}
for key, value in iteritems(spec):
if key not in provider:
if "fallback" in value:
try:
# Get fallback if defined, and valid
provider[key] = _fallback(value["fallback"])
elif "default" in value:
provider[key] = value["default"]
else:
provider[key] = None
except (basic.AnsibleFallbackNotFound, KeyError):
# Get default if defined, otherwise set to None
provider[key] = value.get("default")
if "authorize" in provider:
# Coerce authorize to provider if a string has somehow snuck in.
provider["authorize"] = boolean(provider["authorize"] or False)
Expand All @@ -491,10 +491,8 @@ def _fallback(fallback):
kwargs = item
else:
args = item
try:
return strategy(*args, **kwargs)
except basic.AnsibleFallbackNotFound:
pass

return strategy(*args, **kwargs)


def generate_dict(spec):
Expand Down
6 changes: 6 additions & 0 deletions plugins/modules/telnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@
required: false
type: bool
default: false
crlf:
description:
- Sends a CRLF (Carrage Return) instead of just a LF (Line Feed).
required: false
type: bool
default: false
notes:
- The C(environment) keyword does not work with this task
author:
Expand Down

0 comments on commit 794ba0e

Please sign in to comment.