httpapi/nxos_facts: raise ConnectionError is missing code (#53406)

* `nxos_facts` crashes with certain nxos images; e.g. `7.0(3)I7(3)` as a result of this call:
  ```
        data = self.run('show lldp neighbors', output='json')
  ```
  ...which returns `ERROR: No neighbour information` when the device has no neighbors.

* This response causes httpapi's `handle_reponse()` to raise a ConnectionError, which is caught by `utils/jsonrpc.py` which is expecting `code` in the exception data:

  ```
             except ConnectionError as exc:
                 display.vvv(traceback.format_exc())
                 error = self.error(code=exc.code, message=to_text(exc))
  ```

* Found by: `nxos_facts/tests/common/not_hardware.yaml:7`
This commit is contained in:
Chris Van Heuveln 2019-03-07 08:16:28 -05:00 committed by Nathaniel Case
parent fd6e45bc75
commit 874fd70d10

View file

@ -178,7 +178,7 @@ def handle_response(response):
if response['ins_api'].get('outputs'):
for output in to_list(response['ins_api']['outputs']['output']):
if output['code'] != '200':
raise ConnectionError('%s: %s' % (output['input'], output['msg']))
raise ConnectionError('%s: %s' % (output['input'], output['msg']), code=output['code'])
elif 'body' in output:
result = output['body']
if isinstance(result, dict):