2 # Chris Lumens <clumens@redhat.com>
4 # Copyright 2005, 2006, 2007, 2009 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 KickstartCommand
21 from pykickstart
.errors
import KickstartValueError
, formatErrorMsg
22 from pykickstart
.options
import KSOptionParser
25 _
= lambda x
: gettext
.ldgettext("pykickstart", x
)
27 class FC3_IgnoreDisk(KickstartCommand
):
28 removedKeywords
= KickstartCommand
.removedKeywords
29 removedAttrs
= KickstartCommand
.removedAttrs
31 def __init__(self
, writePriority
=0, *args
, **kwargs
):
32 KickstartCommand
.__init
__(self
, writePriority
, *args
, **kwargs
)
33 self
.op
= self
._getParser
()
35 self
.ignoredisk
= kwargs
.get("ignoredisk", [])
38 retval
= KickstartCommand
.__str
__(self
)
40 if len(self
.ignoredisk
) > 0:
41 retval
+= "ignoredisk --drives=%s\n" % ",".join(self
.ignoredisk
)
46 def drive_cb (option
, opt_str
, value
, parser
):
47 for d
in value
.split(','):
48 parser
.values
.ensure_value(option
.dest
, []).append(d
)
51 op
.add_option("--drives", dest
="ignoredisk", action
="callback",
52 callback
=drive_cb
, nargs
=1, type="string", required
=1)
55 def parse(self
, args
):
56 (opts
, _extra
) = self
.op
.parse_args(args
=args
, lineno
=self
.lineno
)
57 self
._setToSelf
(self
.op
, opts
)
60 class F8_IgnoreDisk(FC3_IgnoreDisk
):
61 removedKeywords
= FC3_IgnoreDisk
.removedKeywords
62 removedAttrs
= FC3_IgnoreDisk
.removedAttrs
64 def __init__(self
, writePriority
=0, *args
, **kwargs
):
65 FC3_IgnoreDisk
.__init
__(self
, writePriority
, *args
, **kwargs
)
67 self
.onlyuse
= kwargs
.get("onlyuse", [])
70 retval
= KickstartCommand
.__str
__(self
)
72 if len(self
.ignoredisk
) > 0:
73 retval
+= "ignoredisk --drives=%s\n" % ",".join(self
.ignoredisk
)
74 elif len(self
.onlyuse
) > 0:
75 retval
+= "ignoredisk --only-use=%s\n" % ",".join(self
.onlyuse
)
79 def parse(self
, args
, errorCheck
=True):
80 retval
= FC3_IgnoreDisk
.parse(self
, args
)
83 if (len(self
.ignoredisk
) == 0 and len(self
.onlyuse
) == 0) or (len(self
.ignoredisk
) > 0 and (len(self
.onlyuse
) > 0)):
84 raise KickstartValueError(formatErrorMsg(self
.lineno
, msg
=_("One of --drives or --only-use must be specified for ignoredisk command.")))
89 def drive_cb (option
, opt_str
, value
, parser
):
90 for d
in value
.split(','):
91 parser
.values
.ensure_value(option
.dest
, []).append(d
)
93 op
= FC3_IgnoreDisk
._getParser
(self
)
94 op
.add_option("--drives", dest
="ignoredisk", action
="callback",
95 callback
=drive_cb
, nargs
=1, type="string")
96 op
.add_option("--only-use", dest
="onlyuse", action
="callback",
97 callback
=drive_cb
, nargs
=1, type="string")
100 class RHEL6_IgnoreDisk(F8_IgnoreDisk
):
101 removedKeywords
= F8_IgnoreDisk
.removedKeywords
102 removedAttrs
= F8_IgnoreDisk
.removedAttrs
104 def __init__(self
, writePriority
=0, *args
, **kwargs
):
105 F8_IgnoreDisk
.__init
__(self
, writePriority
, *args
, **kwargs
)
107 self
.interactive
= kwargs
.get("interactive", False)
112 retval
= F8_IgnoreDisk
.__str
__(self
)
115 retval
= "ignoredisk --interactive\n"
119 def parse(self
, args
):
120 retval
= F8_IgnoreDisk
.parse(self
, args
, errorCheck
=False)
123 if len(self
.ignoredisk
) > 0:
125 if len(self
.onlyuse
) > 0:
130 raise KickstartValueError(formatErrorMsg(self
.lineno
, msg
=_("One of --drives , --only-use , or --interactive must be specified for ignoredisk command.")))
134 def _getParser(self
):
135 op
= F8_IgnoreDisk
._getParser
(self
)
136 op
.add_option("--interactive", dest
="interactive", action
="store_true",
140 F14_IgnoreDisk
= RHEL6_IgnoreDisk