Fix unsafe variant initializer in _TryOSFromDisk
authorIustin Pop <iustin@google.com>
Mon, 14 Jun 2010 01:34:41 +0000 (03:34 +0200)
committerIustin Pop <iustin@google.com>
Mon, 14 Jun 2010 17:46:36 +0000 (19:46 +0200)
commit845da3e806e9b16831c61f07b33db925eba66607
tree8397af323a0a8acc830979bb42541c54f643aaca
parent27137e55043f4d85c43d5f40daeb3f84bd80f283
Fix unsafe variant initializer in _TryOSFromDisk

In case an OS has inconsistent declarations, we might get into a case
where one node reports a valid variants list (with OS API >=15), and
another node has OS API < 15, in which case its supported_variants gets
the default value of None. This leads to the same variable having
inconsistent data types, which leads to subtle bugs later: instead of
reporting something like "Inconsistent OS API versions", the LU exits
with a run-time exception. Furthermore, in another datapath, variants is
initialized to '[]' in case of OS diagnose failures.

The patch changes _TryOSFromDisk to initialize variants to '[]' for
OS api level below 15, and changes the variants calculation in
DiagnoseOS to be more readable.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Guido Trotter <ultrotter@google.com>
lib/backend.py
lib/cmdlib.py