diff options
author | Adrian Dudau <adrian.dudau@enea.com> | 2014-06-26 14:36:22 +0200 |
---|---|---|
committer | Adrian Dudau <adrian.dudau@enea.com> | 2014-06-26 15:32:53 +0200 |
commit | f4cf9fe05bb3f32fabea4e54dd92d368967a80da (patch) | |
tree | 487180fa9866985ea7b28e625651765d86f515c3 /scripts/lib/mic/3rdparty/pykickstart/commands/zfcp.py | |
download | poky-f4cf9fe05bb3f32fabea4e54dd92d368967a80da.tar.gz |
initial commit for Enea Linux 4.0
Migrated from the internal git server on the daisy-enea branch
Signed-off-by: Adrian Dudau <adrian.dudau@enea.com>
Diffstat (limited to 'scripts/lib/mic/3rdparty/pykickstart/commands/zfcp.py')
-rw-r--r-- | scripts/lib/mic/3rdparty/pykickstart/commands/zfcp.py | 134 |
1 files changed, 134 insertions, 0 deletions
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/zfcp.py b/scripts/lib/mic/3rdparty/pykickstart/commands/zfcp.py new file mode 100644 index 0000000000..1ed2694c89 --- /dev/null +++ b/scripts/lib/mic/3rdparty/pykickstart/commands/zfcp.py | |||
@@ -0,0 +1,134 @@ | |||
1 | # | ||
2 | # Chris Lumens <clumens@redhat.com> | ||
3 | # | ||
4 | # Copyright 2005, 2006, 2007 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 FC3_ZFCPData(BaseData): | ||
28 | removedKeywords = BaseData.removedKeywords | ||
29 | removedAttrs = BaseData.removedAttrs | ||
30 | |||
31 | def __init__(self, *args, **kwargs): | ||
32 | BaseData.__init__(self, *args, **kwargs) | ||
33 | self.devnum = kwargs.get("devnum", "") | ||
34 | self.wwpn = kwargs.get("wwpn", "") | ||
35 | self.fcplun = kwargs.get("fcplun", "") | ||
36 | self.scsiid = kwargs.get("scsiid", "") | ||
37 | self.scsilun = kwargs.get("scsilun", "") | ||
38 | |||
39 | def __eq__(self, y): | ||
40 | return self.devnum == y.devnum and self.wwpn == y.wwpn and \ | ||
41 | self.fcplun == y.fcplun and self.scsiid == y.scsiid and \ | ||
42 | self.scsilun == y.scsilun | ||
43 | |||
44 | def __str__(self): | ||
45 | retval = BaseData.__str__(self) | ||
46 | retval += "zfcp" | ||
47 | |||
48 | if self.devnum != "": | ||
49 | retval += " --devnum=%s" % self.devnum | ||
50 | if self.wwpn != "": | ||
51 | retval += " --wwpn=%s" % self.wwpn | ||
52 | if self.fcplun != "": | ||
53 | retval += " --fcplun=%s" % self.fcplun | ||
54 | if hasattr(self, "scsiid") and self.scsiid != "": | ||
55 | retval += " --scsiid=%s" % self.scsiid | ||
56 | if hasattr(self, "scsilun") and self.scsilun != "": | ||
57 | retval += " --scsilun=%s" % self.scsilun | ||
58 | |||
59 | return retval + "\n" | ||
60 | |||
61 | class F12_ZFCPData(FC3_ZFCPData): | ||
62 | removedKeywords = FC3_ZFCPData.removedKeywords + ["scsiid", "scsilun"] | ||
63 | removedAttrs = FC3_ZFCPData.removedAttrs + ["scsiid", "scsilun"] | ||
64 | |||
65 | def __init__(self, *args, **kwargs): | ||
66 | FC3_ZFCPData.__init__(self, *args, **kwargs) | ||
67 | self.deleteRemovedAttrs() | ||
68 | |||
69 | F14_ZFCPData = F12_ZFCPData | ||
70 | |||
71 | class FC3_ZFCP(KickstartCommand): | ||
72 | removedKeywords = KickstartCommand.removedKeywords | ||
73 | removedAttrs = KickstartCommand.removedAttrs | ||
74 | |||
75 | def __init__(self, writePriority=71, *args, **kwargs): | ||
76 | KickstartCommand.__init__(self, writePriority, *args, **kwargs) | ||
77 | self.op = self._getParser() | ||
78 | |||
79 | self.zfcp = kwargs.get("zfcp", []) | ||
80 | |||
81 | def __str__(self): | ||
82 | retval = "" | ||
83 | for zfcp in self.zfcp: | ||
84 | retval += zfcp.__str__() | ||
85 | |||
86 | return retval | ||
87 | |||
88 | def _getParser(self): | ||
89 | op = KSOptionParser() | ||
90 | op.add_option("--devnum", dest="devnum", required=1) | ||
91 | op.add_option("--fcplun", dest="fcplun", required=1) | ||
92 | op.add_option("--scsiid", dest="scsiid", required=1) | ||
93 | op.add_option("--scsilun", dest="scsilun", required=1) | ||
94 | op.add_option("--wwpn", dest="wwpn", required=1) | ||
95 | return op | ||
96 | |||
97 | def parse(self, args): | ||
98 | zd = self.handler.ZFCPData() | ||
99 | (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno) | ||
100 | self._setToObj(self.op, opts, zd) | ||
101 | zd.lineno = self.lineno | ||
102 | |||
103 | # Check for duplicates in the data list. | ||
104 | if zd in self.dataList(): | ||
105 | warnings.warn(_("A zfcp with this information has already been defined.")) | ||
106 | |||
107 | return zd | ||
108 | |||
109 | def dataList(self): | ||
110 | return self.zfcp | ||
111 | |||
112 | class F12_ZFCP(FC3_ZFCP): | ||
113 | removedKeywords = FC3_ZFCP.removedKeywords | ||
114 | removedAttrs = FC3_ZFCP.removedAttrs + ["scsiid", "scsilun"] | ||
115 | |||
116 | def __init__(self, *args, **kwargs): | ||
117 | FC3_ZFCP.__init__(self, *args, **kwargs) | ||
118 | self.deleteRemovedAttrs() | ||
119 | |||
120 | def _getParser(self): | ||
121 | op = FC3_ZFCP._getParser(self) | ||
122 | op.add_option("--scsiid", deprecated=1) | ||
123 | op.add_option("--scsilun", deprecated=1) | ||
124 | return op | ||
125 | |||
126 | class F14_ZFCP(F12_ZFCP): | ||
127 | removedKeywords = F12_ZFCP.removedKeywords | ||
128 | removedAttrs = F12_ZFCP.removedAttrs | ||
129 | |||
130 | def _getParser(self): | ||
131 | op = F12_ZFCP._getParser(self) | ||
132 | op.remove_option("--scsiid") | ||
133 | op.remove_option("--scsilun") | ||
134 | return op | ||