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

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

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


Revision 1.9 - (hide annotations) (download) (as text)
Sat Jun 11 23:00:46 2011 UTC (13 years, 4 months ago) by slords
Branch: MAIN
Changes since 1.8: +11 -7 lines
Content type: text/x-python
Make ext4 configurable

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

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