mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 22:02:50 +00:00
Move Conditional class to netcfg. Added error handling for connect and execute methods.
Fix comments
This commit is contained in:
@@ -38,6 +38,7 @@ def to_list(val):
|
||||
else:
|
||||
return list()
|
||||
|
||||
|
||||
class Eapi(object):
|
||||
|
||||
def __init__(self, module):
|
||||
@@ -107,6 +108,7 @@ class Eapi(object):
|
||||
|
||||
return response['result']
|
||||
|
||||
|
||||
class Cli(object):
|
||||
|
||||
def __init__(self, module):
|
||||
@@ -121,15 +123,20 @@ class Cli(object):
|
||||
password = self.module.params['password']
|
||||
|
||||
self.shell = Shell()
|
||||
self.shell.open(host, port=port, username=username, password=password)
|
||||
|
||||
try:
|
||||
self.shell.open(host, port=port, username=username, password=password)
|
||||
except Exception, exc:
|
||||
self.module.fail_json('Failed to connect to {0}:{1} - {2}'.format(host, port, str(exc)))
|
||||
|
||||
def authorize(self):
|
||||
passwd = self.module.params['auth_pass']
|
||||
self.send(Command('enable', prompt=NET_PASSWD_RE, response=passwd))
|
||||
|
||||
def send(self, commands, encoding='text'):
|
||||
def send(self, commands):
|
||||
return self.shell.send(commands)
|
||||
|
||||
|
||||
class NetworkModule(AnsibleModule):
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
|
||||
Reference in New Issue
Block a user