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

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

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


Revision 1.16 - (hide annotations) (download) (as text)
Fri Nov 10 05:40:24 2006 UTC (17 years, 11 months ago) by slords
Branch: MAIN
Changes since 1.15: +126 -62 lines
Content type: text/x-python
Enhance raid/lvm install options

1 slords 1.1 from installclass import BaseInstallClass
2 slords 1.13 from rhpl.translate import N_, _
3 slords 1.12 from constants import *
4     import os
5     import iutil
6 slords 1.13 from fsset import *
7 slords 1.12
8 slords 1.1 from autopart import getAutopartitionBoot, autoCreatePartitionRequests, autoCreateLVMPartitionRequests
9     from rhpl.log import log
10 slords 1.2 import string
11 slords 1.1 import partRequests
12     import partedUtils
13    
14 slords 1.2 class Script:
15     def __repr__(self):
16     str = ("(s: '%s' i: %s c: %d)") % \
17     (self.script, self.interp, self.inChroot)
18     return string.replace(str, "\n", "|")
19    
20     def __init__(self, script, interp, inChroot, logfile = None):
21     self.script = script
22     self.interp = interp
23     self.inChroot = inChroot
24     self.logfile = logfile
25    
26     def run(self, chroot, serial):
27     scriptRoot = "/"
28     if self.inChroot:
29     scriptRoot = chroot
30    
31     path = scriptRoot + "/tmp/sme-script"
32    
33     f = open(path, "w")
34     f.write(self.script)
35     f.close()
36     os.chmod(path, 0700)
37    
38     if self.logfile is not None:
39     messages = self.logfile
40     elif serial:
41     messages = "/tmp/sme-script.log"
42     else:
43     messages = "/dev/tty3"
44    
45     rc = iutil.execWithRedirect(self.interp,
46     [self.interp,"/tmp/sme-script"],
47     stdout = messages, stderr = messages,
48     root = scriptRoot)
49    
50     if rc != 0:
51     log("WARNING - Error code %s encountered running a sme script", rc)
52    
53     os.unlink(path)
54    
55 slords 1.1 class InstallClass(BaseInstallClass):
56 slords 1.2 id = "smeserver"
57     name = N_("New _SME Server Install")
58     pixmap = "smeserver.png"
59 slords 1.3 description = N_("This option performs a new install of "
60     "SME Server. All attached hard drives "
61     "will be repartitioned and formated.")
62 slords 1.1 sortPriority = 1
63    
64 slords 1.2 parentClass = ( _("Install SME Server"), "smeserver.png" )
65 slords 1.1
66     def requiredDisplayMode(self):
67     return 't'
68    
69     def setSteps(self, dispatch):
70     dispatch.setStepList(
71     "language",
72     "keyboard",
73     "findrootparts",
74 slords 1.4 "findinstall",
75     "installtype",
76 slords 1.1 "partitionobjinit",
77     "autopartitionexecute",
78 slords 1.2 "partition",
79 slords 1.1 "partitiondone",
80     "bootloadersetup",
81 slords 1.7 "languagesupport",
82 slords 1.1 "timezone",
83     "readcomps",
84     "selectlangpackages",
85     "checkdeps",
86     "dependencies",
87     "install",
88     "enablefilesystems",
89     "migratefilesystems",
90     "setuptime",
91     "preinstallconfig",
92     "installpackages",
93     "postinstallconfig",
94     "writeconfig",
95     "instbootloader",
96     "dopostaction",
97     "methodcomplete",
98     "copylogs",
99 slords 1.11 "writeksconfig",
100 slords 1.1 "setfilecon",
101     "complete"
102     )
103    
104 slords 1.2 # 'partition' can be used on the command line to force
105     # verification of partitions. useful in some cases...
106     cmdline = open("/proc/cmdline", "r").read()
107     cmdline = cmdline.split()
108     if "partition" in cmdline:
109     dispatch.skipStep("partition", skip = 0)
110     else:
111     dispatch.skipStep("partition", skip = 1)
112    
113 slords 1.1 def setDefaultPartitioning(self, partitions, clear = CLEARPART_TYPE_LINUX, doClear = 1):
114 slords 1.15 uniqueID = 100
115 slords 1.16 (swapMin, swapMax) = iutil.swapSuggestion()
116     diskset = partedUtils.DiskSet()
117     drives = diskset.driveList()
118     count = 0
119    
120     if "noraid" in cmdline:
121     for drive in drives:
122     if not isys.driveIsRemovable(drive):
123     filesystem = fileSystemTypeGet("ext3")
124     request = partRequests.PartitionSpec(filesystem, mountpoint="/boot", drive=[drive],
125     size=100, primary=1, format=1)
126     partitions.autoPartitionRequests.append(request)
127    
128     if "nolvm" in cmdline:
129     filesystem = fileSystemTypeGet("ext3")
130     request = partRequests.PartitionSpec(filesystem, mountpoint="/", drive=[drive],
131     size=1300, grow=1, primary=1, format=1)
132     partitions.autoPartitionRequests.append(request)
133    
134     filesystem = fileSystemTypeGet("swap")
135     request = partRequests.PartitionSpec(filesystem, drive=[drive], size=swapMin,
136     maxSizeMB=swapMax, grow=1, primary=1, format=1)
137     partitions.autoPartitionRequests.append(request)
138    
139     else:
140     filesystem = fileSystemTypeGet("physical volume (LVM)")
141     request = partRequests.PartitionSpec(filesystem, drive=[drive], size=swapMin+1500,
142     grow=1, primary=1, format=1)
143     request.uniqueID = 200
144     partitions.autoPartitionRequests.append(request)
145    
146     count = count + 1
147     break
148    
149     else:
150     raid1 = []
151     raid2 = []
152     raid3 = []
153    
154     for drive in drives:
155     if not isys.driveIsRemovable(drive):
156     filesystem = fileSystemTypeGet("software RAID")
157     request = partRequests.PartitionSpec(filesystem, drive=[drive], size=100, primary=1, format=1)
158     request.uniqueID = uniqueID
159     raid1.append(uniqueID)
160     partitions.autoPartitionRequests.append(request)
161    
162     if "nolvm" in cmdline:
163     filesystem = fileSystemTypeGet("software RAID")
164     request = partRequests.PartitionSpec(filesystem, drive=[drive], size=1500,
165     grow=1, primary=1, format=1)
166     request.uniqueID = uniqueID + 50
167     raid2.append(uniqueID + 50)
168     partitions.autoPartitionRequests.append(request)
169    
170     filesystem = fileSystemTypeGet("software RAID")
171     request = partRequests.PartitionSpec(filesystem, drive=[drive], size=swapMin,
172     maxSizeMB=swapMax, grow=1, primary=1, format=1)
173     request.uniqueID = uniqueID + 51
174     raid3.append(uniqueID + 51)
175     partitions.autoPartitionRequests.append(request)
176    
177     else:
178     filesystem = fileSystemTypeGet("software RAID")
179     request = partRequests.PartitionSpec(filesystem, drive=[drive], size=swapMin+1500,
180     grow=1, format=1)
181     request.uniqueID = uniqueID + 50
182     raid2.append(uniqueID + 50)
183     partitions.autoPartitionRequests.append(request)
184    
185     uniqueID = uniqueID + 1
186    
187     count = count + 1
188     if "raid1" in cmdline and len(raid2) > 1:
189     break
190    
191     filesystem = fileSystemTypeGet("ext3")
192     request = partRequests.RaidRequestSpec(filesystem, mountpoint="/boot", raidminor=1,
193     raidmembers=raid1, raidlevel="RAID1", format=1, raidspares=0)
194     partitions.autoPartitionRequests.append(request)
195    
196     if len(raid2) > 5:
197     raidLevel = "RAID6"
198     elif len(raid2) > 2:
199     raidLevel = "RAID5"
200     else:
201     raidLevel = "RAID1"
202    
203     if "nolvm" in cmdline:
204     filesystem = fileSystemTypeGet("ext3")
205     request = partRequests.RaidRequestSpec(filesystem, mountpoint="/", raidmembers=raid2, raidminor=2,
206     raidlevel=raidLevel, format=1, raidspares=0)
207     partitions.autoPartitionRequests.append(request)
208    
209     filesystem = fileSystemTypeGet("swap")
210     request = partRequests.RaidRequestSpec(filesystem, raidmembers=raid3, raidminor=3,
211     raidlevel=raidLevel, format=1, raidspares=0)
212     partitions.autoPartitionRequests.append(request)
213    
214     else:
215     filesystem = fileSystemTypeGet("physical volume (LVM)")
216     request = partRequests.RaidRequestSpec(filesystem, raidmembers=raid2, raidminor=2,
217     raidlevel=raidLevel, format=1, raidspares=0)
218     request.uniqueID = 200
219     partitions.autoPartitionRequests.append(request)
220    
221     if count > 0:
222     if not "nolvm" in cmdline:
223     request = partRequests.VolumeGroupRequestSpec(vgname="main", physvols=[200],
224     pesize=32768, format=1)
225     request.uniqueID = 201
226     partitions.autoPartitionRequests.append(request)
227    
228     filesystem = fileSystemTypeGet("ext3")
229     request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/", size=1300,
230     volgroup=201, lvname="root", grow=1, format=1)
231     partitions.autoPartitionRequests.append(request)
232    
233     filesystem = fileSystemTypeGet("swap")
234     request = partRequests.LogicalVolumeRequestSpec(filesystem, size=swapMin, maxSizeMB=swapMax,
235     volgroup=201, lvname="swap", grow=1, format=1)
236     partitions.autoPartitionRequests.append(request)
237     else:
238     dispatch.skipStep("partition", skip = 0)
239     BaseInstallClass.setDefaultPartitioning(self, partitions, clear, doClear)
240    
241 slords 1.14 def setAsHeadless(self, dispatch, isHeadless = 0):
242     if isHeadless == 0:
243     pass
244     else:
245     # dispatch.skipStep("keyboard", permanent = 1)
246     # dispatch.skipStep("mouse", permanent = 1)
247     dispatch.skipStep("handleX11pkgs", permanent = 1)
248     dispatch.skipStep("videocard", permanent = 1)
249     dispatch.skipStep("monitor", permanent = 1)
250     dispatch.skipStep("xcustom", permanent = 1)
251     dispatch.skipStep("writexconfig", permanent = 1)
252    
253 slords 1.1 def setGroupSelection(self, grpset, intf):
254     grpset.unselectAll()
255     grpset.selectGroup("Base")
256    
257 gordonr 1.10 def postAction(self, rootPath, serial, intf):
258     win = intf.waitWindow(_("Post Install Script"),
259     _("The post installation script is running..."))
260    
261 slords 1.3 script = ( "/sbin/syslogd &\n"
262     "sleep 2\n"
263     "/sbin/e-smith/signal-event post-install\n" )
264 slords 1.2 s = Script(script, interp="/bin/sh", inChroot=1)
265     log("%s", s)
266     s.run(rootPath, serial)
267 gordonr 1.10 win.pop()
268 slords 1.1
269     def setInstallData(self, id, intf = None):
270     BaseInstallClass.setInstallData(self, id)
271     self.setAuthentication(id, useShadow=1, useMd5=1)
272     self.setRootPassword(id, pw="ThisIsGoingToBeDisabledAnyway", isCrypted=0)
273     self.setZeroMbr(id, zeroMbr=1)
274     self.setClearParts(id, clear=CLEARPART_TYPE_ALL, initAll=1)
275     self.setDefaultPartitioning(id.partitions, doClear=0)
276     self.setBootloader(id, useLilo=0, location="mbr", linear=1)
277    
278     def __init__(self, expert):
279 slords 1.12 BaseInstallClass.__init__(self, expert)

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