Import name 'lvm' instead of names from lvm package.

Signed-off-by: mulhern <amulhern@redhat.com>
Comment mdraid.mdcreate() and update tests appropriately.

Signed-off-by: mulhern <amulhern@redhat.com>
Remove DMRaidArrayDevice.members property.

It seems to be entirely unused since ContainerDevice class was introduced.

Signed-off-by: mulhern <amulhern@redhat.com>
Extract selection of members in complete() into a separate method.

Use it in complete().

Signed-off-by: mulhern <amulhern@redhat.com>
No longer use _standard_levels as the default set of RAID levels.

The notion of a "standard" RAID level is being eroded too rapidly to make it
really useful. ALL_LEVELS is a better notion.
This change has the added benefit of simplifying the RAIDlevels constructor.
Also, make _raid_levels property a set instead of a list since no real
ordering make sense.

Signed-off-by: mulhern <amulhern@redhat.com>
Adjust RaidLevel hierarchy so that all raid level objects extend RAIDLevel

Signed-off-by: mulhern <amulhern@redhat.com>
Allow the RAID object itself to be a valid RAID descriptor for lookup.

Update tests accordingly.

Signed-off-by: mulhern <amulhern@redhat.com>
Move Container class to raid package and tidy it up

Remove dead attribute nick and get_raw_array_size which is really
only appropriate for RAIDn classes and was renamed to get_net_array_size
in a previous commit.

Make Container.get_recommended_stride() raise an exception as the
notion of a recommended stride is meaningless for containers.
Do not catch the exception because if there's a situation where a Container
is being formatted, the only reason why get_recommended_stride() would be
called, something has gone wrong.

Add get_max_spares() and get_base_member_size() which both raise an exception.

Signed-off-by: mulhern <amulhern@redhat.com>
Add Linear and Single to the RAID classes.

Let them share an abstract super-class with an implementation, they just
handle the names.

Signed-off-by: mulhern <amulhern@redhat.com>
Add a has_redundancy method that returns True if there is actual redundancy

Some RAID levels, e.g., 0, don't actually have any redundancy.

Signed-off-by: mulhern <amulhern@redhat.com>
Add an is_uniform property to the RAID levels.

Signed-off-by: mulhern <amulhern@redhat.com>
Add a Dup class to the various descendants of RAIDLevel.

Signed-off-by: mulhern <amulhern@redhat.com>
Make createBitmap() a property and update tests appropriately.

createBitmap() seems to be a simple function of the device properties.
All of these properties are relevant when its value is used in calling
mdcreate(), so they should all be taken into account at that time.
Use has_redundancy raid property when checking whether a device is removable

There is a semantic change here, an error will be raised in the case of
every non-redundant raid, which in this case includes "container" as well
as "raid0".

Signed-off-by: mulhern <amulhern@redhat.com>
Update the mdraid.mdadd comments

They were restricted to be about the raid levels that were supported when
the comment was first written.

Signed-off-by: mulhern <amulhern@redhat.com>
Use has_redundancy property to decide how to add a member to an array.

Better than using explicit names.

Signed-off-by: mulhern <amulhern@redhat.com>
Check for required methods in MDRaidLevels.isRaidLevel.

Signed-off-by: mulhern <amulhern@redhat.com>
Remove getRaidLevel() from mdraid file and make RAID_levels public

devicelibs.btrfs and devicelibs.lvm will be the same. Keeping getRaidLevel()
will just require making copies of it for each of these, in order to remain
consistent.

Update some tests as appropriate, where RaidError is thrown instead of
MDRaidError.

Signed-off-by: mulhern <amulhern@redhat.com>
Add "linear" to mdraid's list of supported raid levels.

Signed-off-by: mulhern <amulhern@redhat.com>
Add lists of supported RAID levels for btrfs and lvm

Update raid level code in BTRFSDevice appropriately so that it no longer
get raid.RAIDLevels(), instead gets the list of BTRFS supported RAID levels.

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