Do not set parents attribute if parents param is bad.

Wait until after the check.

Also, if somehow parents parameter is 0 or "" or {}, ValueError is raised.
Previously it would only have been raised in cases where parents evaluated
to True for purposes of an if condition, like 2 or "hello".

Main benefit is that new code is easier to understand.

Signed-off-by: mulhern <amulhern@redhat.com>
Add new RaidDevice class for handling RAID aspects of devices.

Signed-off-by: mulhern <amulhern@redhat.com>
Use new RaidDevice class in appropriate Device subclasses.

Signed-off-by: mulhern <amulhern@redhat.com>
Update test setup so that it obeys RAID level requirements.

Previously, the MDRaidArray test did not check whether the number of
parents was fewer than the minimum number allowed by the level if there
were no parents at all. New code always checks, so all those tests that
managed to slip past by setting parents to [] or None have to be updated
with at least as many parents as are required by the level. The tests
that check the state of parents and devices must be updated along with
the setup.

Signed-off-by: mulhern <amulhern@redhat.com>
Adjust detection of exceptions raised.

Previously, for MDRaidArrayDevices, sometimes a DeviceError and sometimes
a RaidError would be thrown if the Raid level was somehow invalid.
Now a DeviceError is thrown, always.
Move getting the attribute into the check methods.

The idea is that one thing the test methods might want to check is
if the attribute is there at all.

Uses a higher order function because it is simpler and clearer and easier
to do the edit.

Signed-off-by: mulhern <amulhern@redhat.com>
Refactor setup of _state_functions into __init__() methods

Use class inheritance where appropriate.

Signed-off-by: mulhern <amulhern@redhat.com>
Add isleaf and direct to _state_functions

Signed-off-by: mulhern <amulhern@redhat.com>
Add dataLevel and metaDataLevel attributes for testing.

Signed-off-by: mulhern <amulhern@redhat.com>
Add a few test for setting dataLevel and metaDataLevel in BTRFS

Signed-off-by: mulhern <amulhern@redhat.com>
pylint hack