Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix for ios.py shared module argument creation #13450

Merged
merged 1 commit into from
Dec 7, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
21 changes: 3 additions & 18 deletions lib/ansible/module_utils/ios.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def ios_module(**kwargs):
"""
spec = kwargs.get('argument_spec') or dict()

argument_spec = url_argument_spec()
argument_spec = shell_argument_spec()
argument_spec.update(IOS_COMMON_ARGS)
if kwargs.get('argument_spec'):
argument_spec.update(kwargs['argument_spec'])
Expand Down Expand Up @@ -150,21 +150,6 @@ def send(self, commands):
responses.append(response)
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):
"""Creates a connection to an IOS device based on the module arguments
"""
Expand All @@ -180,16 +165,16 @@ def ios_connection(module):
shell = IosShell()
shell.connect(host, port=port, username=username, password=password,
timeout=timeout)
shell.send('terminal length 0')
except paramiko.ssh_exception.AuthenticationException, exc:
module.fail_json(msg=exc.message)
except socket.error, exc:
module.fail_json(msg=exc.strerror, errno=exc.errno)

shell.send('terminal length 0')

if module.params['enable_mode']:
shell.authorize(module.params['enable_password'])

return shell