Rework the DRBD8 device status computation
authorIustin Pop <iustin@google.com>
Wed, 18 Jun 2008 10:28:28 +0000 (10:28 +0000)
committerIustin Pop <iustin@google.com>
Wed, 18 Jun 2008 10:28:28 +0000 (10:28 +0000)
commita3f293485eda4d99d1ab780c37f4387e728c888e
treee1fb5fa94643513ef4a841b76d666281c65740ed
parent28873440de0976530e203bf421d9192e427dc19f
Rework the DRBD8 device status computation

Currently, compute the status of a drbd8 device in GetSyncStatus and
return only the values that we need (and fit in the framework of
GetSyncStatus). However, the full status details are useful (and needed)
in other places, so the patch attempts to improve this situation.

We abstract the status of a device outside in a separate class, that
knows how to parse contents from /proc/drbd and set easily accessible
attributes. We then simplify the GetSyncStatus to use this and return
the values that it needs, and add a separate method that returns the
full status object.

The move to a separate class cleans up a little bit the old
sync-progress computation from GetSyncStatus, but it's still many
regexes.

The patch also adds unittests for a few statuses, and modifies one
BaseDRBD call to accept a custom filename instead of '/proc/drbd' to
ease unittests.

Reviewed-by: imsnah
lib/bdev.py
test/data/proc_drbd8.txt [new file with mode: 0644]
test/ganeti.bdev_unittest.py