Error out if the same partition/repo/network is defined twice (#512956).
[pykickstart.git] / pykickstart / commands / zfcp.py
blobbfc0fe5c95458c7a1a52a5175eb6f421dc599e3a
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 *
21 from pykickstart.options import *
23 import gettext
24 _ = lambda x: gettext.ldgettext("pykickstart", x)
26 class FC3_ZFCPData(BaseData):
27 removedKeywords = BaseData.removedKeywords
28 removedAttrs = BaseData.removedAttrs
30 def __init__(self, *args, **kwargs):
31 BaseData.__init__(self, *args, **kwargs)
32 self.devnum = kwargs.get("devnum", "")
33 self.wwpn = kwargs.get("wwpn", "")
34 self.fcplun = kwargs.get("fcplun", "")
35 self.scsiid = kwargs.get("scsiid", "")
36 self.scsilun = kwargs.get("scsilun", "")
38 def __eq__(self, y):
39 return self.devnum == y.devnum and self.wwpn == y.wwpn and \
40 self.fcplun == y.fcplun and self.scsiid == y.scsiid and \
41 self.scsilun == y.scsilun
43 def __str__(self):
44 retval = BaseData.__str__(self)
45 retval += "zfcp"
47 if self.devnum != "":
48 retval += " --devnum=%s" % self.devnum
49 if self.wwpn != "":
50 retval += " --wwpn=%s" % self.wwpn
51 if self.fcplun != "":
52 retval += " --fcplun=%s" % self.fcplun
53 if self.scsiid != "":
54 retval += " --scsiid=%s" % self.scsiid
55 if self.scsilun != "":
56 retval += " --scsilun=%s" % self.scsilun
58 return retval + "\n"
60 class FC3_ZFCP(KickstartCommand):
61 removedKeywords = KickstartCommand.removedKeywords
62 removedAttrs = KickstartCommand.removedAttrs
64 def __init__(self, writePriority=71, *args, **kwargs):
65 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
66 self.op = self._getParser()
68 self.zfcp = kwargs.get("zfcp", [])
70 def __str__(self):
71 retval = ""
72 for zfcp in self.zfcp:
73 retval += zfcp.__str__()
75 return retval
77 def _getParser(self):
78 op = KSOptionParser()
79 op.add_option("--devnum", dest="devnum", required=1)
80 op.add_option("--fcplun", dest="fcplun", required=1)
81 op.add_option("--scsiid", dest="scsiid", required=1)
82 op.add_option("--scsilun", dest="scsilun", required=1)
83 op.add_option("--wwpn", dest="wwpn", required=1)
84 return op
86 def parse(self, args):
87 zd = self.handler.ZFCPData()
88 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
89 self._setToObj(self.op, opts, zd)
91 # Check for duplicates in the data list.
92 if zd in self.dataList():
93 raise KickstartValueError(_("A zfcp with this information has already been defined."))
95 return zd
97 def dataList(self):
98 return self.zfcp