Add new RHEL7 logvol objects to master
[pykickstart.git] / pykickstart / commands / zfcp.py
blob8e354c73c24faa2c37662ae9e6f1fcaa14d70aec
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 BaseData, KickstartCommand
21 from pykickstart.options import KSOptionParser
23 import gettext
24 import warnings
25 _ = lambda x: gettext.ldgettext("pykickstart", x)
27 class FC3_ZFCPData(BaseData):
28 removedKeywords = BaseData.removedKeywords
29 removedAttrs = BaseData.removedAttrs
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", "")
39 def __eq__(self, y):
40 if not y:
41 return False
43 return self.devnum == y.devnum and self.wwpn == y.wwpn and \
44 self.fcplun == y.fcplun and self.scsiid == y.scsiid and \
45 self.scsilun == y.scsilun
47 def __ne__(self, y):
48 return not self == y
50 def __str__(self):
51 retval = BaseData.__str__(self)
52 retval += "zfcp"
54 if self.devnum != "":
55 retval += " --devnum=%s" % self.devnum
56 if self.wwpn != "":
57 retval += " --wwpn=%s" % self.wwpn
58 if self.fcplun != "":
59 retval += " --fcplun=%s" % self.fcplun
60 if hasattr(self, "scsiid") and self.scsiid != "":
61 retval += " --scsiid=%s" % self.scsiid
62 if hasattr(self, "scsilun") and self.scsilun != "":
63 retval += " --scsilun=%s" % self.scsilun
65 return retval + "\n"
67 class F12_ZFCPData(FC3_ZFCPData):
68 removedKeywords = FC3_ZFCPData.removedKeywords + ["scsiid", "scsilun"]
69 removedAttrs = FC3_ZFCPData.removedAttrs + ["scsiid", "scsilun"]
71 def __init__(self, *args, **kwargs):
72 FC3_ZFCPData.__init__(self, *args, **kwargs)
73 self.deleteRemovedAttrs()
75 F14_ZFCPData = F12_ZFCPData
77 class FC3_ZFCP(KickstartCommand):
78 removedKeywords = KickstartCommand.removedKeywords
79 removedAttrs = KickstartCommand.removedAttrs
81 def __init__(self, writePriority=71, *args, **kwargs):
82 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
83 self.op = self._getParser()
85 self.zfcp = kwargs.get("zfcp", [])
87 def __str__(self):
88 retval = ""
89 for zfcp in self.zfcp:
90 retval += zfcp.__str__()
92 return retval
94 def _getParser(self):
95 op = KSOptionParser()
96 op.add_option("--devnum", dest="devnum", required=1)
97 op.add_option("--fcplun", dest="fcplun", required=1)
98 op.add_option("--scsiid", dest="scsiid", required=1)
99 op.add_option("--scsilun", dest="scsilun", required=1)
100 op.add_option("--wwpn", dest="wwpn", required=1)
101 return op
103 def parse(self, args):
104 zd = self.handler.ZFCPData()
105 (opts, _extra) = self.op.parse_args(args=args, lineno=self.lineno)
106 self._setToObj(self.op, opts, zd)
107 zd.lineno = self.lineno
109 # Check for duplicates in the data list.
110 if zd in self.dataList():
111 warnings.warn(_("A zfcp with this information has already been defined."))
113 return zd
115 def dataList(self):
116 return self.zfcp
118 class F12_ZFCP(FC3_ZFCP):
119 removedKeywords = FC3_ZFCP.removedKeywords
120 removedAttrs = FC3_ZFCP.removedAttrs + ["scsiid", "scsilun"]
122 def __init__(self, *args, **kwargs):
123 FC3_ZFCP.__init__(self, *args, **kwargs)
124 self.deleteRemovedAttrs()
126 def _getParser(self):
127 op = FC3_ZFCP._getParser(self)
128 op.add_option("--scsiid", deprecated=1)
129 op.add_option("--scsilun", deprecated=1)
130 return op
132 class F14_ZFCP(F12_ZFCP):
133 removedKeywords = F12_ZFCP.removedKeywords
134 removedAttrs = F12_ZFCP.removedAttrs
136 def _getParser(self):
137 op = F12_ZFCP._getParser(self)
138 op.remove_option("--scsiid")
139 op.remove_option("--scsilun")
140 return op