Skip to content

Commit

Permalink
Os6 collections bug fixes (#19)
Browse files Browse the repository at this point in the history
* os6 command module bug fix

* added os6 collection support for non-legacy platforms
  • Loading branch information
komalupatil authored Nov 17, 2020
1 parent 22d7e87 commit c9a425a
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 19 deletions.
9 changes: 9 additions & 0 deletions changelogs/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@ Ansible Network Collection for Dell EMC OS6 Release Notes

.. contents:: Topics

v1.0.4
======

Bugfixes
---------------

- Fix issue in using list of strings for `commands` argument for `os6_command` module
- Fix issue in using "os6_facts" module for non-legacy n-series platofrms

v1.0.3
======

Expand Down
8 changes: 8 additions & 0 deletions changelogs/changelog.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -76,4 +76,12 @@ releases:
fragments:
- 1.0.3.yaml
release_date: '2020-10-09'
1.0.4:
changes:
bugfixes:
- Fix issue in using list of strings for `commands` argument for `os6_command` module
- Fix issue in using "os6_facts" module for non-legacy n-series platofrms
fragments:
- 1.0.4.yaml
release_date: "2020-11-17"

2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
namespace: dellemc
name: os6
version: 1.0.3
version: 1.0.4
readme: README.md
authors:
- Komal Patil <Komal_uttamrao_Patil@dell.com>
Expand Down
4 changes: 2 additions & 2 deletions plugins/modules/os6_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
module is not returned until the condition is satisfied or
the number of retries has expired.
type: list
elements: dict
elements: str
required: true
wait_for:
description:
Expand Down Expand Up @@ -165,7 +165,7 @@ def main():
"""
argument_spec = dict(
# { command: <str>, prompt: <str>, response: <str> }
commands=dict(type='list', elements='dict', required=True),
commands=dict(type='list', elements='str', required=True),

wait_for=dict(type='list', elements='str'),
match=dict(default='all', choices=['all', 'any']),
Expand Down
34 changes: 18 additions & 16 deletions plugins/modules/os6_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ def parse_hostname(self, data):
return match.group(1)

def parse_model(self, data):
match = re.search(r'System Model ID(.+)\s([A-Z0-9]*)\n', data, re.M)
match = re.search(r'System Model ID(.+)\s([-A-Z0-9]*)\n', data, re.M)
if match:
return match.group(2)

Expand Down Expand Up @@ -286,21 +286,21 @@ def parse_neighbors(self, neighbors):
if intf not in facts:
facts[intf] = list()
fact = dict()
fact['port'] = self.parse_lldp_port(en.split()[3])
if (len(en.split()) > 4):
fact['host'] = self.parse_lldp_host(en.split()[4])
else:
fact['host'] = "Null"
if len(en.split()) > 2:
fact['port'] = self.parse_lldp_port(en.split()[3])
if (len(en.split()) > 4):
fact['host'] = self.parse_lldp_host(en.split()[4])
else:
fact['host'] = "Null"
facts[intf].append(fact)

return facts

def parse_interfaces(self, data):
parsed = dict()
for line in data.split('\n'):
if len(line) == 0:
continue
match = re.match(r'Interface Name(.+)\s([A-Za-z0-9/]*)', line)
match = re.match(r'Interface Name(.+)\s([A-Za-z0-9/]*)', line, re.IGNORECASE)
if match:
key = match.group(2)
parsed[key] = line
Expand All @@ -309,18 +309,20 @@ def parse_interfaces(self, data):
return parsed

def parse_description(self, key, desc):
desc, desc_next = desc.split('--------- --------------- ------ ------- ---- ------ ----- -- -------------------')
desc = re.split(r'[-+\s](?:-+\s)[-+\s].*', desc, maxsplit=1)
desc_next = desc[1]
if desc_next.find('Oob') > 0:
desc_val, desc_info = desc_next.split('Oob')
elif desc_next.find('Port') > 0:
desc_val, desc_info = desc_next.split('Port')
for en in desc_val.splitlines():
if key in en:
match = re.search(r'^(\S+)\s+(\S+)', en)
if match.group(2) in ['Full', 'N/A']:
return "Null"
else:
return match.group(2)
if desc_val:
for en in desc_val.splitlines():
if key in en:
match = re.search(r'^(\S+)\s+(\S+)', en)
if match.group(2) in ['Full', 'N/A']:
return "Null"
else:
return match.group(2)

def parse_macaddress(self, data):
match = re.search(r'Burned In MAC Address(.+)\s([A-Z0-9.]*)\n', data)
Expand Down

0 comments on commit c9a425a

Please sign in to comment.