]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_volume: modify util.prepare.check_id to handle stdout as a list
authorAndrew Schoen <aschoen@redhat.com>
Tue, 30 Jan 2018 17:32:53 +0000 (11:32 -0600)
committerAndrew Schoen <aschoen@redhat.com>
Tue, 30 Jan 2018 17:32:53 +0000 (11:32 -0600)
process.call returns stdout as a list, not a string

Signed-off-by: Andrew Schoen <aschoen@redhat.com>
src/ceph-volume/ceph_volume/tests/util/test_prepare.py
src/ceph-volume/ceph_volume/util/prepare.py

index 98038825dc3e5326ff17de970b801fa131e885da..8f1fb7cd9a3472df06a30d0b9f21e3828a0f1ee9 100644 (file)
@@ -20,7 +20,7 @@ class TestCheckID(object):
         stdout = dict(nodes=[
             dict(id=0),
         ])
-        stdout = json.dumps(stdout)
+        stdout = ['', json.dumps(stdout)]
         monkeypatch.setattr('ceph_volume.process.call', lambda *a, **kw: (stdout, '', 0))
         result = prepare.check_id(0)
         assert result
@@ -30,7 +30,7 @@ class TestCheckID(object):
         stdout = dict(nodes=[
             dict(id=0),
         ])
-        stdout = json.dumps(stdout)
+        stdout = ['', json.dumps(stdout)]
         monkeypatch.setattr('ceph_volume.process.call', lambda *a, **kw: (stdout, '', 0))
         result = prepare.check_id(1)
         assert not result
@@ -39,7 +39,7 @@ class TestCheckID(object):
         stdout = dict(nodes=[
             dict(id=0),
         ])
-        stdout = json.dumps(stdout)
+        stdout = ['', json.dumps(stdout)]
         monkeypatch.setattr('ceph_volume.process.call', lambda *a, **kw: (stdout, '', 0))
         result = prepare.check_id("foo")
         assert not result
index dc272d2ac7c2cdc66dd3f07e68657c337ba81278..c72cb552979502f4a8743e6448d41edbc5f3b6fc 100644 (file)
@@ -96,7 +96,7 @@ def check_id(osd_id):
     if returncode != 0:
         raise RuntimeError('Unable check if OSD id exists: %s' % osd_id)
 
-    output = json.loads(stdout)
+    output = json.loads(''.join(stdout).strip())
     osds = output['nodes']
     found_osd = any([str(osd['id']) == str(osd_id) for osd in osds])
     if found_osd: