2 # Chris Lumens <clumens@redhat.com>
3 # Peter Jones <pjones@redhat.com>
5 # Copyright 2005, 2006, 2007 Red Hat, Inc.
7 # This copyrighted material is made available to anyone wishing to use, modify,
8 # copy, or redistribute it subject to the terms and conditions of the GNU
9 # General Public License v.2. This program is distributed in the hope that it
10 # will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
11 # implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 # See the GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License along with
15 # this program; if not, write to the Free Software Foundation, Inc., 51
16 # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Any Red Hat
17 # trademarks that are incorporated in the source code or documentation are not
18 # subject to the GNU General Public License and may only be used or replicated
19 # with the express permission of Red Hat, Inc.
21 from imgcreate
.pykickstart
.base
import *
22 from imgcreate
.pykickstart
.errors
import *
23 from imgcreate
.pykickstart
.options
import *
26 _
= lambda x
: gettext
.ldgettext("pykickstart", x
)
28 class FC6_IscsiData(BaseData
):
29 def __init__(self
, ipaddr
="", port
="", target
="", user
=None, password
=None):
30 BaseData
.__init
__(self
)
35 self
.password
= password
37 def _getArgsAsStr(self
):
41 retval
+= " --target=%s" % self
.target
43 retval
+= " --ipaddr=%s" % self
.ipaddr
45 retval
+= " --port=%s" % self
.port
46 if self
.user
is not None:
47 retval
+= " --user=%s" % self
.user
48 if self
.password
is not None:
49 retval
+= " --password=%s" % self
.password
54 return "iscsi%s\n" % self
._getArgsAsStr
()
56 class F10_IscsiData(FC6_IscsiData
):
57 def __init__(self
, ipaddr
="", port
="", target
="", user
=None, password
=None,
58 user_in
=None, password_in
=None):
59 FC6_IscsiData
.__init
__(self
, ipaddr
=ipaddr
, port
=port
, user
=user
,
61 self
.user_in
= user_in
62 self
.password_in
= password_in
64 def _getArgsAsStr(self
):
65 retval
= FC6_IscsiData
._getArgsAsStr
(self
)
67 if self
.user_in
is not None:
68 retval
+= " --reverse-user=%s" % self
.user_in
69 if self
.password_in
is not None:
70 retval
+= " --reverse-password=%s" % self
.password_in
74 class FC6_Iscsi(KickstartCommand
):
75 def __init__(self
, writePriority
=71, iscsi
=None):
76 KickstartCommand
.__init
__(self
, writePriority
)
77 self
.op
= self
._getParser
()
86 for iscsi
in self
.iscsi
:
87 retval
+= iscsi
.__str
__()
92 op
= KSOptionParser(lineno
=self
.lineno
)
93 op
.add_option("--target", dest
="target", action
="store", type="string")
94 op
.add_option("--ipaddr", dest
="ipaddr", action
="store", type="string",
96 op
.add_option("--port", dest
="port", action
="store", type="string")
97 op
.add_option("--user", dest
="user", action
="store", type="string")
98 op
.add_option("--password", dest
="password", action
="store",
102 def parse(self
, args
):
103 (opts
, extra
) = self
.op
.parse_args(args
=args
)
106 mapping
= {"command": "scsi", "options": extra
}
107 raise KickstartValueError
, formatErrorMsg(self
.lineno
, msg
=_("Unexpected arguments to %(command)s command: %(options)s") % mapping
)
109 dd
= self
.handler
.IscsiData()
110 self
._setToObj
(self
.op
, opts
, dd
)
113 def add(self
, newObj
):
114 self
.iscsi
.append(newObj
)
116 class F10_Iscsi(FC6_Iscsi
):
117 def __init__(self
, writePriority
=71, iscsi
=None):
118 FC6_Iscsi
.__init
__(self
, writePriority
, iscsi
)
120 def _getParser(self
):
121 op
= FC6_Iscsi
._getParser
(self
)
122 op
.add_option("--reverse-user", dest
="user_in", action
="store",
124 op
.add_option("--reverse-password", dest
="password_in", action
="store",