Skip to content

Commit

Permalink
2.5.1 bug fixes (#450)
Browse files Browse the repository at this point in the history
* Enable system auditd and ip loadshare hash downward compatibility (#441)

* Enable system auditd and ip loadshare hash downward compatibility.

* Add a fragment file.

* Add mock handling for edit_config_catch

* Fix sanity errors.

* Fix mistakes in the fragment file.

* Modify the fix to operation on individual requests in the enterprise_sonic httpapi plugin.

* Enable conditional suppression of GET exceptions.

* Fix handling for an empty GET response.

* Fix an indentation in the PoE facts file and fix global PoE empty configuration handling.

* Update regex expression in edit_config method (#443)

* Update regex expression in edit_config method

* Change fragment to bugfix

* Update 443-update-regex-edit-config.yaml

* Add import of the Ansible ConnectionError exception class for all files where it is used. (#445)

* Add import of the Ansible ConnectionError exception class for all files where it is used.

* Add a fragment file.

* Fix broken module documentation links in the README.md file (#446)

* In the enterprise_sonic README.md file, use the new Galaxy module documentation site for all links.

* Add a changelog fragment for this PR.

* Fix incorrect global regex results.

* Change the fragment designation to "trivial" to match changing the PR type to "documentation".

* Delete changed, redundant fragment file.

---------

Co-authored-by: stalabi1 <54641848+stalabi1@users.noreply.github.com>
  • Loading branch information
kerry-meyer and stalabi1 authored Sep 17, 2024
1 parent 11f5ad8 commit 57cde8f
Show file tree
Hide file tree
Showing 49 changed files with 165 additions and 102 deletions.
128 changes: 64 additions & 64 deletions README.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- sonic_system - Catch the ConnectionError exception caused by unconditional fetching of auditd and ip loadshare hash algorithm configuration, and return empty configuration instead of allowing the uncaught exception to abort all "system" operations on SONiC images older than version 4.4.0 (https://github.com/ansible-collections/dellemc.enterprise_sonic/pull/441).
2 changes: 2 additions & 0 deletions changelogs/fragments/443-update-regex-edit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfixes:
- Update regex search expression for 'not found' error message in httpapi/sonic.py 'edit_config' method (https://github.com/ansible-collection/dellemc.enterprise_sonic/pull/443).
3 changes: 3 additions & 0 deletions changelogs/fragments/445-ConnectionError-add-imports.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- ConnectionError - Add the needed import of the Ansible ConnectionError exception class for all files where it was previously missing. (https://github.com/ansible-collections/dellemc.enterprise_sonic/pull/445).
3 changes: 3 additions & 0 deletions changelogs/fragments/446-README-documentation-links-fix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
trivial:
- README - Update all links to module documentation to use the new Ansible documentation web site on the galaxy.ansible.com domain(https://github.com/ansible-collections/dellemc.enterprise_sonic/pull/446).
9 changes: 7 additions & 2 deletions plugins/httpapi/sonic.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

import json
import time
import re

from ansible.module_utils._text import to_text
from ansible.module_utils.connection import ConnectionError
Expand Down Expand Up @@ -67,7 +68,7 @@ def send_request(self, data, **message_kwargs):
def get(self, command):
return self.send_request(path=command, data=None, method='get')

def edit_config(self, requests):
def edit_config(self, requests, suppr_ntf_excp=True):
"""Send a list of http requests to remote device and return results
"""
if requests is None:
Expand All @@ -78,7 +79,11 @@ def edit_config(self, requests):
try:
response = self.send_request(**req)
except ConnectionError as exc:
raise ConnectionError(to_text(exc, errors='surrogate_then_replace'))
if suppr_ntf_excp and req.get('method') == 'get' and re.search("[nN]ot [fF]ound.*code': 404", str(exc)):
# 'code': 404, 'error-message': 'Resource not found'
response = [{}, {}]
else:
raise ConnectionError(to_text(exc, errors='surrogate_then_replace'))
responses.append(response)
return responses

Expand Down
1 change: 1 addition & 0 deletions plugins/module_utils/network/sonic/config/bfd/bfd.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
__metaclass__ = type

from copy import deepcopy
from ansible.module_utils.connection import ConnectionError
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import (
ConfigBase
)
Expand Down
1 change: 1 addition & 0 deletions plugins/module_utils/network/sonic/config/copp/copp.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
__metaclass__ = type

from copy import deepcopy
from ansible.module_utils.connection import ConnectionError
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import (
ConfigBase,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from copy import deepcopy

from ansible.module_utils.connection import ConnectionError
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import (
ConfigBase,
)
Expand Down
1 change: 1 addition & 0 deletions plugins/module_utils/network/sonic/config/mac/mac.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
__metaclass__ = type

from copy import deepcopy
from ansible.module_utils.connection import ConnectionError
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import (
ConfigBase,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
__metaclass__ = type

from copy import deepcopy
from ansible.module_utils.connection import ConnectionError
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import (
ConfigBase,
)
Expand Down
1 change: 1 addition & 0 deletions plugins/module_utils/network/sonic/config/pki/pki.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

__metaclass__ = type

from ansible.module_utils.connection import ConnectionError
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import (
ConfigBase,
)
Expand Down
1 change: 1 addition & 0 deletions plugins/module_utils/network/sonic/config/poe/poe.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from copy import deepcopy

from ansible.module_utils.connection import ConnectionError
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import (
ConfigBase,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from __future__ import absolute_import, division, print_function
__metaclass__ = type

from ansible.module_utils.connection import ConnectionError
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import (
ConfigBase,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

from ansible.module_utils.connection import ConnectionError
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import (
ConfigBase,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
__metaclass__ = type

from copy import deepcopy
from ansible.module_utils.connection import ConnectionError
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import (
ConfigBase,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
__metaclass__ = type

from copy import deepcopy
from ansible.module_utils.connection import ConnectionError
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import (
ConfigBase,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
__metaclass__ = type

from copy import deepcopy
from ansible.module_utils.connection import ConnectionError
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import (
ConfigBase,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
__metaclass__ = type

from copy import deepcopy
from ansible.module_utils.connection import ConnectionError
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import (
ConfigBase,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import (
to_list,
)
from ansible.module_utils.connection import ConnectionError
from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.utils.utils import (
get_diff,
remove_empties_from_list,
Expand Down
1 change: 1 addition & 0 deletions plugins/module_utils/network/sonic/config/roce/roce.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type

from ansible.module_utils.connection import ConnectionError
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import (
ConfigBase,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

from copy import deepcopy

from ansible.module_utils.connection import ConnectionError
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import (
ConfigBase,
)
Expand Down
1 change: 1 addition & 0 deletions plugins/module_utils/network/sonic/config/sflow/sflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from copy import deepcopy

from ansible.module_utils.connection import ConnectionError
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import (
ConfigBase,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
__metaclass__ = type

from copy import deepcopy
from ansible.module_utils.connection import ConnectionError
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.cfg.base import (
ConfigBase,
)
Expand Down
1 change: 1 addition & 0 deletions plugins/module_utils/network/sonic/facts/bfd/bfd.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from copy import deepcopy

from ansible.module_utils.connection import ConnectionError
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import (
utils,
)
Expand Down
1 change: 1 addition & 0 deletions plugins/module_utils/network/sonic/facts/copp/copp.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import (
utils,
)
from ansible.module_utils.connection import ConnectionError
from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.utils.utils import (
remove_empties
)
Expand Down
1 change: 1 addition & 0 deletions plugins/module_utils/network/sonic/facts/mac/mac.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from copy import deepcopy

from ansible.module_utils.connection import ConnectionError
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import (
utils,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from copy import deepcopy

from ansible.module_utils.connection import ConnectionError
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import (
utils,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from copy import deepcopy

from ansible.module_utils.connection import ConnectionError
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common.utils import (
remove_empties,
validate_config,
Expand Down
1 change: 1 addition & 0 deletions plugins/module_utils/network/sonic/facts/pki/pki.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

from copy import deepcopy

from ansible.module_utils.connection import ConnectionError
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import (
utils,
)
Expand Down
23 changes: 8 additions & 15 deletions plugins/module_utils/network/sonic/facts/poe/poe.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import (
utils,
)
from ansible.module_utils.connection import ConnectionError
from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.poe.poe import PoeArgs

from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.sonic \
Expand Down Expand Up @@ -157,12 +158,7 @@ def get_poe_info(self):
self._module.fail_json(msg=str(exc))

poe_config = {}
try:
poe_config = response[0][1]
if len(poe_config) > 0:
poe_config = poe_config["openconfig-poe:poe"]
except Exception:
raise Exception("response from getting poe facts not formed as expected")
poe_config = response[0][1].get("openconfig-poe:poe", {})

# get poe interface settings
try:
Expand All @@ -172,14 +168,11 @@ def get_poe_info(self):
self._module.fail_json(msg=str(exc))

interface_poe_settings = []
try:
interface_poe_settings = []
for interface in response[0][1]["openconfig-interfaces:interfaces"]["interface"]:
interface_settings = interface.get("openconfig-if-ethernet:ethernet", {}).get("openconfig-if-poe:poe", {})
if len(interface_settings) > 0:
interface_settings.update({"name": interface["name"]})
interface_poe_settings.append(interface_settings)
except Exception:
raise Exception("response from getting poe facts not formed as expected")
poe_interfaces = response[0][1].get("openconfig-interfaces:interfaces", {}).get("interface", [])
for interface in poe_interfaces:
interface_settings = interface.get("openconfig-if-ethernet:ethernet", {}).get("openconfig-if-poe:poe", {})
if len(interface_settings) > 0:
interface_settings.update({"name": interface["name"]})
interface_poe_settings.append(interface_settings)
formatted_specs = self.format_to_argspec(poe_config, interface_poe_settings)
return formatted_specs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import (
utils,
)
from ansible.module_utils.connection import ConnectionError

from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.utils.utils \
import (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import (
utils,
)
from ansible.module_utils.connection import ConnectionError
from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.utils.utils import (
remove_empties_from_list
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import (
utils,
)
from ansible.module_utils.connection import ConnectionError
from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.utils.utils import (
remove_empties
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from copy import deepcopy

from ansible.module_utils.connection import ConnectionError
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import (
utils,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from copy import deepcopy

from ansible.module_utils.connection import ConnectionError
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import (
utils,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import (
utils,
)
from ansible.module_utils.connection import ConnectionError
from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.utils.utils import (
remove_empties_from_list
)
Expand Down
1 change: 1 addition & 0 deletions plugins/module_utils/network/sonic/facts/roce/roce.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

from copy import deepcopy

from ansible.module_utils.connection import ConnectionError
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import (
utils,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import (
utils,
)
from ansible.module_utils.connection import ConnectionError
from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.route_maps.route_maps import Route_mapsArgs

from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.utils.utils import remove_empties_from_list
Expand Down
23 changes: 14 additions & 9 deletions plugins/module_utils/network/sonic/facts/sflow/sflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import (
utils,
)
from ansible.module_utils.connection import ConnectionError
from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.argspec.sflow.sflow import SflowArgs

from ansible_collections.dellemc.enterprise_sonic.plugins.module_utils.network.sonic.sonic \
Expand Down Expand Up @@ -53,17 +54,21 @@ def populate_facts(self, connection, ansible_facts, data=None):
if not data:
data = self.get_sflow_info()

data = self.format_to_argspec(data)
# convert to argspec for ansible_facts
facts = {}
if data:
data = self.format_to_argspec(data)

# validate can add null values for things missing from device config,
# so doing that before remove empties
cleaned_data = utils.remove_empties(
utils.validate_config(self.argument_spec, data)
)
# validate can add null values for things missing from device config,
# so doing that before remove empties
cleaned_data = utils.remove_empties(
utils.validate_config(self.argument_spec, data)
)
if cleaned_data:
facts["sflow"] = cleaned_data["config"]

ansible_facts['ansible_network_resources'].pop('sflow', None)
if cleaned_data:
ansible_facts['ansible_network_resources'].update({"sflow": cleaned_data["config"]})
ansible_facts['ansible_network_resources'].update(facts)

return ansible_facts

Expand Down Expand Up @@ -121,7 +126,7 @@ def get_sflow_info(self):

response_body = {}
try:
response_body = response[0][1][response_key]
response_body = response[0][1].get(response_key)
except Exception:
raise Exception("response from getting sflow facts not formed as expected")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

from copy import deepcopy

from ansible.module_utils.connection import ConnectionError
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import (
utils,
)
Expand Down
Loading

0 comments on commit 57cde8f

Please sign in to comment.