mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Fix nxos_facts for nxapi transport (#23302)
* Partial revert of 2e476e64cd
This broke handling of nxos_facts over nxapi
* Fix nxos_facts tests not run in isolation
This commit is contained in:
parent
485affeb12
commit
d890167575
2 changed files with 43 additions and 16 deletions
|
@ -218,7 +218,6 @@ class FactsBase(object):
|
||||||
yield self.transform_dict(item, keymap)
|
yield self.transform_dict(item, keymap)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Default(FactsBase):
|
class Default(FactsBase):
|
||||||
|
|
||||||
VERSION_MAP = frozenset([
|
VERSION_MAP = frozenset([
|
||||||
|
@ -315,6 +314,8 @@ class Interfaces(FactsBase):
|
||||||
return interfaces
|
return interfaces
|
||||||
|
|
||||||
def populate_neighbors(self, data):
|
def populate_neighbors(self, data):
|
||||||
|
objects = dict()
|
||||||
|
if isinstance(data, str):
|
||||||
# if there are no neighbors the show command returns
|
# if there are no neighbors the show command returns
|
||||||
# ERROR: No neighbour information
|
# ERROR: No neighbour information
|
||||||
if data.startswith('ERROR'):
|
if data.startswith('ERROR'):
|
||||||
|
@ -323,8 +324,6 @@ class Interfaces(FactsBase):
|
||||||
lines = data.split('\n')
|
lines = data.split('\n')
|
||||||
regex = re.compile('(\S+)\s+(\S+)\s+\d+\s+\w+\s+(\S+)')
|
regex = re.compile('(\S+)\s+(\S+)\s+\d+\s+\w+\s+(\S+)')
|
||||||
|
|
||||||
objects = dict()
|
|
||||||
|
|
||||||
for item in data.split('\n')[4:-1]:
|
for item in data.split('\n')[4:-1]:
|
||||||
match = regex.match(item)
|
match = regex.match(item)
|
||||||
if match:
|
if match:
|
||||||
|
@ -332,6 +331,21 @@ class Interfaces(FactsBase):
|
||||||
if match.group(2) not in objects:
|
if match.group(2) not in objects:
|
||||||
objects[match.group(2)] = []
|
objects[match.group(2)] = []
|
||||||
objects[match.group(2)].append(nbor)
|
objects[match.group(2)].append(nbor)
|
||||||
|
|
||||||
|
elif isinstance(data, dict):
|
||||||
|
data = data['TABLE_nbor']['ROW_nbor']
|
||||||
|
if isinstance(data, dict):
|
||||||
|
data = [data]
|
||||||
|
|
||||||
|
for item in data:
|
||||||
|
local_intf = item['l_port_id']
|
||||||
|
if local_intf not in objects:
|
||||||
|
objects[local_intf] = list()
|
||||||
|
nbor = dict()
|
||||||
|
nbor['port'] = item['port_id']
|
||||||
|
nbor['host'] = item['chassis_id']
|
||||||
|
objects[local_intf].append(nbor)
|
||||||
|
|
||||||
return objects
|
return objects
|
||||||
|
|
||||||
def parse_ipv6_interfaces(self, data):
|
def parse_ipv6_interfaces(self, data):
|
||||||
|
|
|
@ -8,8 +8,21 @@
|
||||||
- name: set test_items
|
- name: set test_items
|
||||||
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
|
||||||
|
|
||||||
|
- name: enable nxapi
|
||||||
|
nxos_config:
|
||||||
|
lines:
|
||||||
|
- feature nxapi
|
||||||
|
- nxapi http port 80
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
|
||||||
- name: run test case
|
- name: run test case
|
||||||
include: "{{ test_case_to_run }}"
|
include: "{{ test_case_to_run }}"
|
||||||
with_items: "{{ test_items }}"
|
with_items: "{{ test_items }}"
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: test_case_to_run
|
loop_var: test_case_to_run
|
||||||
|
|
||||||
|
- name: disable nxapi
|
||||||
|
nxos_config:
|
||||||
|
lines:
|
||||||
|
- no feature nxapi
|
||||||
|
provider: "{{ cli }}"
|
||||||
|
|
Loading…
Reference in a new issue