summaryrefslogtreecommitdiffstats
path: root/scripts/lib/mic/3rdparty/pykickstart/commands/logvol.py
diff options
context:
space:
mode:
authorTom Zanussi <tom.zanussi@linux.intel.com>2013-08-24 15:31:34 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-10-01 22:56:03 +0100
commit9fc88f96d40b17c90bac53b90045a87b2d2cff84 (patch)
tree63010e5aabf895697655baf89bd668d6752b3f97 /scripts/lib/mic/3rdparty/pykickstart/commands/logvol.py
parent53a1d9a788fd9f970af980da2ab975cca60685c4 (diff)
downloadpoky-9fc88f96d40b17c90bac53b90045a87b2d2cff84.tar.gz
wic: Add mic w/pykickstart
This is the starting point for the implemention described in [YOCTO 3847] which came to the conclusion that it would make sense to use kickstart syntax to implement image creation in OpenEmbedded. I subsequently realized that there was an existing tool that already implemented image creation using kickstart syntax, the Tizen/Meego mic tool. As such, it made sense to use that as a starting point - this commit essentially just copies the relevant Python code from the MIC tool to the scripts/lib dir, where it can be accessed by the previously created wic tool. Most of this will be removed or renamed by later commits, since we're initially focusing on partitioning only. Care should be taken so that we can easily add back any additional functionality should we decide later to expand the tool, though (we may also want to contribute our local changes to the mic tool to the Tizen project if it makes sense, and therefore should avoid gratuitous changes to the original code if possible). Added the /mic subdir from Tizen mic repo as a starting point: git clone git://review.tizen.org/tools/mic.git For reference, the top commit: commit 20164175ddc234a17b8a12c33d04b012347b1530 Author: Gui Chen <gui.chen@intel.com> Date: Sun Jun 30 22:32:16 2013 -0400 bump up to 0.19.2 Also added the /plugins subdir, moved to under the /mic subdir (to match the default plugin_dir location in mic.conf.in, which was renamed to yocto-image.conf (moved and renamed by later patches) and put into /scripts. (From OE-Core rev: 31f0360f1fd4ebc9dfcaed42d1c50d2448b4632e) Signed-off-by: Tom Zanussi <tom.zanussi@linux.intel.com> Signed-off-by: Saul Wold <sgw@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/lib/mic/3rdparty/pykickstart/commands/logvol.py')
-rw-r--r--scripts/lib/mic/3rdparty/pykickstart/commands/logvol.py304
1 files changed, 304 insertions, 0 deletions
diff --git a/scripts/lib/mic/3rdparty/pykickstart/commands/logvol.py b/scripts/lib/mic/3rdparty/pykickstart/commands/logvol.py
new file mode 100644
index 0000000000..c1b9cc3a61
--- /dev/null
+++ b/scripts/lib/mic/3rdparty/pykickstart/commands/logvol.py
@@ -0,0 +1,304 @@
1#
2# Chris Lumens <clumens@redhat.com>
3#
4# Copyright 2005, 2006, 2007, 2008 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
25import warnings
26_ = lambda x: gettext.ldgettext("pykickstart", x)
27
28class FC3_LogVolData(BaseData):
29 removedKeywords = BaseData.removedKeywords
30 removedAttrs = BaseData.removedAttrs
31
32 def __init__(self, *args, **kwargs):
33 BaseData.__init__(self, *args, **kwargs)
34 self.fstype = kwargs.get("fstype", "")
35 self.grow = kwargs.get("grow", False)
36 self.maxSizeMB = kwargs.get("maxSizeMB", 0)
37 self.name = kwargs.get("name", "")
38 self.format = kwargs.get("format", True)
39 self.percent = kwargs.get("percent", 0)
40 self.recommended = kwargs.get("recommended", False)
41 self.size = kwargs.get("size", None)
42 self.preexist = kwargs.get("preexist", False)
43 self.vgname = kwargs.get("vgname", "")
44 self.mountpoint = kwargs.get("mountpoint", "")
45
46 def __eq__(self, y):
47 return self.vgname == y.vgname and self.name == y.name
48
49 def _getArgsAsStr(self):
50 retval = ""
51
52 if self.fstype != "":
53 retval += " --fstype=\"%s\"" % self.fstype
54 if self.grow:
55 retval += " --grow"
56 if self.maxSizeMB > 0:
57 retval += " --maxsize=%d" % self.maxSizeMB
58 if not self.format:
59 retval += " --noformat"
60 if self.percent > 0:
61 retval += " --percent=%d" % self.percent
62 if self.recommended:
63 retval += " --recommended"
64 if self.size > 0:
65 retval += " --size=%d" % self.size
66 if self.preexist:
67 retval += " --useexisting"
68
69 return retval
70
71 def __str__(self):
72 retval = BaseData.__str__(self)
73 retval += "logvol %s %s --name=%s --vgname=%s\n" % (self.mountpoint, self._getArgsAsStr(), self.name, self.vgname)
74 return retval
75
76class FC4_LogVolData(FC3_LogVolData):
77 removedKeywords = FC3_LogVolData.removedKeywords
78 removedAttrs = FC3_LogVolData.removedAttrs
79
80 def __init__(self, *args, **kwargs):
81 FC3_LogVolData.__init__(self, *args, **kwargs)
82 self.bytesPerInode = kwargs.get("bytesPerInode", 4096)
83 self.fsopts = kwargs.get("fsopts", "")
84
85 def _getArgsAsStr(self):
86 retval = FC3_LogVolData._getArgsAsStr(self)
87
88 if hasattr(self, "bytesPerInode") and self.bytesPerInode != 0:
89 retval += " --bytes-per-inode=%d" % self.bytesPerInode
90 if self.fsopts != "":
91 retval += " --fsoptions=\"%s\"" % self.fsopts
92
93 return retval
94
95class RHEL5_LogVolData(FC4_LogVolData):
96 removedKeywords = FC4_LogVolData.removedKeywords
97 removedAttrs = FC4_LogVolData.removedAttrs
98
99 def __init__(self, *args, **kwargs):
100 FC4_LogVolData.__init__(self, *args, **kwargs)
101 self.encrypted = kwargs.get("encrypted", False)
102 self.passphrase = kwargs.get("passphrase", "")
103
104 def _getArgsAsStr(self):
105 retval = FC4_LogVolData._getArgsAsStr(self)
106
107 if self.encrypted:
108 retval += " --encrypted"
109
110 if self.passphrase != "":
111 retval += " --passphrase=\"%s\"" % self.passphrase
112
113 return retval
114
115class F9_LogVolData(FC4_LogVolData):
116 removedKeywords = FC4_LogVolData.removedKeywords + ["bytesPerInode"]
117 removedAttrs = FC4_LogVolData.removedAttrs + ["bytesPerInode"]
118
119 def __init__(self, *args, **kwargs):
120 FC4_LogVolData.__init__(self, *args, **kwargs)
121 self.deleteRemovedAttrs()
122
123 self.fsopts = kwargs.get("fsopts", "")
124 self.fsprofile = kwargs.get("fsprofile", "")
125 self.encrypted = kwargs.get("encrypted", False)
126 self.passphrase = kwargs.get("passphrase", "")
127
128 def _getArgsAsStr(self):
129 retval = FC4_LogVolData._getArgsAsStr(self)
130
131 if self.fsprofile != "":
132 retval += " --fsprofile=\"%s\"" % self.fsprofile
133 if self.encrypted:
134 retval += " --encrypted"
135
136 if self.passphrase != "":
137 retval += " --passphrase=\"%s\"" % self.passphrase
138
139 return retval
140
141class F12_LogVolData(F9_LogVolData):
142 removedKeywords = F9_LogVolData.removedKeywords
143 removedAttrs = F9_LogVolData.removedAttrs
144
145 def __init__(self, *args, **kwargs):
146 F9_LogVolData.__init__(self, *args, **kwargs)
147 self.deleteRemovedAttrs()
148
149 self.escrowcert = kwargs.get("escrowcert", "")
150 self.backuppassphrase = kwargs.get("backuppassphrase", False)
151
152 def _getArgsAsStr(self):
153 retval = F9_LogVolData._getArgsAsStr(self)
154
155 if self.encrypted and self.escrowcert != "":
156 retval += " --escrowcert=\"%s\"" % self.escrowcert
157
158 if self.backuppassphrase:
159 retval += " --backuppassphrase"
160
161 return retval
162
163F14_LogVolData = F12_LogVolData
164
165class F15_LogVolData(F14_LogVolData):
166 removedKeywords = F14_LogVolData.removedKeywords
167 removedAttrs = F14_LogVolData.removedAttrs
168
169 def __init__(self, *args, **kwargs):
170 F14_LogVolData.__init__(self, *args, **kwargs)
171 self.label = kwargs.get("label", "")
172
173 def _getArgsAsStr(self):
174 retval = F14_LogVolData._getArgsAsStr(self)
175
176 if self.label != "":
177 retval += " --label=\"%s\"" % self.label
178
179 return retval
180
181class FC3_LogVol(KickstartCommand):
182 removedKeywords = KickstartCommand.removedKeywords
183 removedAttrs = KickstartCommand.removedAttrs
184
185 def __init__(self, writePriority=133, *args, **kwargs):
186 KickstartCommand.__init__(self, writePriority, *args, **kwargs)
187 self.op = self._getParser()
188
189 self.lvList = kwargs.get("lvList", [])
190
191 def __str__(self):
192 retval = ""
193
194 for part in self.lvList:
195 retval += part.__str__()
196
197 return retval
198
199 def _getParser(self):
200 def lv_cb (option, opt_str, value, parser):
201 parser.values.format = False
202 parser.values.preexist = True
203
204 op = KSOptionParser()
205 op.add_option("--fstype", dest="fstype")
206 op.add_option("--grow", dest="grow", action="store_true",
207 default=False)
208 op.add_option("--maxsize", dest="maxSizeMB", action="store", type="int",
209 nargs=1)
210 op.add_option("--name", dest="name", required=1)
211 op.add_option("--noformat", action="callback", callback=lv_cb,
212 dest="format", default=True, nargs=0)
213 op.add_option("--percent", dest="percent", action="store", type="int",
214 nargs=1)
215 op.add_option("--recommended", dest="recommended", action="store_true",
216 default=False)
217 op.add_option("--size", dest="size", action="store", type="int",
218 nargs=1)
219 op.add_option("--useexisting", dest="preexist", action="store_true",
220 default=False)
221 op.add_option("--vgname", dest="vgname", required=1)
222 return op
223
224 def parse(self, args):
225 (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
226
227 if len(extra) == 0:
228 raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("Mount point required for %s") % "logvol")
229
230 lvd = self.handler.LogVolData()
231 self._setToObj(self.op, opts, lvd)
232 lvd.lineno = self.lineno
233 lvd.mountpoint=extra[0]
234
235 # Check for duplicates in the data list.
236 if lvd in self.dataList():
237 warnings.warn(_("A logical volume with the name %s has already been defined in volume group %s.") % (lvd.device, lvd.vgname))
238
239 return lvd
240
241 def dataList(self):
242 return self.lvList
243
244class FC4_LogVol(FC3_LogVol):
245 removedKeywords = FC3_LogVol.removedKeywords
246 removedAttrs = FC3_LogVol.removedAttrs
247
248 def _getParser(self):
249 op = FC3_LogVol._getParser(self)
250 op.add_option("--bytes-per-inode", dest="bytesPerInode", action="store",
251 type="int", nargs=1)
252 op.add_option("--fsoptions", dest="fsopts")
253 return op
254
255class RHEL5_LogVol(FC4_LogVol):
256 removedKeywords = FC4_LogVol.removedKeywords
257 removedAttrs = FC4_LogVol.removedAttrs
258
259 def _getParser(self):
260 op = FC4_LogVol._getParser(self)
261 op.add_option("--encrypted", action="store_true", default=False)
262 op.add_option("--passphrase")
263 return op
264
265class F9_LogVol(FC4_LogVol):
266 removedKeywords = FC4_LogVol.removedKeywords
267 removedAttrs = FC4_LogVol.removedAttrs
268
269 def _getParser(self):
270 op = FC4_LogVol._getParser(self)
271 op.add_option("--bytes-per-inode", deprecated=1)
272 op.add_option("--fsprofile", dest="fsprofile", action="store",
273 type="string", nargs=1)
274 op.add_option("--encrypted", action="store_true", default=False)
275 op.add_option("--passphrase")
276 return op
277
278class F12_LogVol(F9_LogVol):
279 removedKeywords = F9_LogVol.removedKeywords
280 removedAttrs = F9_LogVol.removedAttrs
281
282 def _getParser(self):
283 op = F9_LogVol._getParser(self)
284 op.add_option("--escrowcert")
285 op.add_option("--backuppassphrase", action="store_true", default=False)
286 return op
287
288class F14_LogVol(F12_LogVol):
289 removedKeywords = F12_LogVol.removedKeywords
290 removedAttrs = F12_LogVol.removedAttrs
291
292 def _getParser(self):
293 op = F12_LogVol._getParser(self)
294 op.remove_option("--bytes-per-inode")
295 return op
296
297class F15_LogVol(F14_LogVol):
298 removedKeywords = F14_LogVol.removedKeywords
299 removedAttrs = F14_LogVol.removedAttrs
300
301 def _getParser(self):
302 op = F14_LogVol._getParser(self)
303 op.add_option("--label")
304 return op