[blivet:master 2/5] Add new RaidDevice class for handling RAID aspects of devices.
Vratislav Podzimek
vpodzime at redhat.com
Tue Oct 7 06:26:03 UTC 2014
On Mon, 2014-10-06 at 09:14 -0400, mulhern wrote:
> Signed-off-by: mulhern <amulhern at redhat.com>
> ---
> blivet/devices/raid.py | 106 +++++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 106 insertions(+)
> create mode 100644 blivet/devices/raid.py
>
> diff --git a/blivet/devices/raid.py b/blivet/devices/raid.py
> new file mode 100644
> index 0000000..0f064f9
> --- /dev/null
> +++ b/blivet/devices/raid.py
> @@ -0,0 +1,106 @@
> +# devices/raid.py
> +#
> +# Copyright (C) 2014 Red Hat, Inc.
> +#
> +# This copyrighted material is made available to anyone wishing to use,
> +# modify, copy, or redistribute it subject to the terms and conditions of
> +# the GNU General Public License v.2, or (at your option) any later version.
> +# This program is distributed in the hope that it will be useful, but WITHOUT
> +# ANY WARRANTY expressed or implied, including the implied warranties of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
> +# Public License for more details. You should have received a copy of the
> +# GNU General Public License along with this program; if not, write to the
> +# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> +# 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
> +# source code or documentation are not subject to the GNU General Public
> +# License and may only be used or replicated with the express permission of
> +# Red Hat, Inc.
> +#
> +# Red Hat Author(s): Anne Mulhern <amulhern at redhat.com>
> +#
> +
> +import abc
> +
> +from six import add_metaclass
> +
> +from .. import errors
> +from ..i18n import N_, P_
> +
> +from .storage import StorageDevice
> +
> + at add_metaclass(abc.ABCMeta)
> +class RaidDevice(StorageDevice):
> + """ Metaclass for devices that support RAID in some form. """
> +
> + def _validateRaidLevel(self, level, parent_diff=0):
> + """ Returns an error message if the RAID level is invalid for this
> + device, otherwise None.
> +
> + :param level: a RAID level
> + :type level: :class:`~.devicelibs.raid.RAIDLevel`
> + :param int parent_diff: number of parents being removed or added
> + :returns: an error message if the RAID level is invalid, else None
> + :rtype: str or NoneType
> +
> + The default number of parents being removed or added is 0,
> + indicating that the level is to be checked against the current
> + number of parents. The number is positive for added parents,
> + negative for removed parents.
> + """
> + num_parents = len(self.parents) + parent_diff
> + if not self.exists and num_parents < level.min_members:
> + message = P_(
> + "RAID level %(raidLevel)s requires that device have at least %(minMembers)d member.",
> + "RAID level %(raidLevel)s requires that device have at least %(minMembers)d members.",
> + level.min_members
> + )
> + return message % {"raidLevel": level, "minMembers" : level.min_members}
> + return None
> +
> + def _getLevel(self, value, levels):
> + """ Obtains a valid level for the allowed set of levels.
> +
> + :param value: a RAID level
> + :type value: a valid RAID level descriptor
> + :param levels: a list of valid levels
> + :type levels: :class:`~.devicelibs.raid.RAIDLevels`
> + :returns: a valid RAID level
> + :rtype: :class:`~.devicelibs.raid.RAIDLevel`
> + :raises: ValueError if invalid RAID level
The syntax for the :raises: field [1] is
:raises EXCEPT_TYPE: condition description
[1] http://sphinx-doc.org/domains.html#info-field-lists
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list