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 *
25 _ = lambda x: gettext.ldgettext("pykickstart", x)
27 class F8_DeviceData(BaseData):
28 removedKeywords = BaseData.removedKeywords
29 removedAttrs = BaseData.removedAttrs
31 def __init__(self, *args, **kwargs):
32 BaseData.__init__(self, *args, **kwargs)
33 self.moduleName = kwargs.get("moduleName", "")
34 self.moduleOpts = kwargs.get("moduleOpts", "")
37 return self.moduleName == y.moduleName
40 retval = BaseData.__str__(self)
42 if self.moduleName != "":
43 retval += "device %s" % self.moduleName
45 if self.moduleOpts != "":
46 retval += " --opts=\"%s\"" % self.moduleOpts
50 class FC3_Device(KickstartCommand):
51 removedKeywords = KickstartCommand.removedKeywords
52 removedAttrs = KickstartCommand.removedAttrs
54 def __init__(self, writePriority=0, *args, **kwargs):
55 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
56 self.op = self._getParser()
58 self.type = kwargs.get("type", "")
59 self.moduleName = kwargs.get("moduleName", "")
60 self.moduleOpts = kwargs.get("moduleOpts", "")
63 return self.moduleName == y.moduleName
66 retval = KickstartCommand.__str__(self)
68 if self.moduleName != "":
69 retval += "device %s %s" % (self.type, self.moduleName)
71 if self.moduleOpts != "":
72 retval += " --opts=\"%s\"" % self.moduleOpts
78 op.add_option("--opts", dest="moduleOpts", default="")
81 def parse(self, args):
82 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
85 raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("device command requires two arguments: module type and name")))
87 self.moduleOpts = opts.moduleOpts
89 self.moduleName = extra[1]
92 class F8_Device(FC3_Device):
93 removedKeywords = FC3_Device.removedKeywords
94 removedAttrs = FC3_Device.removedAttrs
96 def __init__(self, writePriority=0, *args, **kwargs):
97 FC3_Device.__init__(self, writePriority, *args, **kwargs)
98 self.deviceList = kwargs.get("deviceList", [])
102 for device in self.deviceList:
103 retval += device.__str__()
107 def parse(self, args):
108 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
111 raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("%s command requires a single argument: %s") % ("device", "module name")))
114 self._setToObj(self.op, opts, dd)
115 dd.lineno = self.lineno
116 dd.moduleName = extra[0]
118 # Check for duplicates in the data list.
119 if dd in self.dataList():
120 warnings.warn(_("A module with the name %s has already been defined.") % dd.moduleName)
125 return self.deviceList