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
.options
import *
23 from rhpl
.translate
import _
24 import rhpl
.translate
as translate
26 translate
.textdomain("pykickstart")
28 class F8_DeviceData(BaseData
):
29 def __init__(self
, moduleName
="", moduleOpts
=""):
30 BaseData
.__init
__(self
)
31 self
.moduleName
= moduleName
32 self
.moduleOpts
= moduleOpts
35 if self
.moduleName
!= "":
36 if self
.moduleOpts
!= "":
37 retval
= "--opts=%s" % self
.moduleOpts
41 return "device %s %s\n" % (self
.moduleName
, retval
)
45 class FC3_Device(KickstartCommand
):
46 def __init__(self
, writePriority
=0, type="", moduleName
="", moduleOpts
=""):
47 KickstartCommand
.__init
__(self
, writePriority
)
49 self
.moduleName
= moduleName
50 self
.moduleOpts
= moduleOpts
53 if self
.moduleName
!= "":
54 if self
.moduleOpts
!= "":
55 retval
= "--opts=%s" % self
.moduleOpts
59 return "device %s %s %s\n" % (self
.type, self
.moduleName
, retval
)
63 def parse(self
, args
):
64 op
= KSOptionParser(lineno
=self
.lineno
)
65 op
.add_option("--opts", dest
="moduleOpts", default
="")
67 (opts
, extra
) = op
.parse_args(args
=args
)
70 raise KickstartValueError
, formatErrorMsg(self
.lineno
, msg
=_("device command requires two arguments: module type and name"))
72 self
.opts
= opts
.moduleOpts
74 self
.moduleName
= extra
[1]
76 class F8_Device(KickstartCommand
):
77 def __init__(self
, writePriority
=0, deviceList
=None):
78 KickstartCommand
.__init
__(self
, writePriority
)
80 if deviceList
== None:
83 self
.deviceList
= deviceList
87 for device
in self
.deviceList
:
88 retval
+= device
.__str
__()
92 def parse(self
, args
):
93 op
= KSOptionParser(lineno
=self
.lineno
)
94 op
.add_option("--opts", dest
="moduleOpts", default
="")
96 (opts
, extra
) = op
.parse_args(args
=args
)
99 raise KickstartValueError
, formatErrorMsg(self
.lineno
, msg
=_("%s command requires a single argument: %s") % ("device", "module name"))
102 self
._setToObj
(op
, opts
, dd
)
103 dd
.moduleName
= extra
[1]
106 def add(self
, newObj
):
107 self
.deviceList
.append(newObj
)