diff options
| author | yuan liang <leetpy2@gmail.com> | 2018-01-17 16:51:05 +0800 |
|---|---|---|
| committer | Julia Kreger <juliaashleykreger@gmail.com> | 2018-01-26 18:34:56 +0000 |
| commit | f55b8a34c4b796632940652219091265498b60c5 (patch) | |
| tree | e52522051d472060d88cd014afbe3b4fd8600f8f /ironic_python_agent/hardware_managers | |
| parent | cd2ab6b1fb4955a3f07afc2ba50d765339ae1fe4 (diff) | |
| download | ironic-python-agent-f55b8a34c4b796632940652219091265498b60c5.tar.gz | |
Execute error in _detect_cna_card
A list type parameter pass to utils.execute will raise OSError.
Change-Id: Ic5dd30f7e819e433d05bf9cc888902abe7a82def
Diffstat (limited to 'ironic_python_agent/hardware_managers')
| -rw-r--r-- | ironic_python_agent/hardware_managers/cna.py | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/ironic_python_agent/hardware_managers/cna.py b/ironic_python_agent/hardware_managers/cna.py index e2962327..6998422a 100644 --- a/ironic_python_agent/hardware_managers/cna.py +++ b/ironic_python_agent/hardware_managers/cna.py @@ -14,6 +14,7 @@ import os +from oslo_concurrency import processutils from oslo_config import cfg from oslo_log import log @@ -27,13 +28,18 @@ CONF = cfg.CONF def _detect_cna_card(): addr_path = '/sys/class/net' for net_dev in os.listdir(addr_path): + link_path = '{}/{}/device/driver/module'.format(addr_path, net_dev) try: - link_command = 'readlink {}/{}/device/driver/module'.format( - addr_path, net_dev) - out = utils.execute(link_command.split()) - if not out or out[1]: - continue - except OSError: + out = utils.execute('readlink', '-v', link_path) + except OSError as e: + LOG.warning('Something went wrong when readlink for ' + 'interface %(device)s. Error: %(error)s', + {'device': net_dev, 'error': e}) + continue + except processutils.ProcessExecutionError as e: + LOG.debug('Get driver for interface %(device)s failed. ' + 'Error: %(error)s', + {'device': net_dev, 'error': e}) continue driver_name = os.path.basename(out[0].strip()) if driver_name == 'i40e': |
