1 |
# dmraid.py |
2 |
# dmraid device formats |
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 |
from ..storage_log import log_method_call |
24 |
from flags import flags |
25 |
from ..errors import * |
26 |
from . import DeviceFormat, register_device_format |
27 |
|
28 |
import gettext |
29 |
_ = lambda x: gettext.ldgettext("anaconda", x) |
30 |
|
31 |
import logging |
32 |
log = logging.getLogger("storage") |
33 |
|
34 |
|
35 |
class DMRaidMember(DeviceFormat): |
36 |
""" A dmraid member disk. """ |
37 |
_type = "dmraidmember" |
38 |
_name = "dm-raid member device" |
39 |
# XXX This looks like trouble. |
40 |
# |
41 |
# Maybe a better approach is a RaidMember format with subclass |
42 |
# for MDRaidMember, letting all *_raid_member types fall through |
43 |
# to the generic RaidMember format, which is basically read-only. |
44 |
# |
45 |
# One problem that presents is the possibility of someone passing |
46 |
# a dmraid member to the MDRaidArrayDevice constructor. |
47 |
_udevTypes = ["adaptec_raid_member", "ddf_raid_member", |
48 |
"hpt37x_raid_member", "hpt45x_raid_member", |
49 |
"isw_raid_member", |
50 |
"jmicron_raid_member", "lsi_mega_raid_member", |
51 |
"nvidia_raid_member", "promise_fasttrack_raid_member", |
52 |
"silicon_medley_raid_member", "via_raid_member"] |
53 |
_formattable = False # can be formatted |
54 |
_supported = True # is supported |
55 |
_linuxNative = False # for clearpart |
56 |
_packages = ["dmraid"] # required packages |
57 |
_resizable = False # can be resized |
58 |
_bootable = False # can be used as boot |
59 |
_maxSize = 0 # maximum size in MB |
60 |
_minSize = 0 # minimum size in MB |
61 |
_hidden = True # hide devices with this formatting? |
62 |
|
63 |
def __init__(self, *args, **kwargs): |
64 |
""" Create a DeviceFormat instance. |
65 |
|
66 |
Keyword Arguments: |
67 |
|
68 |
device -- path to the underlying device |
69 |
uuid -- this format's UUID |
70 |
exists -- indicates whether this is an existing format |
71 |
|
72 |
On initialization this format is like DeviceFormat |
73 |
|
74 |
""" |
75 |
log_method_call(self, *args, **kwargs) |
76 |
DeviceFormat.__init__(self, *args, **kwargs) |
77 |
|
78 |
# Initialize the attribute that will hold the block object. |
79 |
self._raidmem = None |
80 |
|
81 |
def __str__(self): |
82 |
s = DeviceFormat.__str__(self) |
83 |
s += (" raidmem = %(raidmem)r" % {"raidmem": self.raidmem}) |
84 |
return s |
85 |
|
86 |
def _getRaidmem(self): |
87 |
return self._raidmem |
88 |
|
89 |
def _setRaidmem(self, raidmem): |
90 |
self._raidmem = raidmem |
91 |
|
92 |
raidmem = property(lambda d: d._getRaidmem(), |
93 |
lambda d,r: d._setRaidmem(r)) |
94 |
|
95 |
def create(self, *args, **kwargs): |
96 |
log_method_call(self, device=self.device, |
97 |
type=self.type, status=self.status) |
98 |
raise DMRaidMemberError("creation of dmraid members is non-sense") |
99 |
|
100 |
def destroy(self, *args, **kwargs): |
101 |
log_method_call(self, device=self.device, |
102 |
type=self.type, status=self.status) |
103 |
raise DMRaidMemberError("destruction of dmraid members is non-sense") |
104 |
|
105 |
|
106 |
if not flags.cmdline.has_key("noiswmd"): |
107 |
DMRaidMember._udevTypes.remove("isw_raid_member") |
108 |
|
109 |
# The anaconda cmdline has not been parsed yet when we're first imported, |
110 |
# so we can not use flags.dmraid here |
111 |
if flags.cmdline.has_key("nodmraid"): |
112 |
DMRaidMember._udevTypes = [] |
113 |
|
114 |
register_device_format(DMRaidMember) |
115 |
|