/[smeserver]/cdrom.image/updates/installclasses/smeinstallclass.py
ViewVC logotype

Annotation of /cdrom.image/updates/installclasses/smeinstallclass.py

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


Revision 1.1.2.4 - (hide annotations) (download) (as text)
Fri Aug 29 13:56:56 2008 UTC (16 years, 3 months ago) by slords
Branch: SME8
Changes since 1.1.2.3: +16 -15 lines
Content type: text/x-python
retab and add confirminstall

1 slords 1.1.2.1 from installclass import BaseInstallClass
2     from rhpl.translate import N_, _
3     from constants import *
4     import os
5     import iutil
6     from fsset import *
7     from flags import flags
8    
9     from autopart import getAutopartitionBoot, autoCreatePartitionRequests, autoCreateLVMPartitionRequests
10    
11     import logging
12     log = logging.getLogger("anaconda")
13    
14     import string
15     import partRequests
16     import partedUtils
17    
18     class Script:
19     def __repr__(self):
20     str = ("(s: '%s' i: %s c: %d)") % \
21     (self.script, self.interp, self.inChroot)
22     return string.replace(str, "\n", "|")
23    
24     def __init__(self, script, interp, inChroot, logfile = None):
25     self.script = script
26     self.interp = interp
27     self.inChroot = inChroot
28     self.logfile = logfile
29    
30     def run(self, chroot, serial):
31     import tempfile
32     import os.path
33    
34     if self.inChroot:
35     scriptRoot = chroot
36     else:
37     scriptRoot = "/"
38    
39     (fd, path) = tempfile.mkstemp("", "sme-script-", scriptRoot + "/tmp")
40    
41     os.write(fd, self.script)
42     os.close(fd)
43     os.chmod(path, 0700)
44    
45     if self.logfile is not None:
46     messages = self.logfile
47     elif serial:
48     messages = "%s.log" % path
49     else:
50     messages = "/dev/tty3"
51    
52     rc = iutil.execWithRedirect(self.interp, ["/tmp/%s" % os.path.basename(path)],
53     stdin = messages, stdout = messages, stderr = messages,
54     root = scriptRoot)
55    
56     if rc != 0:
57     log.error("WARNING - Error code %s encountered running a sme script", rc)
58    
59     os.unlink(path)
60     if serial or self.logfile is not None:
61     os.chmod("%s" % messages, 0600)
62    
63     class InstallClass(BaseInstallClass):
64     id = "smeserver"
65     name = N_("New _SME Server Install")
66     pixmap = "smeserver.png"
67     description = N_("This option performs a new install of "
68     "SME Server. All attached hard drives "
69     "will be repartitioned and formated.")
70     sortPriority = 1
71    
72     parentClass = ( _("Install SME Server"), "smeserver.png" )
73    
74     def requiredDisplayMode(self):
75     return 't'
76    
77     def setSteps(self, dispatch):
78     dispatch.setStepList(
79 slords 1.1.2.4 "language",
80     "keyboard",
81 slords 1.1.2.1 "findrootparts",
82 slords 1.1.2.4 "betanag",
83     "installtype",
84 slords 1.1.2.1 "partitionobjinit",
85     "autopartitionexecute",
86     "partition",
87 slords 1.1.2.4 "partitiondone",
88     "bootloadersetup",
89     "timezone",
90 slords 1.1.2.1 "reposetup",
91     "basepkgsel",
92 slords 1.1.2.4 "postselection",
93     "confirminstall",
94     "install",
95     "enablefilesystems",
96 slords 1.1.2.1 "migratefilesystems",
97     "setuptime",
98     "preinstallconfig",
99 slords 1.1.2.4 "installpackages",
100 slords 1.1.2.1 "postinstallconfig",
101 slords 1.1.2.4 "writeconfig",
102     "instbootloader",
103 slords 1.1.2.1 "dopostaction",
104 slords 1.1.2.4 "writeksconfig",
105 slords 1.1.2.1 "methodcomplete",
106     "copylogs",
107     "setfilecon",
108 slords 1.1.2.4 "complete"
109 slords 1.1.2.1 )
110    
111     # 'partition' can be used on the command line to force
112     # verification of partitions. useful in some cases...
113     if flags.cmdline.has_key("partition"):
114     dispatch.skipStep("partition", skip = 0)
115     else:
116     dispatch.skipStep("partition", skip = 1)
117    
118     def setDefaultPartitioning(self, partitions, clear = CLEARPART_TYPE_LINUX, doClear = 1):
119     uniqueID = 100
120     (swapMin, swapMax) = iutil.swapSuggestion()
121     diskset = partedUtils.DiskSet()
122     drives = diskset.driveList()
123     usedDrives = []
124    
125     spares = 0
126     useable = 0
127     for drive in drives:
128     if isys.mediaPresent(drive):
129     useable = useable + 1
130    
131     log.info("Useable is %d" % useable)
132     if useable >= 1:
133     if flags.cmdline.has_key("noraid"):
134     for drive in drives:
135     if isys.mediaPresent(drive):
136     filesystem = fileSystemTypeGet("ext3")
137     request = partRequests.PartitionSpec(filesystem, mountpoint="/boot", drive=[drive],
138     size=100, primary=1, format=1)
139     partitions.autoPartitionRequests.append(request)
140     usedDrives.append(drive);
141    
142     if flags.cmdline.has_key("nolvm"):
143     filesystem = fileSystemTypeGet("ext3")
144     request = partRequests.PartitionSpec(filesystem, mountpoint="/", drive=[drive],
145     size=1300, grow=1, primary=1, format=1)
146     partitions.autoPartitionRequests.append(request)
147    
148     filesystem = fileSystemTypeGet("swap")
149     request = partRequests.PartitionSpec(filesystem, drive=[drive], size=swapMin,
150     maxSizeMB=swapMax, grow=1, primary=1, format=1)
151     partitions.autoPartitionRequests.append(request)
152    
153     else:
154     filesystem = fileSystemTypeGet("physical volume (LVM)")
155     request = partRequests.PartitionSpec(filesystem, drive=[drive], size=swapMin+1500,
156     grow=1, primary=1, format=1)
157     request.uniqueID = 200
158     partitions.autoPartitionRequests.append(request)
159    
160     break
161    
162     else:
163     raid1 = []
164     raid2 = []
165     raid3 = []
166    
167     if useable >= 3 and not flags.cmdline.has_key("nospare"):
168     useable = useable - 1
169     spares = 1
170    
171     if flags.cmdline.has_key("raid1") and useable >= 1:
172     useable = 1
173     raidLevel = "RAID1"
174     else:
175     if useable >= 6:
176     useable = useable - 2
177     raidLevel = "RAID6"
178     elif useable >= 2:
179     useable = useable - 1
180     if useable >= 2:
181     raidLevel = "RAID5"
182     else:
183     raidLevel = "RAID1"
184     else:
185     raidLevel = "RAID1"
186    
187     for drive in drives:
188     if isys.mediaPresent(drive):
189     filesystem = fileSystemTypeGet("software RAID")
190     request = partRequests.PartitionSpec(filesystem, drive=[drive], size=100, primary=1, format=1)
191     request.uniqueID = uniqueID
192     raid1.append(uniqueID)
193     partitions.autoPartitionRequests.append(request)
194     usedDrives.append(drive);
195    
196     if flags.cmdline.has_key("nolvm"):
197     filesystem = fileSystemTypeGet("software RAID")
198     request = partRequests.PartitionSpec(filesystem, drive=[drive], size=swapMin/useable+10,
199     maxSizeMB=swapMax/useable, grow=1, primary=1, format=1)
200     request.uniqueID = uniqueID + 30
201     raid2.append(uniqueID + 30)
202     partitions.autoPartitionRequests.append(request)
203    
204     filesystem = fileSystemTypeGet("software RAID")
205     request = partRequests.PartitionSpec(filesystem, drive=[drive], size=1500/useable,
206     grow=1, primary=1, format=1)
207     request.uniqueID = uniqueID + 60
208     raid3.append(uniqueID + 60)
209     partitions.autoPartitionRequests.append(request)
210    
211     else:
212     filesystem = fileSystemTypeGet("software RAID")
213     if flags.cmdline.has_key("multipart"):
214     request = partRequests.PartitionSpec(filesystem, drive=[drive], size=(swapMin+3000)/useable,
215     grow=1, format=1)
216     else:
217     request = partRequests.PartitionSpec(filesystem, drive=[drive], size=(swapMin+1500)/useable,
218     grow=1, format=1)
219     request.uniqueID = uniqueID + 50
220     raid2.append(uniqueID + 50)
221     partitions.autoPartitionRequests.append(request)
222    
223     uniqueID = uniqueID + 1
224    
225     if flags.cmdline.has_key("raid1") and len(raid1)-spares >= 2:
226     break
227    
228     filesystem = fileSystemTypeGet("ext3")
229     request = partRequests.RaidRequestSpec(filesystem, mountpoint="/boot", raidminor=1,
230     raidmembers=raid1, raidlevel="RAID1", format=1, raidspares=spares)
231     partitions.autoPartitionRequests.append(request)
232    
233     if flags.cmdline.has_key("nolvm"):
234     filesystem = fileSystemTypeGet("swap")
235     request = partRequests.RaidRequestSpec(filesystem, raidmembers=raid2, raidminor=2,
236     raidlevel=raidLevel, format=1, raidspares=spares)
237     partitions.autoPartitionRequests.append(request)
238    
239     filesystem = fileSystemTypeGet("ext3")
240     request = partRequests.RaidRequestSpec(filesystem, mountpoint="/", raidmembers=raid3, raidminor=3,
241     raidlevel=raidLevel, format=1, raidspares=spares)
242     partitions.autoPartitionRequests.append(request)
243    
244     else:
245     filesystem = fileSystemTypeGet("physical volume (LVM)")
246     request = partRequests.RaidRequestSpec(filesystem, raidmembers=raid2, raidminor=2,
247     raidlevel=raidLevel, format=1, raidspares=spares)
248     request.uniqueID = 200
249     partitions.autoPartitionRequests.append(request)
250    
251     if not flags.cmdline.has_key("nolvm"):
252     request = partRequests.VolumeGroupRequestSpec(vgname="main", physvols=[200],
253     pesize=32768, format=1)
254     request.uniqueID = 201
255     partitions.autoPartitionRequests.append(request)
256    
257     if flags.cmdline.has_key("multipart"):
258     filesystem = fileSystemTypeGet("ext3")
259     request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/", size=2048,
260     maxSizeMB=4096, volgroup=201, lvname="root", grow=1, format=1)
261     partitions.autoPartitionRequests.append(request)
262    
263     filesystem = fileSystemTypeGet("ext3")
264     request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/var", size=1024,
265     maxSizeMB=4096, volgroup=201, lvname="var", grow=1, format=1)
266     partitions.autoPartitionRequests.append(request)
267    
268     filesystem = fileSystemTypeGet("ext3")
269     request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/home/e-smith/files", size=1024,
270     maxSizeMB=8192, volgroup=201, lvname="files", grow=1, format=1)
271     partitions.autoPartitionRequests.append(request)
272    
273     filesystem = fileSystemTypeGet("ext3")
274     request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/tmp", size=512,
275     maxSizeMB=4096, volgroup=201, lvname="tmp", grow=1, format=1)
276     partitions.autoPartitionRequests.append(request)
277    
278     filesystem = fileSystemTypeGet("swap")
279     request = partRequests.LogicalVolumeRequestSpec(filesystem, size=swapMin, maxSizeMB=swapMax,
280     volgroup=201, lvname="swap", grow=1, format=1)
281     partitions.autoPartitionRequests.append(request)
282     else:
283     filesystem = fileSystemTypeGet("ext3")
284     request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/", size=1300,
285     volgroup=201, lvname="root", grow=1, format=1)
286     partitions.autoPartitionRequests.append(request)
287    
288     filesystem = fileSystemTypeGet("swap")
289     request = partRequests.LogicalVolumeRequestSpec(filesystem, size=swapMin, maxSizeMB=swapMax,
290     volgroup=201, lvname="swap", grow=1, format=1)
291     partitions.autoPartitionRequests.append(request)
292    
293     partitions.autoClearPartType = clear
294     partitions.autoClearPartDrives = usedDrives
295     else:
296     BaseInstallClass.setDefaultPartitioning(self, partitions, clear, doClear)
297    
298     def setAsHeadless(self, dispatch, isHeadless = 0):
299     if isHeadless == 0:
300     pass
301     else:
302     dispatch.skipStep("handleX11pkgs", permanent = 1)
303     dispatch.skipStep("videocard", permanent = 1)
304     dispatch.skipStep("monitor", permanent = 1)
305     dispatch.skipStep("xcustom", permanent = 1)
306     dispatch.skipStep("writexconfig", permanent = 1)
307    
308     def postAction(self, anaconda, serial):
309     win = anaconda.intf.waitWindow(_("Post Install Script"),
310     _("The post installation script is running..."))
311    
312     script = ( "#!/bin/sh\nmkdir -p /var/lib/dhcp; /sbin/syslogd ; sleep 2; /sbin/e-smith/signal-event post-install\n" )
313     s = Script(script, interp="/bin/sh", inChroot=1)
314     log.info("%s", s)
315     s.run(anaconda.rootPath, serial)
316     win.pop()
317    
318     def setInstallData(self, anaconda):
319     BaseInstallClass.setInstallData(self, anaconda)
320     self.setDefaultPartitioning(anaconda.id.partitions, CLEARPART_TYPE_ALL)
321     self.setSELinux(anaconda.id, SELINUX_DISABLED)
322    
323     def setGroupSelection(self, anaconda):
324     BaseInstallClass.__init__(self, anaconda.backend)
325     anaconda.backend.selectGroup("Base")
326     anaconda.backend.selectGroup("Core")
327     anaconda.backend.selectGroup("Extras")
328     anaconda.backend.selectGroup("SME Server")
329    
330     def __init__(self, expert):
331     BaseInstallClass.__init__(self, expert)
332     self.repopaths = { "base": "%s" %(productPath,) }
333     self.forceTextMode = 1

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