summaryrefslogtreecommitdiffstats
path: root/scripts/lib/mic/3rdparty/pykickstart/commands/method.py
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/lib/mic/3rdparty/pykickstart/commands/method.py')
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/method.py186
1 files changed, 186 insertions, 0 deletions
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/method.py b/scripts/lib/mic/3rdparty/pykickstart/commands/method.py
new file mode 100644
index 0000000000..e21064acda
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/method.py
@@ -0,0 +1,186 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2007, 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#
20from pykickstart.base import *
21from pykickstart.errors import *
22from pykickstart.options import *
23
24import gettext
25_ = lambda x: gettext.ldgettext("pykickstart", x)
26
27class FC3_Method(KickstartCommand):
28 removedKeywords = KickstartCommand.removedKeywords
29 removedAttrs = KickstartCommand.removedAttrs
30
31 def __init__(self, writePriority=0, *args, **kwargs):
32 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
33 self.method = kwargs.get("method", "")
34
35 # Set all these attributes so calls to this command's __call__
36 # method can set them. However we don't want to provide them as
37 # arguments to __init__ because method is special.
38 self.biospart = None
39 self.partition = None
40 self.server = None
41 self.dir = None
42 self.url = None
43
44 def __str__(self):
45 retval = KickstartCommand.__str__(self)
46
47 if self.method == "cdrom":
48 retval += "# Use CDROM installation media\ncdrom\n"
49 elif self.method == "harddrive":
50 msg = "# Use hard drive installation media\nharddrive --dir=%s" % self.dir
51
52 if self.biospart is not None:
53 retval += msg + " --biospart=%s\n" % self.biospart
54 else:
55 retval += msg + " --partition=%s\n" % self.partition
56 elif self.method == "nfs":
57 retval += "# Use NFS installation media\nnfs --server=%s --dir=%s\n" % (self.server, self.dir)
58 elif self.method == "url":
59 retval += "# Use network installation\nurl --url=\"%s\"\n" % self.url
60
61 return retval
62
63 def _getParser(self):
64 op = KSOptionParser()
65
66 # method = "cdrom" falls through to the return
67 if self.currentCmd == "harddrive":
68 op.add_option("--biospart", dest="biospart")
69 op.add_option("--partition", dest="partition")
70 op.add_option("--dir", dest="dir", required=1)
71 elif self.currentCmd == "nfs":
72 op.add_option("--server", dest="server", required=1)
73 op.add_option("--dir", dest="dir", required=1)
74 elif self.currentCmd == "url":
75 op.add_option("--url", dest="url", required=1)
76
77 return op
78
79 def parse(self, args):
80 self.method = self.currentCmd
81
82 op = self._getParser()
83 (opts, extra) = op.parse_args(args=args, lineno=self.lineno)
84 self._setToSelf(op, opts)
85
86 if self.currentCmd == "harddrive":
87 if self.biospart is None and self.partition is None or \
88 self.biospart is not None and self.partition is not None:
89 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of biospart or partition options must be specified."))
90
91 return self
92
93class FC6_Method(FC3_Method):
94 removedKeywords = FC3_Method.removedKeywords
95 removedAttrs = FC3_Method.removedAttrs
96
97 def __init__(self, writePriority=0, *args, **kwargs):
98 FC3_Method.__init__(self, writePriority, *args, **kwargs)
99
100 # Same reason for this attribute as the comment in FC3_Method.
101 self.opts = None
102
103 def __str__(self):
104 retval = KickstartCommand.__str__(self)
105
106 if self.method == "cdrom":
107 retval += "# Use CDROM installation media\ncdrom\n"
108 elif self.method == "harddrive":
109 msg = "# Use hard drive installation media\nharddrive --dir=%s" % self.dir
110
111 if self.biospart is not None:
112 retval += msg + " --biospart=%s\n" % self.biospart
113 else:
114 retval += msg + " --partition=%s\n" % self.partition
115 elif self.method == "nfs":
116 retval += "# Use NFS installation media\nnfs --server=%s --dir=%s" % (self.server, self.dir)
117 if self.opts is not None:
118 retval += " --opts=\"%s\"" % self.opts
119 retval += "\n"
120 elif self.method == "url":
121 retval += "# Use network installation\nurl --url=\"%s\"\n" % self.url
122
123 return retval
124
125 def _getParser(self):
126 op = FC3_Method._getParser(self)
127
128 if self.currentCmd == "nfs":
129 op.add_option("--opts", dest="opts")
130
131 return op
132
133class F13_Method(FC6_Method):
134 removedKeywords = FC6_Method.removedKeywords
135 removedAttrs = FC6_Method.removedAttrs
136
137 def __init__(self, *args, **kwargs):
138 FC6_Method.__init__(self, *args, **kwargs)
139
140 # And same as all the other __init__ methods.
141 self.proxy = ""
142
143 def __str__(self):
144 retval = FC6_Method.__str__(self)
145
146 if self.method == "url" and self.proxy:
147 retval = retval.strip()
148 retval += " --proxy=\"%s\"\n" % self.proxy
149
150 return retval
151
152 def _getParser(self):
153 op = FC6_Method._getParser(self)
154
155 if self.currentCmd == "url":
156 op.add_option("--proxy")
157
158 return op
159
160class F14_Method(F13_Method):
161 removedKeywords = F13_Method.removedKeywords
162 removedAttrs = F13_Method.removedAttrs
163
164 def __init__(self, *args, **kwargs):
165 F13_Method.__init__(self, *args, **kwargs)
166
167 self.noverifyssl = False
168
169 def __str__(self):
170 retval = F13_Method.__str__(self)
171
172 if self.method == "url" and self.noverifyssl:
173 retval = retval.strip()
174 retval += " --noverifyssl\n"
175
176 return retval
177
178 def _getParser(self):
179 op = F13_Method._getParser(self)
180
181 if self.currentCmd == "url":
182 op.add_option("--noverifyssl", action="store_true", default=False)
183
184 return op
185
186RHEL6_Method = F14_Method