mirror of
https://github.com/linux-system-roles/network.git
synced 2026-01-23 02:15:17 +00:00
Automation Hub, and possibly Galaxy in the future, require the collection to be screened with `ansible-test sanity` among other checks. The role had a number of issues: * Use `AssertionError` instead of `assert` * Use of `logging` module not in accordance with standards, but these are ok and the errors were suppressed * Several import errors which are ok because they are checked elsewhere * __init__.py in the module_utils directories must be empty, so a new file myerror.py was added to move the code from __init__.py * NOTE: network_lsr/nm/__init__.py is not empty * The documentation block in the module was not properly constructed or formatted. * shellcheck issues, including removing unused files * use `unused` instead of `_` (underscore) for variables that are unused add WARNING to module docs - collection users should not use directly Signed-off-by: Rich Megginson <rmeggins@redhat.com>
44 lines
1.1 KiB
Python
44 lines
1.1 KiB
Python
# SPDX-License-Identifier: BSD-3-Clause
|
|
""" Support for NetworkManager aka the NM provider """
|
|
|
|
from __future__ import absolute_import, division, print_function
|
|
|
|
__metaclass__ = type
|
|
|
|
# pylint: disable=import-error, no-name-in-module
|
|
from ansible.module_utils.network_lsr.utils import Util # noqa:E501
|
|
|
|
ETHTOOL_FEATURE_PREFIX = "ETHTOOL_OPTNAME_FEATURE_"
|
|
ETHTOOL_COALESCE_PREFIX = "ETHTOOL_OPTNAME_COALESCE_"
|
|
|
|
|
|
def get_nm_ethtool_feature(name):
|
|
"""
|
|
Translate ethtool feature into Network Manager name
|
|
|
|
:param name: Name of the feature
|
|
:type name: str
|
|
:returns: Name of the feature to be used by `NM.SettingEthtool.set_feature()`
|
|
:rtype: str
|
|
"""
|
|
|
|
name = ETHTOOL_FEATURE_PREFIX + name.upper()
|
|
|
|
feature = getattr(Util.NM(), name, None)
|
|
return feature
|
|
|
|
|
|
def get_nm_ethtool_coalesce(name):
|
|
"""
|
|
Translate ethtool coalesce into Network Manager name
|
|
|
|
:param name: Name of the coalesce
|
|
:type name: str
|
|
:returns: Name of the setting to be used by `NM.SettingEthtool.set_coalesce()`
|
|
:rtype: str
|
|
"""
|
|
|
|
name = ETHTOOL_COALESCE_PREFIX + name.upper()
|
|
|
|
coalesce = getattr(Util.NM(), name, None)
|
|
return coalesce
|