mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-08-22 22:11:44 -07:00
Add support for global IGMP configuration on onyx switches (#42164)
* Add support for global IGMP configuration on onyx switches Signed-off-by: Samer Deeb <samerd@mellanox.com> * Add support for global IGMP configuration on onyx switches Signed-off-by: Samer Deeb <samerd@mellanox.com>
This commit is contained in:
parent
0897e79bd1
commit
3ca4a35334
4 changed files with 381 additions and 6 deletions
|
@ -119,7 +119,6 @@ def show_cmd(module, cmd, json_fmt=True, fail_on_error=True):
|
|||
if fail_on_error:
|
||||
raise
|
||||
return None
|
||||
|
||||
if json_fmt:
|
||||
out = _parse_json_output(out)
|
||||
try:
|
||||
|
@ -177,15 +176,18 @@ class BaseOnyxModule(object):
|
|||
def check_declarative_intent_params(self, result):
|
||||
return None
|
||||
|
||||
def _validate_key(self, param, key):
|
||||
validator = getattr(self, 'validate_%s' % key)
|
||||
if callable(validator):
|
||||
validator(param.get(key))
|
||||
|
||||
def validate_param_values(self, obj, param=None):
|
||||
if param is None:
|
||||
param = self._module.params
|
||||
for key in obj:
|
||||
# validate the param value (if validator func exists)
|
||||
try:
|
||||
validator = getattr(self, 'validate_%s' % key)
|
||||
if callable(validator):
|
||||
validator(param.get(key))
|
||||
self._validate_key(param, key)
|
||||
except AttributeError:
|
||||
pass
|
||||
|
||||
|
@ -202,9 +204,16 @@ class BaseOnyxModule(object):
|
|||
except ValueError:
|
||||
return None
|
||||
|
||||
def _validate_range(self, attr_name, min_val, max_val, value):
|
||||
if value is None:
|
||||
return True
|
||||
if not min_val <= int(value) <= max_val:
|
||||
msg = '%s must be between %s and %s' % (
|
||||
attr_name, min_val, max_val)
|
||||
self._module.fail_json(msg=msg)
|
||||
|
||||
def validate_mtu(self, value):
|
||||
if value and not 1500 <= int(value) <= 9612:
|
||||
self._module.fail_json(msg='mtu must be between 1500 and 9612')
|
||||
self._validate_range('mtu', 1500, 9612, value)
|
||||
|
||||
def generate_commands(self):
|
||||
pass
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue