2 # Chris Lumens <clumens@redhat.com>
4 # Copyright 2005, 2006, 2007, 2008 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 *
24 _ = lambda x: gettext.ldgettext("pykickstart", x)
26 class FC3_DriverDiskData(BaseData):
27 removedKeywords = BaseData.removedKeywords
28 removedAttrs = BaseData.removedAttrs
30 def __init__(self, writePriority=0, *args, **kwargs):
31 BaseData.__init__(self, *args, **kwargs)
33 self.partition = kwargs.get("partition", "")
34 self.source = kwargs.get("source", "")
35 self.type = kwargs.get("type", "")
37 def _getArgsAsStr(self):
41 retval += "%s" % self.partition
43 if hasattr(self, "type") and self.type:
44 retval += " --type=%s" % self.type
46 retval += "--source=%s" % self.source
50 retval = BaseData.__str__(self)
51 retval += "driverdisk %s\n" % self._getArgsAsStr()
54 class FC4_DriverDiskData(FC3_DriverDiskData):
55 removedKeywords = FC3_DriverDiskData.removedKeywords
56 removedAttrs = FC3_DriverDiskData.removedAttrs
58 def __init__(self, writePriority=0, *args, **kwargs):
59 FC3_DriverDiskData.__init__(self, *args, **kwargs)
60 self.deleteRemovedAttrs()
62 self.biospart = kwargs.get("biospart", "")
64 def _getArgsAsStr(self):
68 retval += "%s" % self.partition
70 if hasattr(self, "type") and self.type:
71 retval += " --type=%s" % self.type
73 retval += "--source=%s" % self.source
75 retval += "--biospart=%s" % self.biospart
79 class F12_DriverDiskData(FC4_DriverDiskData):
80 removedKeywords = FC4_DriverDiskData.removedKeywords + ["type"]
81 removedAttrs = FC4_DriverDiskData.removedAttrs + ["type"]
83 def __init__(self, *args, **kwargs):
84 FC4_DriverDiskData.__init__(self, *args, **kwargs)
85 self.deleteRemovedAttrs()
87 F14_DriverDiskData = F12_DriverDiskData
89 class FC3_DriverDisk(KickstartCommand):
90 removedKeywords = KickstartCommand.removedKeywords
91 removedAttrs = KickstartCommand.removedAttrs
93 def __init__(self, writePriority=0, *args, **kwargs):
94 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
95 self.op = self._getParser()
97 self.driverdiskList = kwargs.get("driverdiskList", [])
101 for dd in self.driverdiskList:
102 retval += dd.__str__()
106 def _getParser(self):
107 op = KSOptionParser()
108 op.add_option("--source")
109 op.add_option("--type")
112 def parse(self, args):
113 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
116 raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Only one partition may be specified for driverdisk command.")))
118 if len(extra) == 1 and opts.source:
119 raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Only one of --source and partition may be specified for driverdisk command.")))
121 if not extra and not opts.source:
122 raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("One of --source or partition must be specified for driverdisk command.")))
124 ddd = self.handler.DriverDiskData()
125 self._setToObj(self.op, opts, ddd)
126 ddd.lineno = self.lineno
128 ddd.partition = extra[0]
133 return self.driverdiskList
135 class FC4_DriverDisk(FC3_DriverDisk):
136 removedKeywords = FC3_DriverDisk.removedKeywords
137 removedAttrs = FC3_DriverDisk.removedKeywords
139 def _getParser(self):
140 op = FC3_DriverDisk._getParser(self)
141 op.add_option("--biospart")
144 def parse(self, args):
145 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
148 raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Only one partition may be specified for driverdisk command.")))
150 if len(extra) == 1 and opts.source:
151 raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Only one of --source and partition may be specified for driverdisk command.")))
152 elif len(extra) == 1 and opts.biospart:
153 raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Only one of --biospart and partition may be specified for driverdisk command.")))
154 elif opts.source and opts.biospart:
155 raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Only one of --biospart and --source may be specified for driverdisk command.")))
157 if not extra and not opts.source and not opts.biospart:
158 raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("One of --source, --biospart, or partition must be specified for driverdisk command.")))
160 ddd = self.handler.DriverDiskData()
161 self._setToObj(self.op, opts, ddd)
162 ddd.lineno = self.lineno
164 ddd.partition = extra[0]
168 class F12_DriverDisk(FC4_DriverDisk):
169 removedKeywords = FC4_DriverDisk.removedKeywords
170 removedAttrs = FC4_DriverDisk.removedKeywords
172 def _getParser(self):
173 op = FC4_DriverDisk._getParser(self)
174 op.add_option("--type", deprecated=1)
177 class F14_DriverDisk(F12_DriverDisk):
178 removedKeywords = F12_DriverDisk.removedKeywords
179 removedAttrs = F12_DriverDisk.removedKeywords
181 def _getParser(self):
182 op = F12_DriverDisk._getParser(self)
183 op.remove_option("--type")