/[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.9 - (hide annotations) (download) (as text)
Fri Jun 5 20:24:07 2009 UTC (15 years, 6 months ago) by slords
Branch: SME8
Changes since 1.1.2.8: +17 -10 lines
Content type: text/x-python
Minor fixes

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

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