mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #13450 from privateip/feature_ios_shared_module
bugfix for ios.py shared module argument creation
This commit is contained in:
commit
17b334d4a5
1 changed files with 3 additions and 18 deletions
|
@ -80,7 +80,7 @@ def ios_module(**kwargs):
|
||||||
"""
|
"""
|
||||||
spec = kwargs.get('argument_spec') or dict()
|
spec = kwargs.get('argument_spec') or dict()
|
||||||
|
|
||||||
argument_spec = url_argument_spec()
|
argument_spec = shell_argument_spec()
|
||||||
argument_spec.update(IOS_COMMON_ARGS)
|
argument_spec.update(IOS_COMMON_ARGS)
|
||||||
if kwargs.get('argument_spec'):
|
if kwargs.get('argument_spec'):
|
||||||
argument_spec.update(kwargs['argument_spec'])
|
argument_spec.update(kwargs['argument_spec'])
|
||||||
|
@ -150,21 +150,6 @@ class IosShell(object):
|
||||||
responses.append(response)
|
responses.append(response)
|
||||||
return responses
|
return responses
|
||||||
|
|
||||||
def ios_from_args(module):
|
|
||||||
"""Extracts the set of argumetns to build a valid IOS connection
|
|
||||||
"""
|
|
||||||
params = dict()
|
|
||||||
for arg, attrs in IOS_COMMON_ARGS.iteritems():
|
|
||||||
if module.params['device']:
|
|
||||||
params[arg] = module.params['device'].get(arg)
|
|
||||||
if arg not in params or module.params[arg]:
|
|
||||||
params[arg] = module.params[arg]
|
|
||||||
if params[arg] is None:
|
|
||||||
if attrs.get('required'):
|
|
||||||
module.fail_json(msg='argument %s is required' % arg)
|
|
||||||
params[arg] = attrs.get('default')
|
|
||||||
return params
|
|
||||||
|
|
||||||
def ios_connection(module):
|
def ios_connection(module):
|
||||||
"""Creates a connection to an IOS device based on the module arguments
|
"""Creates a connection to an IOS device based on the module arguments
|
||||||
"""
|
"""
|
||||||
|
@ -180,16 +165,16 @@ def ios_connection(module):
|
||||||
shell = IosShell()
|
shell = IosShell()
|
||||||
shell.connect(host, port=port, username=username, password=password,
|
shell.connect(host, port=port, username=username, password=password,
|
||||||
timeout=timeout)
|
timeout=timeout)
|
||||||
|
shell.send('terminal length 0')
|
||||||
except paramiko.ssh_exception.AuthenticationException, exc:
|
except paramiko.ssh_exception.AuthenticationException, exc:
|
||||||
module.fail_json(msg=exc.message)
|
module.fail_json(msg=exc.message)
|
||||||
except socket.error, exc:
|
except socket.error, exc:
|
||||||
module.fail_json(msg=exc.strerror, errno=exc.errno)
|
module.fail_json(msg=exc.strerror, errno=exc.errno)
|
||||||
|
|
||||||
shell.send('terminal length 0')
|
|
||||||
|
|
||||||
if module.params['enable_mode']:
|
if module.params['enable_mode']:
|
||||||
shell.authorize(module.params['enable_password'])
|
shell.authorize(module.params['enable_password'])
|
||||||
|
|
||||||
return shell
|
return shell
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue