2 # Chris Lumens <clumens@redhat.com>
4 # Copyright 2005, 2006, 2007 Red Hat, Inc.
6 # This copyrighted material is made available to anyone wishing to use, modify,
7 # copy, or redistribute it subject to the terms and conditions of the GNU
8 # General Public License v.2. This program is distributed in the hope that it
9 # will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
10 # implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11 # See the GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License along with
14 # this program; if not, write to the Free Software Foundation, Inc., 51
15 # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
16 # trademarks that are incorporated in the source code or documentation are not
17 # subject to the GNU General Public License and may only be used or replicated
18 # with the express permission of Red Hat, Inc.
20 from pykickstart
.base
import *
21 from pykickstart
.errors
import *
22 from pykickstart
.options
import *
24 from rhpl
.translate
import _
25 import rhpl
.translate
as translate
27 translate
.textdomain("pykickstart")
29 class FC3_LogVolData(BaseData
):
30 def __init__(self
, fstype
="", grow
=False, maxSizeMB
=0, name
="",
31 format
=True, percent
=0, recommended
=False, size
=None,
32 preexist
=False, vgname
="", mountpoint
=""):
33 BaseData
.__init
__(self
)
36 self
.maxSizeMB
= maxSizeMB
39 self
.percent
= percent
40 self
.recommended
= recommended
42 self
.preexist
= preexist
44 self
.mountpoint
= mountpoint
46 def _getArgsAsStr(self
):
50 retval
+= " --fstype=\"%s\"" % self
.fstype
53 if self
.maxSizeMB
> 0:
54 retval
+= " --maxsize=%d" % self
.maxSizeMB
56 retval
+= " --noformat"
58 retval
+= " --percent=%d" % self
.percent
60 retval
+= " --recommended"
62 retval
+= " --size=%d" % self
.size
64 retval
+= " --useexisting"
69 return "logvol %s %s --name=%s --vgname=%s\n" % (self
.mountpoint
, self
._getArgsAsStr
(), self
.name
, self
.vgname
)
71 class FC4_LogVolData(FC3_LogVolData
):
72 def __init__(self
, bytesPerInode
=4096, fsopts
="", fstype
="", grow
=False,
73 maxSizeMB
=0, name
="", format
=True, percent
=0,
74 recommended
=False, size
=None, preexist
=False, vgname
="",
76 FC3_LogVolData
.__init
__(self
, fstype
=fstype
, grow
=grow
,
77 maxSizeMB
=maxSizeMB
, name
=name
,
78 format
=format
, percent
=percent
,
79 recommended
=recommended
, size
=size
,
80 preexist
=preexist
, vgname
=vgname
,
81 mountpoint
=mountpoint
)
82 self
.bytesPerInode
= bytesPerInode
85 def _getArgsAsStr(self
):
86 retval
= FC3_LogVolData
._getArgsAsStr
(self
)
88 if self
.bytesPerInode
> 0:
89 retval
+= " --bytes-per-inode=%d" % self
.bytesPerInode
91 retval
+= " --fsoptions=\"%s\"" % self
.fsopts
95 class FC3_LogVol(KickstartCommand
):
96 def __init__(self
, writePriority
=132, lvList
=None):
97 KickstartCommand
.__init
__(self
, writePriority
)
108 for part
in self
.lvList
:
109 retval
+= part
.__str
__()
113 def _setClassData(self
):
114 self
.dataType
= FC3_LogVolData
116 def _getParser(self
):
117 def lv_cb (option
, opt_str
, value
, parser
):
118 parser
.values
.format
= False
119 parser
.values
.preexist
= True
121 op
= KSOptionParser(lineno
=self
.lineno
)
122 op
.add_option("--fstype", dest
="fstype")
123 op
.add_option("--grow", dest
="grow", action
="store_true",
125 op
.add_option("--maxsize", dest
="maxSizeMB", action
="store", type="int",
127 op
.add_option("--name", dest
="name", required
=1)
128 op
.add_option("--noformat", action
="callback", callback
=lv_cb
,
129 dest
="format", default
=True, nargs
=0)
130 op
.add_option("--percent", dest
="percent", action
="store", type="int",
132 op
.add_option("--recommended", dest
="recommended", action
="store_true",
134 op
.add_option("--size", dest
="size", action
="store", type="int",
136 op
.add_option("--useexisting", dest
="preexist", action
="store_true",
138 op
.add_option("--vgname", dest
="vgname", required
=1)
141 def parse(self
, args
):
142 op
= self
._getParser
()
143 (opts
, extra
) = op
.parse_args(args
=args
)
146 raise KickstartValueError
, formatErrorMsg(self
.lineno
, msg
=_("Mount point required for %s") % "logvol")
148 lvd
= self
.dataType()
149 self
._setToObj
(op
, opts
, lvd
)
150 lvd
.mountpoint
=extra
[0]
153 def add(self
, newObj
):
154 self
.lvList
.append(newObj
)
156 class FC4_LogVol(FC3_LogVol
):
157 def __init__(self
, writePriority
=132, lvList
=None):
158 FC3_LogVol
.__init
__(self
, writePriority
, lvList
)
160 def _getParser(self
):
161 op
= FC3_LogVol
._getParser
(self
)
162 op
.add_option("--bytes-per-inode", dest
="bytesPerInode", action
="store",
164 op
.add_option("--fsoptions", dest
="fsopts")
167 def _setClassData(self
):
168 self
.dataType
= FC4_LogVolData