89dad583b8c7809e07b0e5d97668632122a6a44c
[tools/mic.git] / mic / kickstart / custom_commands / partition.py
1 #!/usr/bin/python -tt
2 #
3 # Marko Saukko <marko.saukko@cybercom.com>
4 #
5 # Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 #
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.
13 #
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.
17
18 from pykickstart.commands.partition import *
19
20 class Mic_PartData(FC4_PartData):
21     removedKeywords = FC4_PartData.removedKeywords
22     removedAttrs = FC4_PartData.removedAttrs
23
24     def __init__(self, *args, **kwargs):
25         FC4_PartData.__init__(self, *args, **kwargs)
26         self.deleteRemovedAttrs()
27         self.align = kwargs.get("align", None)
28         self.extopts = kwargs.get("extopts", None)
29         self.part_type = kwargs.get("part_type", None)
30         self.uuid = kwargs.get("uuid", None)
31         self.exclude_image = kwargs.get("exclude_from_image", False)
32
33     def _getArgsAsStr(self):
34         retval = FC4_PartData._getArgsAsStr(self)
35
36         if self.align:
37             retval += " --align"
38         if self.extopts:
39             retval += " --extoptions=%s" % self.extopts
40         if self.part_type:
41             retval += " --part-type=%s" % self.part_type
42         if self.uuid:
43             retval += " --uuid=%s" % self.uuid
44         if self.exclude_image:
45             retval += " --exclude-from-image"
46
47         return retval
48
49 class Mic_Partition(FC4_Partition):
50     removedKeywords = FC4_Partition.removedKeywords
51     removedAttrs = FC4_Partition.removedAttrs
52
53     def _getParser(self):
54         op = FC4_Partition._getParser(self)
55         # The alignment value is given in kBytes. e.g., value 8 means that
56         # the partition is aligned to start from 8096 byte boundary.
57         op.add_option("--align", type="int", action="store", dest="align",
58                       default=None)
59         op.add_option("--extoptions", type="string", action="store", dest="extopts",
60                       default=None)
61         op.add_option("--part-type", type="string", action="store", dest="part_type",
62                       default=None)
63         op.add_option("--uuid", dest="uuid", action="store", type="string")
64         op.add_option("--exclude-from-image", action="store_true", dest="exclude_image",
65                       default=False)
66         return op