Skip to content

Commit

Permalink
Make error message for port group facts gathering more descriptive (#396
Browse files Browse the repository at this point in the history
)
  • Loading branch information
stalabi1 authored Jun 12, 2024
1 parent c6bfcf1 commit 3f5ede4
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/396-port-group-facts-enhancement.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- sonic_port_group - Make error message for port group facts gathering more descriptive (https://github.com/ansible-collections/dellemc.enterprise_sonic/pull/396).
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#
# -*- coding: utf-8 -*-
# © Copyright 2020 Dell Inc. or its subsidiaries. All Rights Reserved
# © Copyright 2024 Dell Inc. or its subsidiaries. All Rights Reserved
# GNU General Public License v3.0+
# (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
"""
Expand All @@ -14,7 +14,7 @@
__metaclass__ = type

from copy import deepcopy

import warnings
from ansible_collections.ansible.netcommon.plugins.module_utils.network.common import (
utils,
)
Expand Down Expand Up @@ -97,6 +97,10 @@ def get_port_groups(self):
try:
pgs_response = edit_config(self._module, to_request(self._module, pgs_request))
except ConnectionError as exc:
if 'Resource not found' in str(exc):
warnings.warn('The port group ("port_group") feature is not supported on this platform.')
return []

self._module.fail_json(msg=str(exc), code=exc.code)

pgs_config = []
Expand All @@ -105,7 +109,7 @@ def get_port_groups(self):

pgs = []
for pg_config in pgs_config:
pg = dict()
pg = {}
if 'config' in pg_config:
pg['id'] = pg_config['id']
speed_str = pg_config['config'].get('speed', None)
Expand Down

0 comments on commit 3f5ede4

Please sign in to comment.