2 # Hans de Goede <hdegoede@redhat.com>
4 # Copyright 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 *
21 from pykickstart.options import *
25 _ = lambda x: gettext.ldgettext("pykickstart", x)
27 class F12_FcoeData(BaseData):
28 removedKeywords = BaseData.removedKeywords
29 removedAttrs = BaseData.removedAttrs
31 def __init__(self, *args, **kwargs):
32 BaseData.__init__(self, *args, **kwargs)
33 self.nic = kwargs.get("nic", None)
36 return self.nic == y.nic
38 def _getArgsAsStr(self):
42 retval += " --nic=%s" % self.nic
47 retval = BaseData.__str__(self)
48 retval += "fcoe%s\n" % self._getArgsAsStr()
51 class F13_FcoeData(F12_FcoeData):
52 removedKeywords = F12_FcoeData.removedKeywords
53 removedAttrs = F12_FcoeData.removedAttrs
55 def __init__(self, *args, **kwargs):
56 F12_FcoeData.__init__(self, *args, **kwargs)
57 self.dcb = kwargs.get("dcb", False)
59 def _getArgsAsStr(self):
60 retval = F12_FcoeData._getArgsAsStr(self)
67 class F12_Fcoe(KickstartCommand):
68 removedKeywords = KickstartCommand.removedKeywords
69 removedAttrs = KickstartCommand.removedAttrs
71 def __init__(self, writePriority=71, *args, **kwargs):
72 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
73 self.op = self._getParser()
74 self.fcoe = kwargs.get("fcoe", [])
78 for fcoe in self.fcoe:
79 retval += fcoe.__str__()
85 op.add_option("--nic", dest="nic", required=1)
88 def parse(self, args):
89 zd = self.handler.FcoeData()
90 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
92 mapping = {"command": "fcoe", "options": extra}
93 raise KickstartValueError (formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping))
95 self._setToObj(self.op, opts, zd)
96 zd.lineno = self.lineno
98 # Check for duplicates in the data list.
99 if zd in self.dataList():
100 warnings.warn(_("A FCOE device with the name %s has already been defined.") % zd.nic)
107 class F13_Fcoe(F12_Fcoe):
108 removedKeywords = F12_Fcoe.removedKeywords
109 removedAttrs = F12_Fcoe.removedAttrs
111 def _getParser(self):
112 op = F12_Fcoe._getParser(self)
113 op.add_option("--dcb", dest="dcb", action="store_true", default=False)