/[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.2 - (hide annotations) (download) (as text)
Mon Mar 17 17:28:11 2008 UTC (16 years, 9 months ago) by slords
Branch: SME8
Changes since 1.1.2.1: +1 -0 lines
Content type: text/x-python
Updates

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

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