move pykickstart -> imgcreate.pykickstart
[pykickstart/EL-5.git] / pykickstart / commands / ignoredisk.py
blob23c9a0187a284b24dc9daa48cf3013ba3bb9d130
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 import string
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:
31 ignoredisk = []
33 self.ignoredisk = ignoredisk
35 def __str__(self):
36 if len(self.ignoredisk) > 0:
37 return "ignoredisk --drives=%s\n" % string.join(self.ignoredisk, ",")
38 else:
39 return ""
41 def _getParser(self):
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")
49 return op
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)
59 if onlyuse == None:
60 onlyuse = []
62 self.onlyuse = onlyuse
64 def __str__(self):
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, ",")
69 else:
70 return ""
72 def _getParser(self):
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")
80 return op
82 RHEL4_IgnoreDisk = F8_IgnoreDisk
84 RHEL5_IgnoreDisk = F8_IgnoreDisk