Skip to content

Commit

Permalink
Fix aoscx_facts module
Browse files Browse the repository at this point in the history
When stressing the device, if 1000 VLANS are added to the switch,
module facts is not able to display the physical interfaces.
If VLANS are deleted from the config, facts module displays the
information correctly again.

This commit fixes performance and module works in that scenario.

CR 268603

(cherry picked from commit 15cc5cad89a64887b9ba6db5219fd8d105b17ffa)
  • Loading branch information
Vladimir Vargas authored and Kattia Chaves Ramirez committed Jun 6, 2023
1 parent 21423fc commit b42ae3e
Showing 1 changed file with 9 additions and 25 deletions.
34 changes: 9 additions & 25 deletions plugins/modules/aoscx_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,10 +280,17 @@ def main():
# Retrieve ansible_net_gather_subset
ansible_facts.update({"ansible_net_gather_subset": subset_list})

# Retrieve device facts
try:
switch = Device(session)
switch.get()
curr_firmware = iter(switch.get_firmware_version().split("."))
platform = next(curr_firmware)
main_version = int(next(curr_firmware))
sub_version = int(next(curr_firmware))
except Exception as e:
ansible_module.fail_json(msg="Firmware version: {0}".format(str(e)))

# Retrieve device facts
try:
switch.get_subsystems() # subsystem
except Exception as e:
ansible_module.fail_json(msg="Subsystem: {0}".format(str(e)))
Expand All @@ -310,33 +317,11 @@ def main():
# in argument_spec
use_data_planes = False
for subset in subset_list:

# Argument translation for management_interface and
# physical_interfaces
if subset == "management_interface":
subset = "mgmt_intf_status"
elif subset == "physical_interfaces":
try:
curr_firmware = iter(switch.get_firmware_version().split("."))
except Exception:
# Reconnect and retry:
# Platforms 6000 and 6100 fail here
# The session is suddenly closed and it is necessary
# to reopen it
try:
session.open(
username=session.username(),
password=session.password(),
use_proxy=False,
)
except Exception as e:
ansible_module.fail_json(msg=str(e))

curr_firmware = iter(switch.get_firmware_version().split("."))
platform = next(curr_firmware)
main_version = int(next(curr_firmware))
sub_version = int(next(curr_firmware))

if platform in ["FL", "ML", "CL", "LL"] and (
main_version > 10 or sub_version > 8
):
Expand Down Expand Up @@ -391,7 +376,6 @@ def main():
intfs = switch.subsystems[subsystem][subset]
ansible_facts[str_subset].update({subsystem: intfs})

session.close()
ansible_module.exit_json(ansible_facts=ansible_facts, warnings=warnings)


Expand Down

0 comments on commit b42ae3e

Please sign in to comment.