/[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.3 - (hide annotations) (download) (as text)
Tue Mar 18 20:57:24 2008 UTC (16 years, 9 months ago) by slords
Branch: SME8
Changes since 1.1.2.2: +15 -21 lines
Content type: text/x-python
Screens fixup

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.3 "language",
80     "keyboard",
81 slords 1.1.2.1 "findrootparts",
82 slords 1.1.2.3 "betanag",
83     "installtype",
84 slords 1.1.2.1 "partitionobjinit",
85     "autopartitionexecute",
86     "partition",
87 slords 1.1.2.3 "partitiondone",
88     "bootloadersetup",
89     "timezone",
90 slords 1.1.2.1 "reposetup",
91     "basepkgsel",
92 slords 1.1.2.3 "postselection",
93     "install",
94     "enablefilesystems",
95 slords 1.1.2.1 "migratefilesystems",
96     "setuptime",
97     "preinstallconfig",
98 slords 1.1.2.3 "installpackages",
99 slords 1.1.2.1 "postinstallconfig",
100 slords 1.1.2.3 "writeconfig",
101     "instbootloader",
102 slords 1.1.2.1 "dopostaction",
103 slords 1.1.2.3 "writeksconfig",
104 slords 1.1.2.1 "methodcomplete",
105     "copylogs",
106     "setfilecon",
107 slords 1.1.2.3 "complete"
108 slords 1.1.2.1 )
109    
110     # 'partition' can be used on the command line to force
111     # verification of partitions. useful in some cases...
112     if flags.cmdline.has_key("partition"):
113     dispatch.skipStep("partition", skip = 0)
114     else:
115     dispatch.skipStep("partition", skip = 1)
116    
117     def setDefaultPartitioning(self, partitions, clear = CLEARPART_TYPE_LINUX, doClear = 1):
118     uniqueID = 100
119     (swapMin, swapMax) = iutil.swapSuggestion()
120     diskset = partedUtils.DiskSet()
121     drives = diskset.driveList()
122     usedDrives = []
123    
124     spares = 0
125     useable = 0
126     for drive in drives:
127     if isys.mediaPresent(drive):
128     useable = useable + 1
129    
130     log.info("Useable is %d" % useable)
131     if useable >= 1:
132     if flags.cmdline.has_key("noraid"):
133     for drive in drives:
134     if isys.mediaPresent(drive):
135     filesystem = fileSystemTypeGet("ext3")
136     request = partRequests.PartitionSpec(filesystem, mountpoint="/boot", drive=[drive],
137     size=100, primary=1, format=1)
138     partitions.autoPartitionRequests.append(request)
139     usedDrives.append(drive);
140    
141     if flags.cmdline.has_key("nolvm"):
142     filesystem = fileSystemTypeGet("ext3")
143     request = partRequests.PartitionSpec(filesystem, mountpoint="/", drive=[drive],
144     size=1300, grow=1, primary=1, format=1)
145     partitions.autoPartitionRequests.append(request)
146    
147     filesystem = fileSystemTypeGet("swap")
148     request = partRequests.PartitionSpec(filesystem, drive=[drive], size=swapMin,
149     maxSizeMB=swapMax, grow=1, primary=1, format=1)
150     partitions.autoPartitionRequests.append(request)
151    
152     else:
153     filesystem = fileSystemTypeGet("physical volume (LVM)")
154     request = partRequests.PartitionSpec(filesystem, drive=[drive], size=swapMin+1500,
155     grow=1, primary=1, format=1)
156     request.uniqueID = 200
157     partitions.autoPartitionRequests.append(request)
158    
159     break
160    
161     else:
162     raid1 = []
163     raid2 = []
164     raid3 = []
165    
166     if useable >= 3 and not flags.cmdline.has_key("nospare"):
167     useable = useable - 1
168     spares = 1
169    
170     if flags.cmdline.has_key("raid1") and useable >= 1:
171     useable = 1
172     raidLevel = "RAID1"
173     else:
174     if useable >= 6:
175     useable = useable - 2
176     raidLevel = "RAID6"
177     elif useable >= 2:
178     useable = useable - 1
179     if useable >= 2:
180     raidLevel = "RAID5"
181     else:
182     raidLevel = "RAID1"
183     else:
184     raidLevel = "RAID1"
185    
186     for drive in drives:
187     if isys.mediaPresent(drive):
188     filesystem = fileSystemTypeGet("software RAID")
189     request = partRequests.PartitionSpec(filesystem, drive=[drive], size=100, primary=1, format=1)
190     request.uniqueID = uniqueID
191     raid1.append(uniqueID)
192     partitions.autoPartitionRequests.append(request)
193     usedDrives.append(drive);
194    
195     if flags.cmdline.has_key("nolvm"):
196     filesystem = fileSystemTypeGet("software RAID")
197     request = partRequests.PartitionSpec(filesystem, drive=[drive], size=swapMin/useable+10,
198     maxSizeMB=swapMax/useable, grow=1, primary=1, format=1)
199     request.uniqueID = uniqueID + 30
200     raid2.append(uniqueID + 30)
201     partitions.autoPartitionRequests.append(request)
202    
203     filesystem = fileSystemTypeGet("software RAID")
204     request = partRequests.PartitionSpec(filesystem, drive=[drive], size=1500/useable,
205     grow=1, primary=1, format=1)
206     request.uniqueID = uniqueID + 60
207     raid3.append(uniqueID + 60)
208     partitions.autoPartitionRequests.append(request)
209    
210     else:
211     filesystem = fileSystemTypeGet("software RAID")
212     if flags.cmdline.has_key("multipart"):
213     request = partRequests.PartitionSpec(filesystem, drive=[drive], size=(swapMin+3000)/useable,
214     grow=1, format=1)
215     else:
216     request = partRequests.PartitionSpec(filesystem, drive=[drive], size=(swapMin+1500)/useable,
217     grow=1, format=1)
218     request.uniqueID = uniqueID + 50
219     raid2.append(uniqueID + 50)
220     partitions.autoPartitionRequests.append(request)
221    
222     uniqueID = uniqueID + 1
223    
224     if flags.cmdline.has_key("raid1") and len(raid1)-spares >= 2:
225     break
226    
227     filesystem = fileSystemTypeGet("ext3")
228     request = partRequests.RaidRequestSpec(filesystem, mountpoint="/boot", raidminor=1,
229     raidmembers=raid1, raidlevel="RAID1", format=1, raidspares=spares)
230     partitions.autoPartitionRequests.append(request)
231    
232     if flags.cmdline.has_key("nolvm"):
233     filesystem = fileSystemTypeGet("swap")
234     request = partRequests.RaidRequestSpec(filesystem, raidmembers=raid2, raidminor=2,
235     raidlevel=raidLevel, format=1, raidspares=spares)
236     partitions.autoPartitionRequests.append(request)
237    
238     filesystem = fileSystemTypeGet("ext3")
239     request = partRequests.RaidRequestSpec(filesystem, mountpoint="/", raidmembers=raid3, raidminor=3,
240     raidlevel=raidLevel, format=1, raidspares=spares)
241     partitions.autoPartitionRequests.append(request)
242    
243     else:
244     filesystem = fileSystemTypeGet("physical volume (LVM)")
245     request = partRequests.RaidRequestSpec(filesystem, raidmembers=raid2, raidminor=2,
246     raidlevel=raidLevel, format=1, raidspares=spares)
247     request.uniqueID = 200
248     partitions.autoPartitionRequests.append(request)
249    
250     if not flags.cmdline.has_key("nolvm"):
251     request = partRequests.VolumeGroupRequestSpec(vgname="main", physvols=[200],
252     pesize=32768, format=1)
253     request.uniqueID = 201
254     partitions.autoPartitionRequests.append(request)
255    
256     if flags.cmdline.has_key("multipart"):
257     filesystem = fileSystemTypeGet("ext3")
258     request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/", size=2048,
259     maxSizeMB=4096, volgroup=201, lvname="root", grow=1, format=1)
260     partitions.autoPartitionRequests.append(request)
261    
262     filesystem = fileSystemTypeGet("ext3")
263     request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/var", size=1024,
264     maxSizeMB=4096, volgroup=201, lvname="var", grow=1, format=1)
265     partitions.autoPartitionRequests.append(request)
266    
267     filesystem = fileSystemTypeGet("ext3")
268     request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/home/e-smith/files", size=1024,
269     maxSizeMB=8192, volgroup=201, lvname="files", grow=1, format=1)
270     partitions.autoPartitionRequests.append(request)
271    
272     filesystem = fileSystemTypeGet("ext3")
273     request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/tmp", size=512,
274     maxSizeMB=4096, volgroup=201, lvname="tmp", grow=1, format=1)
275     partitions.autoPartitionRequests.append(request)
276    
277     filesystem = fileSystemTypeGet("swap")
278     request = partRequests.LogicalVolumeRequestSpec(filesystem, size=swapMin, maxSizeMB=swapMax,
279     volgroup=201, lvname="swap", grow=1, format=1)
280     partitions.autoPartitionRequests.append(request)
281     else:
282     filesystem = fileSystemTypeGet("ext3")
283     request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/", size=1300,
284     volgroup=201, lvname="root", grow=1, format=1)
285     partitions.autoPartitionRequests.append(request)
286    
287     filesystem = fileSystemTypeGet("swap")
288     request = partRequests.LogicalVolumeRequestSpec(filesystem, size=swapMin, maxSizeMB=swapMax,
289     volgroup=201, lvname="swap", grow=1, format=1)
290     partitions.autoPartitionRequests.append(request)
291    
292     partitions.autoClearPartType = clear
293     partitions.autoClearPartDrives = usedDrives
294     else:
295     BaseInstallClass.setDefaultPartitioning(self, partitions, clear, doClear)
296    
297     def setAsHeadless(self, dispatch, isHeadless = 0):
298     if isHeadless == 0:
299     pass
300     else:
301     dispatch.skipStep("handleX11pkgs", permanent = 1)
302     dispatch.skipStep("videocard", permanent = 1)
303     dispatch.skipStep("monitor", permanent = 1)
304     dispatch.skipStep("xcustom", permanent = 1)
305     dispatch.skipStep("writexconfig", permanent = 1)
306    
307     def postAction(self, anaconda, serial):
308     win = anaconda.intf.waitWindow(_("Post Install Script"),
309     _("The post installation script is running..."))
310    
311     script = ( "#!/bin/sh\nmkdir -p /var/lib/dhcp; /sbin/syslogd ; sleep 2; /sbin/e-smith/signal-event post-install\n" )
312     s = Script(script, interp="/bin/sh", inChroot=1)
313     log.info("%s", s)
314     s.run(anaconda.rootPath, serial)
315     win.pop()
316    
317     def setInstallData(self, anaconda):
318     BaseInstallClass.setInstallData(self, anaconda)
319     self.setDefaultPartitioning(anaconda.id.partitions, CLEARPART_TYPE_ALL)
320     self.setSELinux(anaconda.id, SELINUX_DISABLED)
321    
322     def setGroupSelection(self, anaconda):
323     BaseInstallClass.__init__(self, anaconda.backend)
324     anaconda.backend.selectGroup("Base")
325     anaconda.backend.selectGroup("Core")
326     anaconda.backend.selectGroup("Extras")
327     anaconda.backend.selectGroup("SME Server")
328    
329     def __init__(self, expert):
330     BaseInstallClass.__init__(self, expert)
331     self.repopaths = { "base": "%s" %(productPath,) }
332     self.forceTextMode = 1

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