Raise exception when get_disks() cannot get 'TYPE' column
This commit makes get_disks() raise an exception when it cannot get
'TYPE' column. In most of new linux distros, this cannot be happened,
however, in old distros, the 'TYPE' column doesn't exist. In that
situation, this could be useful for debugging and it's easy to
understand what is the root cause.
Change-Id: I328f1c2ea80478a00432f51e77ffd12036829430
Related-Bug: #1673607
diff --git a/tempest/common/utils/linux/remote_client.py b/tempest/common/utils/linux/remote_client.py
index 6dfc579..1d86946 100644
--- a/tempest/common/utils/linux/remote_client.py
+++ b/tempest/common/utils/linux/remote_client.py
@@ -62,10 +62,14 @@
# Show header line too
selected.append(l)
# lsblk lists disk type in a column right-aligned with TYPE
- elif pos > 0 and l[pos:pos + 4] == "disk":
+ elif pos is not None and pos > 0 and l[pos:pos + 4] == "disk":
selected.append(l)
- return "\n".join(selected)
+ if selected:
+ return "\n".join(selected)
+ else:
+ msg = "'TYPE' column is requred but the output doesn't have it: "
+ raise tempest.lib.exceptions.TempestException(msg + output)
def get_boot_time(self):
cmd = 'cut -f1 -d. /proc/uptime'