diff options
Diffstat (limited to 'scripts/lib/mic/3rdparty/pykickstart/commands/fcoe.py')
-rw-r--r-- | scripts/lib/mic/3rdparty/pykickstart/commands/fcoe.py | 114 |
1 files changed, 114 insertions, 0 deletions
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/fcoe.py b/scripts/lib/mic/3rdparty/pykickstart/commands/fcoe.py new file mode 100644 index 0000000000..33208499b3 --- /dev/null +++ b/scripts/lib/mic/3rdparty/pykickstart/commands/fcoe.py | |||
@@ -0,0 +1,114 @@ | |||
1 | # | ||
2 | # Hans de Goede <hdegoede@redhat.com> | ||
3 | # | ||
4 | # Copyright 2009 Red Hat, Inc. | ||
5 | # | ||
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. | ||
12 | # | ||
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. | ||
19 | # | ||
20 | from pykickstart.base import * | ||
21 | from pykickstart.options import * | ||
22 | |||
23 | import gettext | ||
24 | import warnings | ||
25 | _ = lambda x: gettext.ldgettext("pykickstart", x) | ||
26 | |||
27 | class F12_FcoeData(BaseData): | ||
28 | removedKeywords = BaseData.removedKeywords | ||
29 | removedAttrs = BaseData.removedAttrs | ||
30 | |||
31 | def __init__(self, *args, **kwargs): | ||
32 | BaseData.__init__(self, *args, **kwargs) | ||
33 | self.nic = kwargs.get("nic", None) | ||
34 | |||
35 | def __eq__(self, y): | ||
36 | return self.nic == y.nic | ||
37 | |||
38 | def _getArgsAsStr(self): | ||
39 | retval = "" | ||
40 | |||
41 | if self.nic: | ||
42 | retval += " --nic=%s" % self.nic | ||
43 | |||
44 | return retval | ||
45 | |||
46 | def __str__(self): | ||
47 | retval = BaseData.__str__(self) | ||
48 | retval += "fcoe%s\n" % self._getArgsAsStr() | ||
49 | return retval | ||
50 | |||
51 | class F13_FcoeData(F12_FcoeData): | ||
52 | removedKeywords = F12_FcoeData.removedKeywords | ||
53 | removedAttrs = F12_FcoeData.removedAttrs | ||
54 | |||
55 | def __init__(self, *args, **kwargs): | ||
56 | F12_FcoeData.__init__(self, *args, **kwargs) | ||
57 | self.dcb = kwargs.get("dcb", False) | ||
58 | |||
59 | def _getArgsAsStr(self): | ||
60 | retval = F12_FcoeData._getArgsAsStr(self) | ||
61 | |||
62 | if self.dcb: | ||
63 | retval += " --dcb" | ||
64 | |||
65 | return retval | ||
66 | |||
67 | class F12_Fcoe(KickstartCommand): | ||
68 | removedKeywords = KickstartCommand.removedKeywords | ||
69 | removedAttrs = KickstartCommand.removedAttrs | ||
70 | |||
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", []) | ||
75 | |||
76 | def __str__(self): | ||
77 | retval = "" | ||
78 | for fcoe in self.fcoe: | ||
79 | retval += fcoe.__str__() | ||
80 | |||
81 | return retval | ||
82 | |||
83 | def _getParser(self): | ||
84 | op = KSOptionParser() | ||
85 | op.add_option("--nic", dest="nic", required=1) | ||
86 | return op | ||
87 | |||
88 | def parse(self, args): | ||
89 | zd = self.handler.FcoeData() | ||
90 | (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) | ||
91 | if len(extra) > 0: | ||
92 | mapping = {"command": "fcoe", "options": extra} | ||
93 | raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Unexpected arguments to %(command)s command: %(options)s") % mapping) | ||
94 | |||
95 | self._setToObj(self.op, opts, zd) | ||
96 | zd.lineno = self.lineno | ||
97 | |||
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) | ||
101 | |||
102 | return zd | ||
103 | |||
104 | def dataList(self): | ||
105 | return self.fcoe | ||
106 | |||
107 | class F13_Fcoe(F12_Fcoe): | ||
108 | removedKeywords = F12_Fcoe.removedKeywords | ||
109 | removedAttrs = F12_Fcoe.removedAttrs | ||
110 | |||
111 | def _getParser(self): | ||
112 | op = F12_Fcoe._getParser(self) | ||
113 | op.add_option("--dcb", dest="dcb", action="store_true", default=False) | ||
114 | return op | ||