query: Change internal result computation
authorIustin Pop <iustin@google.com>
Sun, 16 Jan 2011 15:02:25 +0000 (16:02 +0100)
committerIustin Pop <iustin@google.com>
Tue, 18 Jan 2011 15:55:46 +0000 (16:55 +0100)
commite2d188ccc43f3ff5ea4bc4bf6e4f4f747dc430e5
treee86c0e97b15f0d28204e08118794135d86766856
parent82599b3ef6d9c396a49d6131788c3c7b146292f5
query: Change internal result computation

While looking at the query library, I realized that while we have five
field statuses, making this a 5-dimensional space, four of them are
shrunk to a single possible value (None). Hence it should be possible to
convert this into a single value space plus extra 4 special constants.

This patch implements this, making (IMHO) the return value of normal
functions much simpler: you simply return the desired value, instead of
(QRFS_NORMAL, value); for the special results, you simply return
_FS_UNAVAIL, instead of (QRFS_UNAVAIL, None). This I believe does
simplify the code.

Signed-off-by: Iustin Pop <iustin@google.com>
Reviewed-by: Michael Hanselmann <hansmi@google.com>
lib/query.py
test/ganeti.query_unittest.py