/[smeserver]/cdrom.image/updates/dispatch.py
ViewVC logotype

Contents of /cdrom.image/updates/dispatch.py

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.6 - (show annotations) (download) (as text)
Fri Jun 9 05:02:59 2006 UTC (18 years, 4 months ago) by gordonr
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +0 -0 lines
Content type: text/x-python
FILE REMOVED
See bug 1510 - all changes should be in the anaconda CVS repository

1 #
2 # dispatch.py: install/upgrade master flow control
3 #
4 # Erik Troan <ewt@redhat.com>
5 #
6 # Copyright 2001-2002 Red Hat, Inc.
7 #
8 # This software may be freely redistributed under the terms of the GNU
9 # library public license.
10 #
11 # You should have received a copy of the GNU Library Public License
12 # along with this program; if not, write to the Free Software
13 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
14 #
15
16 import string
17 from types import *
18 from constants import *
19 from packages import readPackages, checkDependencies, doInstall
20 from packages import handleX11Packages, writeConfiguration, writeXConfiguration
21 from packages import checkMonitorOK, setSaneXSettings
22 from packages import writeKSConfiguration, turnOnFilesystems
23 from packages import doMigrateFilesystems
24 from packages import queryUpgradeContinue
25 from packages import doPreInstall, doPostInstall, doPostAction,copyAnacondaLogs
26 from autopart import doAutoPartition
27 from packages import firstbootConfiguration
28 from packages import betaNagScreen
29 from packages import selectLanguageSupportGroups
30 from packages import setupTimezone
31 from packages import setFileCons
32 from partitioning import partitionMethodSetup, partitionObjectsInitialize
33 from partitioning import partitioningComplete
34 from floppy import makeBootdisk
35 from bootloader import writeBootloader, bootloaderSetupChoices
36 from flags import flags
37 from upgrade import upgradeFindPackages, upgradeMountFilesystems
38 from upgrade import upgradeSwapSuggestion, upgradeMigrateFind
39 from upgrade import findRootParts
40 from network import networkDeviceCheck
41 from installmethod import doMethodComplete
42
43 from rhpl.log import log
44
45 # These are all of the install steps, in order. Note that upgrade and
46 # install steps are the same thing! Upgrades skip install steps, while
47 # installs skip upgrade steps.
48
49 #
50 # items are one of
51 #
52 # ( name, tuple)
53 # ( name, Function, tuple)
54 #
55 # in the second case, the function is called directly from the dispatcher
56
57 installSteps = [
58 ("welcome", ("id.configFileData",)),
59 ("betanag", betaNagScreen, ("intf", "dir")),
60 ("language", ("intf", "id.instLanguage")),
61 ("keyboard", ("id.instLanguage.getDefaultKeyboard()", "id.keyboard")),
62 ("checkmonitorok", checkMonitorOK, ("id.monitor", "dispatch")),
63 ("monitor", ("id.xsetup", "id.monitor", "intf")),
64 ("setsanex", setSaneXSettings, ("id.xsetup",)),
65 ("findrootparts", findRootParts, ("intf", "id", "dispatch", "dir", "instPath")),
66 ("findinstall", ("dispatch", "intf", "id", "instPath")),
67 ("installtype", ("dispatch", "id", "method", "intf")),
68 ("zfcpconfig", ("id.zfcp", "id.diskset", "intf")),
69 ("partitionmethod", ("id.partitions", "id.instClass")),
70 ("partitionobjinit", partitionObjectsInitialize, ("id.diskset",
71 "id.partitions",
72 "dir", "intf")),
73 ("partitionmethodsetup", partitionMethodSetup, ("id.partitions",
74 "dispatch")),
75 ("autopartition", ("id.diskset", "id.partitions", "intf", "dispatch")),
76 ("autopartitionexecute", doAutoPartition, ("dir", "id.diskset",
77 "id.partitions", "intf",
78 "id.instClass", "dispatch")),
79 ("fdisk", ("id.diskset", "id.partitions", "intf")),
80 ("fdasd", ("id.diskset", "id.partitions", "intf")),
81 ("partition", ("id.fsset", "id.diskset", "id.partitions", "intf")),
82 ("upgrademount", upgradeMountFilesystems, ("intf", "id.upgradeRoot",
83 "id.fsset", "instPath")),
84 ("upgradecontinue", queryUpgradeContinue, ("intf", "dir")),
85 ("upgradeswapsuggestion", upgradeSwapSuggestion, ("dispatch", "id",
86 "instPath")),
87 ("addswap", ("intf", "id.fsset", "instPath",
88 "id.upgradeSwapInfo", "dispatch")),
89 ("partitiondone", partitioningComplete, ("id.bootloader", "id.fsset",
90 "id.diskset", "id.partitions",
91 "intf", "instPath", "dir")),
92 ("upgrademigfind", upgradeMigrateFind, ("dispatch", "id.fsset")),
93 ("upgrademigratefs", ("id.fsset",)),
94 ("upgbootloader", ("dispatch", "id.bootloader")),
95 ("bootloadersetup", bootloaderSetupChoices, ("dispatch", "id.bootloader",
96 "id.fsset", "id.diskset",
97 "dir")),
98 ("bootloader", ("dispatch", "id.bootloader", "id.fsset", "id.diskset")),
99 ("bootloaderadvanced", ("dispatch", "id.bootloader", "id.fsset",
100 "id.diskset")),
101 ("networkdevicecheck", networkDeviceCheck, ("id.network", "dispatch")),
102 ("network", ("id.network", "dir", "intf", "id")),
103 ("firewall", ("intf", "id.network", "id.firewall", "id.security")),
104 ("languagesupport", ("id.langSupport",)),
105 ("timezone", ("id.instLanguage", "id.timezone")),
106 ("accounts", ("intf", "id.rootPassword")),
107 ("authentication", ("id.auth",)),
108 ("readcomps", readPackages, ("intf", "method", "id")),
109 ("desktopchoice", ("intf", "id.instClass", "dispatch", "id.grpset")),
110 ("findpackages", upgradeFindPackages, ("intf", "method", "id",
111 "instPath", "dir")),
112 ("selectlangpackages", selectLanguageSupportGroups, ("id.grpset","id.langSupport")),
113 ("package-selection", ("id.grpset", "id.langSupport", "id.instClass", "dispatch")),
114 ("indivpackage", ("id.grpset",)),
115 ("handleX11pkgs", handleX11Packages, ("dir", "intf", "dispatch",
116 "id", "instPath")),
117 ("checkdeps", checkDependencies, ("dir", "intf", "dispatch",
118 "id", "instPath")),
119 ("dependencies", ("id.grpset", "id.dependencies")),
120 ("confirminstall", ("intf", "id",)),
121 ("confirmupgrade", ("intf", "id",)),
122 ("install", ("dir", "intf", "id")),
123 ("enablefilesystems", turnOnFilesystems, ("dir", "id.fsset",
124 "id.diskset", "id.partitions",
125 "id.upgrade", "instPath")),
126 ("migratefilesystems", doMigrateFilesystems, ("dir", "id.fsset",
127 "id.diskset", "id.upgrade",
128 "instPath")),
129 ("setuptime", setupTimezone, ("id.timezone", "id.upgrade", "instPath",
130 "dir")),
131 ("preinstallconfig", doPreInstall, ("method", "id", "intf", "instPath",
132 "dir")),
133 ("installpackages", doInstall, ("method", "id", "intf", "instPath")),
134 ("postinstallconfig", doPostInstall, ("method", "id", "intf", "instPath")),
135 ("writeconfig", writeConfiguration, ("id", "instPath")),
136 ("firstboot", firstbootConfiguration, ("id", "instPath")),
137 ("instbootloader", writeBootloader, ("intf", "instPath", "id.fsset",
138 "id.bootloader", "id.langSupport",
139 "id.grpset")),
140 ("bootdisk", ("dir", "dispatch", "id.fsset")),
141 ("makebootdisk", makeBootdisk, ("intf", "dir", "id.floppyDevice",
142 "id.grpset", "instPath", "id.bootloader")),
143 #
144 # we dont use videocard and xcustom currently, they are still listed as
145 # steps but are not listed in the list of install steps in installclass.py
146 #
147 ("videocard", ("dispatch", "id.xsetup", "id.videocard", "intf")),
148 #
149 # this got moved up to just after mouse config, only runs if monitor probe
150 # failed. Needs to be here if we enable videocard and xcustom again.
151 # ("monitor", ("id.xsetup", "id.monitor", "intf")),
152 ("xcustom", ("id.xsetup", "id.monitor", "id.videocard",
153 "id.desktop", "id.grpset", "id.instClass", "instPath")),
154 ("writexconfig", writeXConfiguration, ("id", "instPath")),
155 ("writeksconfig", writeKSConfiguration, ("id", "instPath")),
156 ("setfilecon", setFileCons, ("instPath","id.partitions")),
157 ("copylogs", copyAnacondaLogs, ("instPath",)),
158 ("dopostaction", doPostAction, ("id", "instPath", "intf")),
159 ("methodcomplete", doMethodComplete, ("method",)),
160 ("complete", ()),
161 ]
162
163 class Dispatcher:
164
165 def gotoPrev(self):
166 self.dir = -1
167 self.moveStep()
168
169 def gotoNext(self):
170 self.dir = 1
171 self.moveStep()
172
173 def canGoBack(self):
174 # begin with the step before this one. If all steps are skipped,
175 # we can not go backwards from this screen
176 i = self.step - 1
177 while i >= self.firstStep:
178 if (not self.skipSteps.has_key(installSteps[i][0])
179 and (type(installSteps[i][1]) != FunctionType)):
180 return 1
181 i = i - 1
182 return 0
183
184 def setStepList(self, *steps):
185 # only remove non-permanently skipped steps from our skip list
186 for step, state in self.skipSteps.items():
187 if state == 1:
188 del self.skipSteps[step]
189
190 stepExists = {}
191 for step in installSteps:
192 name = step[0]
193 if not name in steps:
194 self.skipSteps[name] = 1
195
196 stepExists[name] = 1
197
198 for name in steps:
199 if not stepExists.has_key(name):
200 raise KeyError, ("step %s does not exist" % name)
201
202 def stepInSkipList(self, step):
203 return self.skipSteps.has_key(step)
204
205 def skipStep(self, stepToSkip, skip = 1, permanent = 0):
206 for step in installSteps:
207 name = step[0]
208 if name == stepToSkip:
209 if skip:
210 if permanent:
211 self.skipSteps[name] = 2
212 elif not self.skipSteps.has_key(name):
213 self.skipSteps[name] = 1
214 elif self.skipSteps.has_key(name):
215 # if marked as permanent then dont change
216 if self.skipSteps[name] != 2:
217 del self.skipSteps[name]
218 return
219
220 raise KeyError, ("unknown step %s" % stepToSkip)
221
222 def moveStep(self):
223 if self.step == None:
224 self.step = self.firstStep
225 else:
226 self.step = self.step + self.dir
227
228 if self.step >= len(installSteps):
229 return None
230
231 while ((self.step >= self.firstStep
232 and self.step < len(installSteps))
233 and (self.skipSteps.has_key(installSteps[self.step][0])
234 or (type(installSteps[self.step][1]) == FunctionType))):
235 info = installSteps[self.step]
236 if ((type(info[1]) == FunctionType)
237 and (not self.skipSteps.has_key(info[0]))):
238 log("moving (%d) to step %s" %(self.dir, info[0]))
239 (func, args) = info[1:]
240 rc = apply(func, self.bindArgs(args))
241 if rc == DISPATCH_BACK:
242 self.dir = -1
243 elif rc == DISPATCH_FORWARD:
244 self.dir = 1
245 # if anything else, leave self.dir alone
246
247 self.step = self.step + self.dir
248 if self.step == len(installSteps):
249 return None
250
251 if (self.step < 0):
252 # pick the first step not in the skip list
253 self.step = 0
254 while self.skipSteps.has_key(installSteps[self.step][0]):
255 self.step = self.step + 1
256 elif self.step >= len(installSteps):
257 self.step = len(installSteps) - 1
258 while self.skipSteps.has_key(installSteps[self.step][0]):
259 self.step = self.step - 1
260 log("moving (%d) to step %s" %(self.dir, installSteps[self.step][0]))
261
262 def bindArgs(self, args):
263 newArgs = ()
264 for arg in args:
265 obj = self
266 for item in string.split(arg, '.'):
267 if not obj.__dict__.has_key(item):
268 exec "obj = self.%s" %(arg,)
269 break
270 obj = obj.__dict__[item]
271 newArgs = newArgs + (obj,)
272
273 return newArgs
274
275 def currentStep(self):
276 if self.step == None:
277 self.gotoNext()
278 elif self.step >= len(installSteps):
279 return (None, None)
280
281 stepInfo = installSteps[self.step]
282 step = stepInfo[0]
283 args = self.bindArgs(stepInfo[1])
284
285 return (step, args)
286
287 def __init__(self, intf, id, method, instPath):
288 self.dir = DISPATCH_FORWARD
289 self.step = None
290 self.skipSteps = {}
291
292 self.id = id
293 self.flags = flags
294 self.intf = intf
295 self.method = method
296 self.dispatch = self
297 self.instPath = instPath
298 self.firstStep = 0

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed