/[smeserver]/cdrom.image/sme9/updates/storage/formats/mdraid.py
ViewVC logotype

Annotation of /cdrom.image/sme9/updates/storage/formats/mdraid.py

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (hide annotations) (download) (as text)
Sun Oct 20 23:12:54 2013 UTC (10 years, 9 months ago) by charliebrady
Branch: MAIN
Content type: text/x-python
Add devicelibs and formats subdirectories of storage, and contained .py
files, in preparation to modifying to allow degraded RAID install.

1 charliebrady 1.1 # mdraid.py
2     # Device format classes for anaconda's storage configuration module.
3     #
4     # Copyright (C) 2009 Red Hat, Inc.
5     #
6     # This copyrighted material is made available to anyone wishing to use,
7     # modify, copy, or redistribute it subject to the terms and conditions of
8     # the GNU General Public License v.2, or (at your option) any later version.
9     # This program is distributed in the hope that it will be useful, but WITHOUT
10     # ANY WARRANTY expressed or implied, including the implied warranties of
11     # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
12     # Public License for more details. You should have received a copy of the
13     # GNU General Public License along with this program; if not, write to the
14     # Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
15     # 02110-1301, USA. Any Red Hat trademarks that are incorporated in the
16     # source code or documentation are not subject to the GNU General Public
17     # License and may only be used or replicated with the express permission of
18     # Red Hat, Inc.
19     #
20     # Red Hat Author(s): Dave Lehman <dlehman@redhat.com>
21     #
22    
23     import os
24    
25     from ..storage_log import log_method_call
26     from flags import flags
27     from parted import PARTITION_RAID
28     from ..errors import *
29     from ..devicelibs import mdraid
30     from . import DeviceFormat, register_device_format
31    
32     import gettext
33     _ = lambda x: gettext.ldgettext("anaconda", x)
34    
35     import logging
36     log = logging.getLogger("storage")
37    
38    
39     class MDRaidMember(DeviceFormat):
40     """ An mdraid member disk. """
41     _type = "mdmember"
42     _name = "software RAID"
43     _udevTypes = ["linux_raid_member"]
44     partedFlag = PARTITION_RAID
45     _formattable = True # can be formatted
46     _supported = True # is supported
47     _linuxNative = True # for clearpart
48     _packages = ["mdadm"] # required packages
49    
50     def __init__(self, *args, **kwargs):
51     """ Create a MDRaidMember instance.
52    
53     Keyword Arguments:
54    
55     device -- path to underlying device
56     uuid -- this member device's uuid
57     mdUuid -- the uuid of the array this device belongs to
58     exists -- indicates whether this is an existing format
59    
60     """
61     log_method_call(self, *args, **kwargs)
62     DeviceFormat.__init__(self, *args, **kwargs)
63     self.mdUuid = kwargs.get("mdUuid")
64     self.raidMinor = None
65    
66     #self.probe()
67     self.biosraid = kwargs.get("biosraid")
68    
69     def __str__(self):
70     s = DeviceFormat.__str__(self)
71     s += (" mdUUID = %(mdUUID)s biosraid = %(biosraid)s" %
72     {"mdUUID": self.mdUuid, "biosraid": self.biosraid})
73     return s
74    
75     @property
76     def dict(self):
77     d = super(MDRaidMember, self).dict
78     d.update({"mdUUID": self.mdUuid, "biosraid": self.biosraid})
79     return d
80    
81     def probe(self):
82     """ Probe for any missing information about this format. """
83     log_method_call(self, device=self.device,
84     type=self.type, status=self.status)
85     if not self.exists:
86     raise MDMemberError("format does not exist")
87    
88     info = mdraid.mdexamine(self.device)
89     if self.uuid is None:
90     self.uuid = info['uuid']
91     if self.raidMinor is None:
92     self.raidMinor = info['mdMinor']
93    
94     def destroy(self, *args, **kwargs):
95     if not self.exists:
96     raise MDMemberError("format does not exist")
97    
98     if not os.access(self.device, os.W_OK):
99     raise MDMemberError("device path does not exist")
100    
101     mdraid.mddestroy(self.device)
102     self.exists = False
103    
104     @property
105     def status(self):
106     # XXX hack -- we don't have a nice way to see if the array is active
107     return False
108    
109     @property
110     def hidden(self):
111     return (self._hidden or self.biosraid)
112    
113     def writeKS(self, f):
114     f.write("raid.%s" % self.majorminor)
115    
116     # nodmraid -> Wether to use BIOS RAID or not
117     # Note the anaconda cmdline has not been parsed yet when we're first imported,
118     # so we can not use flags.dmraid here
119     if not flags.cmdline.has_key("noiswmd") and \
120     not flags.cmdline.has_key("nodmraid"):
121     MDRaidMember._udevTypes.append("isw_raid_member")
122    
123     register_device_format(MDRaidMember)
124    

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed