tests: fix `_get_osd_id_from_host()` in TestOSDs()

We must initialize `children` variable in `_get_osd_id_from_host()`,
otherwise, if for any reason the deployment has failed and result with
an osd host with no OSD registered, we won't enter in the condition,
therefore, `children` is never set and the function tries to return
something undefined.

Typical error:
```
E       UnboundLocalError: local variable 'children' referenced before assignment
```

Fixes: #2860

Signed-off-by: Guillaume Abrioux <gabrioux@redhat.com>
pull/2870/head
Guillaume Abrioux 2018-07-09 11:51:24 +02:00 committed by mergify[bot]
parent 07852ed039
commit 9a65ec231d
1 changed files with 1 additions and 0 deletions

View File

@ -49,6 +49,7 @@ class TestOSDs(object):
host.exists('ceph-volume-systemd') host.exists('ceph-volume-systemd')
def _get_osd_id_from_host(self, node, osd_tree): def _get_osd_id_from_host(self, node, osd_tree):
children = []
for n in osd_tree['nodes']: for n in osd_tree['nodes']:
if n['name'] == node['vars']['inventory_hostname'] and n['type'] == 'host': if n['name'] == node['vars']['inventory_hostname'] and n['type'] == 'host':
children = n['children'] children = n['children']