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.
22 from imgcreate
.pykickstart
.base
import *
23 from imgcreate
.pykickstart
.options
import *
25 class FC3_IgnoreDisk(KickstartCommand
):
26 def __init__(self
, writePriority
=0, ignoredisk
=None):
27 KickstartCommand
.__init
__(self
, writePriority
)
28 self
.op
= self
._getParser
()
30 if ignoredisk
== None:
33 self
.ignoredisk
= ignoredisk
36 if len(self
.ignoredisk
) > 0:
37 return "ignoredisk --drives=%s\n" % string
.join(self
.ignoredisk
, ",")
42 def drive_cb (option
, opt_str
, value
, parser
):
43 for d
in value
.split(','):
44 parser
.values
.ensure_value(option
.dest
, []).append(d
)
46 op
= KSOptionParser(lineno
=self
.lineno
)
47 op
.add_option("--drives", dest
="ignoredisk", action
="callback",
48 callback
=drive_cb
, nargs
=1, type="string")
51 def parse(self
, args
):
52 (opts
, extra
) = self
.op
.parse_args(args
=args
)
53 self
._setToSelf
(self
.op
, opts
)
55 class F8_IgnoreDisk(FC3_IgnoreDisk
):
56 def __init__(self
, writePriority
=0, ignoredisk
=None, onlyuse
=None):
57 FC3_IgnoreDisk
.__init
__(self
, writePriority
, ignoredisk
)
62 self
.onlyuse
= onlyuse
65 if len(self
.ignoredisk
) > 0:
66 return "ignoredisk --drives=%s\n" % string
.join(self
.ignoredisk
, ",")
67 elif len(self
.onlyuse
) > 0:
68 return "ignoredisk --only-use=%s\n" % string
.join(self
.onlyuse
, ",")
73 def drive_cb (option
, opt_str
, value
, parser
):
74 for d
in value
.split(','):
75 parser
.values
.ensure_value(option
.dest
, []).append(d
)
77 op
= FC3_IgnoreDisk
._getParser
(self
)
78 op
.add_option("--only-use", dest
="onlyuse", action
="callback",
79 callback
=drive_cb
, nargs
=1, type="string")
82 RHEL4_IgnoreDisk
= F8_IgnoreDisk
84 RHEL5_IgnoreDisk
= F8_IgnoreDisk