diff options
Diffstat (limited to 'scripts/lib/wic/kickstart/__init__.py')
-rw-r--r-- | scripts/lib/wic/kickstart/__init__.py | 129 |
1 files changed, 0 insertions, 129 deletions
diff --git a/scripts/lib/wic/kickstart/__init__.py b/scripts/lib/wic/kickstart/__init__.py deleted file mode 100644 index 79b39fbf3f..0000000000 --- a/scripts/lib/wic/kickstart/__init__.py +++ /dev/null | |||
@@ -1,129 +0,0 @@ | |||
1 | #!/usr/bin/env python -tt | ||
2 | # | ||
3 | # Copyright (c) 2007 Red Hat, Inc. | ||
4 | # Copyright (c) 2009, 2010, 2011 Intel, Inc. | ||
5 | # | ||
6 | # This program is free software; you can redistribute it and/or modify it | ||
7 | # under the terms of the GNU General Public License as published by the Free | ||
8 | # Software Foundation; version 2 of the License | ||
9 | # | ||
10 | # This program is distributed in the hope that it will be useful, but | ||
11 | # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
12 | # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
13 | # for more details. | ||
14 | # | ||
15 | # You should have received a copy of the GNU General Public License along | ||
16 | # with this program; if not, write to the Free Software Foundation, Inc., 59 | ||
17 | # Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
18 | |||
19 | import os, sys, re | ||
20 | import shutil | ||
21 | import subprocess | ||
22 | import string | ||
23 | |||
24 | import pykickstart.sections as kssections | ||
25 | import pykickstart.commands as kscommands | ||
26 | import pykickstart.constants as ksconstants | ||
27 | import pykickstart.errors as kserrors | ||
28 | import pykickstart.parser as ksparser | ||
29 | import pykickstart.version as ksversion | ||
30 | from pykickstart.handlers.control import commandMap | ||
31 | from pykickstart.handlers.control import dataMap | ||
32 | |||
33 | from wic import msger | ||
34 | from wic.utils import errors, misc, runner, fs_related as fs | ||
35 | from custom_commands import wicboot, partition | ||
36 | |||
37 | def read_kickstart(path): | ||
38 | """Parse a kickstart file and return a KickstartParser instance. | ||
39 | |||
40 | This is a simple utility function which takes a path to a kickstart file, | ||
41 | parses it and returns a pykickstart KickstartParser instance which can | ||
42 | be then passed to an ImageCreator constructor. | ||
43 | |||
44 | If an error occurs, a CreatorError exception is thrown. | ||
45 | """ | ||
46 | |||
47 | #version = ksversion.makeVersion() | ||
48 | #ks = ksparser.KickstartParser(version) | ||
49 | |||
50 | using_version = ksversion.DEVEL | ||
51 | commandMap[using_version]["bootloader"] = wicboot.Wic_Bootloader | ||
52 | commandMap[using_version]["part"] = partition.Wic_Partition | ||
53 | commandMap[using_version]["partition"] = partition.Wic_Partition | ||
54 | dataMap[using_version]["PartData"] = partition.Wic_PartData | ||
55 | superclass = ksversion.returnClassForVersion(version=using_version) | ||
56 | |||
57 | class KSHandlers(superclass): | ||
58 | def __init__(self): | ||
59 | superclass.__init__(self, mapping=commandMap[using_version]) | ||
60 | |||
61 | kickstart = ksparser.KickstartParser(KSHandlers(), errorsAreFatal=True) | ||
62 | |||
63 | try: | ||
64 | kickstart.readKickstart(path) | ||
65 | except (kserrors.KickstartParseError, kserrors.KickstartError), err: | ||
66 | msger.warning("Errors occurred when parsing kickstart file: %s\n" % path) | ||
67 | msger.error("%s" % err) | ||
68 | |||
69 | return kickstart | ||
70 | |||
71 | def get_image_size(kickstart, default=None): | ||
72 | __size = 0 | ||
73 | for part in kickstart.handler.partition.partitions: | ||
74 | if part.mountpoint == "/" and part.size: | ||
75 | __size = part.size | ||
76 | if __size > 0: | ||
77 | return int(__size) * 1024L | ||
78 | else: | ||
79 | return default | ||
80 | |||
81 | def get_image_fstype(kickstart, default=None): | ||
82 | for part in kickstart.handler.partition.partitions: | ||
83 | if part.mountpoint == "/" and part.fstype: | ||
84 | return part.fstype | ||
85 | return default | ||
86 | |||
87 | def get_image_fsopts(kickstart, default=None): | ||
88 | for part in kickstart.handler.partition.partitions: | ||
89 | if part.mountpoint == "/" and part.fsopts: | ||
90 | return part.fsopts | ||
91 | return default | ||
92 | |||
93 | def get_timeout(kickstart, default=None): | ||
94 | if not hasattr(kickstart.handler.bootloader, "timeout"): | ||
95 | return default | ||
96 | if kickstart.handler.bootloader.timeout is None: | ||
97 | return default | ||
98 | return int(kickstart.handler.bootloader.timeout) | ||
99 | |||
100 | def get_bootloader_file(kickstart, default=None): | ||
101 | if not hasattr(kickstart.handler.bootloader, "configfile"): | ||
102 | return default | ||
103 | if kickstart.handler.bootloader.configfile is None: | ||
104 | return default | ||
105 | return kickstart.handler.bootloader.configfile | ||
106 | |||
107 | def get_kernel_args(kickstart, default="ro rd.live.image"): | ||
108 | if not hasattr(kickstart.handler.bootloader, "appendLine"): | ||
109 | return default | ||
110 | if kickstart.handler.bootloader.appendLine is None: | ||
111 | return default | ||
112 | return "%s %s" %(default, kickstart.handler.bootloader.appendLine) | ||
113 | |||
114 | def get_menu_args(kickstart, default=""): | ||
115 | if not hasattr(kickstart.handler.bootloader, "menus"): | ||
116 | return default | ||
117 | if kickstart.handler.bootloader.menus in (None, ""): | ||
118 | return default | ||
119 | return "%s" % kickstart.handler.bootloader.menus | ||
120 | |||
121 | def get_default_kernel(kickstart, default=None): | ||
122 | if not hasattr(kickstart.handler.bootloader, "default"): | ||
123 | return default | ||
124 | if not kickstart.handler.bootloader.default: | ||
125 | return default | ||
126 | return kickstart.handler.bootloader.default | ||
127 | |||
128 | def get_partitions(kickstart): | ||
129 | return kickstart.handler.partition.partitions | ||