Merge pull request #38682 from cloudflare/NotImplementedError-MSG

[2016.11.2/napalm] Better error message when NotImplementedError raised
This commit is contained in:
Mike Place 2017-01-15 11:34:24 -07:00 committed by GitHub
commit bf6d74c98e

View file

@ -297,14 +297,20 @@ def call(method, **params):
# either not connected
# either unable to execute the command
err_tb = traceback.format_exc() # let's get the full traceback and display for debugging reasons.
comment = 'Cannot execute "{method}" on {device}{port} as {user}. Reason: {error}!'.format(
device=NETWORK_DEVICE.get('HOSTNAME', '[unspecified hostname]'),
port=(':{port}'.format(port=NETWORK_DEVICE.get('OPTIONAL_ARGS', {}).get('port'))
if NETWORK_DEVICE.get('OPTIONAL_ARGS', {}).get('port') else ''),
user=NETWORK_DEVICE.get('USERNAME', ''),
method=method,
error=error
)
if isinstance(error, NotImplementedError):
comment = '{method} is not implemented for the NAPALM {driver} driver!'.format(
method=method,
driver=NETWORK_DEVICE.get('DRIVER_NAME')
)
else:
comment = 'Cannot execute "{method}" on {device}{port} as {user}. Reason: {error}!'.format(
device=NETWORK_DEVICE.get('HOSTNAME', '[unspecified hostname]'),
port=(':{port}'.format(port=NETWORK_DEVICE.get('OPTIONAL_ARGS', {}).get('port'))
if NETWORK_DEVICE.get('OPTIONAL_ARGS', {}).get('port') else ''),
user=NETWORK_DEVICE.get('USERNAME', ''),
method=method,
error=error
)
log.error(comment)
log.error(err_tb)
return {