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`

(cherry picked from commit 874fd70d10)
pull/54918/head
Chris Van Heuveln 7 years ago committed by Toshio Kuratomi
parent 7dcfa2c45c
commit 903e6cd2d6

@ -123,7 +123,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):

Loading…
Cancel
Save