59 |
description = N_("This option performs a new install of " |
description = N_("This option performs a new install of " |
60 |
"SME Server. All attached hard drives " |
"SME Server. All attached hard drives " |
61 |
"will be repartitioned and formated.") |
"will be repartitioned and formated.") |
62 |
|
|
63 |
sortPriority = 1 |
sortPriority = 1 |
64 |
useabledrives = 0 |
|
65 |
|
cmdline = {} |
66 |
|
doPartition = False |
67 |
|
|
68 |
parentClass = ( _("Install SME Server"), "smeserver.png" ) |
parentClass = ( _("Install SME Server"), "smeserver.png" ) |
69 |
|
|
70 |
def requiredDisplayMode(self): |
def requiredDisplayMode(self): |
71 |
return 't' |
return 't' |
72 |
|
|
73 |
|
def createCmdlineDict(self): |
74 |
|
cmdlineDict = {} |
75 |
|
cmdline = open("/proc/cmdline", "r").read().strip() |
76 |
|
|
77 |
|
for i in cmdline.split(): |
78 |
|
try: |
79 |
|
(key, val) = i.split("=", 1) |
80 |
|
except: |
81 |
|
key = i |
82 |
|
val = True |
83 |
|
|
84 |
|
cmdlineDict[key] = val |
85 |
|
|
86 |
|
return cmdlineDict |
87 |
|
|
88 |
|
def mediaPresent(self, device): |
89 |
|
try: |
90 |
|
fd = os.open("/dev/%s" % device, os.O_RDONLY) |
91 |
|
except OSError, (errno, strerror): |
92 |
|
# error 123 = No medium found |
93 |
|
if errno == 123: |
94 |
|
return False |
95 |
|
else: |
96 |
|
return True |
97 |
|
else: |
98 |
|
os.close(fd) |
99 |
|
return True |
100 |
|
|
101 |
def setSteps(self, dispatch): |
def setSteps(self, dispatch): |
102 |
dispatch.setStepList( |
dispatch.setStepList( |
103 |
"language", |
"language", |
107 |
"installtype", |
"installtype", |
108 |
"partitionobjinit", |
"partitionobjinit", |
109 |
"autopartitionexecute", |
"autopartitionexecute", |
|
"parttype", |
|
110 |
"partition", |
"partition", |
111 |
"partitiondone", |
"partitiondone", |
112 |
"bootloadersetup", |
"bootloadersetup", |
113 |
"languagesupport", |
"languagesupport", |
114 |
"timezone", |
"timezone", |
115 |
"readcomps", |
"readcomps", |
133 |
"complete" |
"complete" |
134 |
) |
) |
135 |
|
|
136 |
# 'partition' can be used on the command line to force |
|
137 |
|
# 'partition' can be used on the command line to force |
138 |
# verification of partitions. useful in some cases... |
# verification of partitions. useful in some cases... |
139 |
cmdline = open("/proc/cmdline", "r").read() |
if self.doPartition or self.cmdline.has_key("partition"): |
|
cmdline = cmdline.split() |
|
|
if self.useabledrives == 0 or "partition" in cmdline: |
|
|
dispatch.skipStep("parttype", skip = 0) |
|
140 |
dispatch.skipStep("partition", skip = 0) |
dispatch.skipStep("partition", skip = 0) |
141 |
else: |
else: |
|
dispatch.skipStep("parttype", skip = 1) |
|
142 |
dispatch.skipStep("partition", skip = 1) |
dispatch.skipStep("partition", skip = 1) |
143 |
|
|
144 |
def setDefaultPartitioning(self, partitions, clear = CLEARPART_TYPE_LINUX, doClear = 1): |
def setDefaultPartitioning(self, partitions, clear = CLEARPART_TYPE_LINUX, doClear = 1): |
145 |
uniqueID = 100 |
self.cmdline = self.createCmdlineDict() |
|
(swapMin, swapMax) = iutil.swapSuggestion() |
|
146 |
diskset = partedUtils.DiskSet() |
diskset = partedUtils.DiskSet() |
|
drives = diskset.driveList() |
|
|
usedDrives = [] |
|
147 |
|
|
148 |
spares = 0 |
alldrives = diskset.driveList() |
149 |
self.useabledrives = 0 |
if self.cmdline.has_key("drives"): |
150 |
for drive in drives: |
drives = filter(lambda x:self.mediaPresent(x) and |
151 |
if not isys.driveIsRemovable(drive): |
x in self.cmdline["drives"].split(","), alldrives) |
152 |
self.useabledrives = self.useabledrives + 1 |
else: |
153 |
|
drives = filter(lambda x:not isys.driveIsRemovable(x) and |
154 |
log.info("Found %d useable drives" % self.useabledrives) |
self.mediaPresent(x) and |
155 |
if self.useabledrives >= 1: |
not isys.driveUsesModule(x, ["usb-storage", "ub", "sbp2"]), alldrives) |
|
if "noraid" in cmdline: |
|
|
for drive in drives: |
|
|
if not isys.driveIsRemovable(drive): |
|
|
filesystem = fileSystemTypeGet("ext3") |
|
|
request = partRequests.PartitionSpec(filesystem, mountpoint="/boot", drive=[drive], |
|
|
size=100, primary=1, format=1) |
|
|
partitions.autoPartitionRequests.append(request) |
|
|
usedDrives.append(drive); |
|
156 |
|
|
157 |
if "nolvm" in cmdline: |
if self.cmdline.has_key("spares"): |
158 |
filesystem = fileSystemTypeGet("ext3") |
spares = max(0,min(int(self.cmdline["spares"]),len(drives)-2)) |
159 |
request = partRequests.PartitionSpec(filesystem, mountpoint="/", drive=[drive], |
else: |
160 |
size=1300, grow=1, primary=1, format=1) |
spares = (len(drives)+4)/7 |
|
partitions.autoPartitionRequests.append(request) |
|
|
|
|
|
filesystem = fileSystemTypeGet("swap") |
|
|
request = partRequests.PartitionSpec(filesystem, drive=[drive], size=swapMin, |
|
|
maxSizeMB=swapMax, grow=1, primary=1, format=1) |
|
|
partitions.autoPartitionRequests.append(request) |
|
|
|
|
|
else: |
|
|
filesystem = fileSystemTypeGet("physical volume (LVM)") |
|
|
request = partRequests.PartitionSpec(filesystem, drive=[drive], size=swapMin+1500, |
|
|
grow=1, primary=1, format=1) |
|
|
request.uniqueID = 200 |
|
|
partitions.autoPartitionRequests.append(request) |
|
161 |
|
|
162 |
break |
if self.cmdline.has_key("raid") and self.cmdline["raid"] in ["none","0","1","5","6"]: |
163 |
|
if self.cmdline["raid"] == "none": |
164 |
|
level = 0 |
165 |
|
else: |
166 |
|
level = int(self.cmdline["raid"]) |
167 |
|
if level == 0: |
168 |
|
del drives[1:] |
169 |
|
spares = 0 |
170 |
|
if level == 6 and len(drives)-spares < 4: |
171 |
|
level = 5 |
172 |
|
if level == 5 and len(drives)-spares < 3: |
173 |
|
level = 1 |
174 |
|
if level == 1: |
175 |
|
if spares > 1 and not self.cmdline.has_key("spares"): |
176 |
|
spares = 1 |
177 |
|
del drives[2+spares:] |
178 |
|
else: |
179 |
|
if len(drives) - spares >= 6: |
180 |
|
level = 6 |
181 |
|
elif len(drives) - spares >= 3: |
182 |
|
level = 5 |
183 |
|
else: |
184 |
|
level = 1 |
185 |
|
|
186 |
|
if len(drives) >= 1: |
187 |
|
log("Using the following drives: %s" % drives) |
188 |
|
if level >= 1: |
189 |
|
log("Installing using RAID%s" % level) |
190 |
|
log("Using %s spare drives" % spares) |
191 |
else: |
else: |
192 |
|
log("Installing without using RAID") |
193 |
|
|
194 |
|
(swapMin, swapMax) = iutil.swapSuggestion() |
195 |
|
if level >= 1: |
196 |
raid1 = [] |
raid1 = [] |
197 |
raid2 = [] |
raid2 = [] |
198 |
raid3 = [] |
raid3 = [] |
199 |
|
uniqueID = 100 |
200 |
|
|
201 |
if self.useabledrives >= 3 and "nospare" not in cmdline: |
for drive in drives: |
202 |
self.useabledrives = self.useabledrives - 1 |
request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"), |
203 |
spares = 1 |
drive=[drive], size=100, primary=1, format=1) |
204 |
|
request.uniqueID = uniqueID |
205 |
|
raid1.append(uniqueID) |
206 |
|
partitions.autoPartitionRequests.append(request) |
207 |
|
|
208 |
if "raid1" in cmdline and self.useabledrives >= 1: |
if not self.cmdline.has_key("nolvm"): |
209 |
self.useabledrives = 1 |
request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"), |
210 |
raidLevel = "RAID1" |
size=(swapMin+4096)/(len(drives)-spares-max(0,level-4)), |
211 |
else: |
drive=[drive], primary=1, grow=1, format=1) |
212 |
if self.useabledrives >= 6: |
request.uniqueID = uniqueID + 50 |
213 |
self.useabledrives = self.useabledrives - 2 |
raid2.append(uniqueID + 50) |
214 |
raidLevel = "RAID6" |
partitions.autoPartitionRequests.append(request) |
|
elif self.useabledrives >= 2: |
|
|
self.useabledrives = self.useabledrives - 1 |
|
|
if self.useabledrives >= 2: |
|
|
raidLevel = "RAID5" |
|
|
else: |
|
|
raidLevel = "RAID1" |
|
215 |
else: |
else: |
216 |
raidLevel = "RAID1" |
request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"), |
217 |
|
drive=[drive], size=swapMin/(len(drives)-spares-max(0,level-4))+10, grow=1, |
218 |
|
maxSizeMB=swapMax/(len(drives)-spares-max(0,level-4)), format=1, primary=1) |
219 |
|
request.uniqueID = uniqueID + 30 |
220 |
|
raid2.append(uniqueID + 30) |
221 |
|
partitions.autoPartitionRequests.append(request) |
222 |
|
|
223 |
for drive in drives: |
request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"), |
224 |
if not isys.driveIsRemovable(drive): |
size=1500/(len(drives)-spares-max(0,level-4)), |
225 |
filesystem = fileSystemTypeGet("software RAID") |
drive=[drive], grow=1, primary=1, format=1) |
226 |
request = partRequests.PartitionSpec(filesystem, drive=[drive], size=100, primary=1, format=1) |
request.uniqueID = uniqueID + 60 |
227 |
request.uniqueID = uniqueID |
raid3.append(uniqueID + 60) |
|
raid1.append(uniqueID) |
|
228 |
partitions.autoPartitionRequests.append(request) |
partitions.autoPartitionRequests.append(request) |
|
usedDrives.append(drive); |
|
229 |
|
|
230 |
if "nolvm" in cmdline: |
uniqueID = uniqueID + 1 |
|
filesystem = fileSystemTypeGet("software RAID") |
|
|
request = partRequests.PartitionSpec(filesystem, drive=[drive], size=swapMin/self.useabledrives+10, |
|
|
maxSizeMB=swapMax/self.useabledrives, grow=1, primary=1, format=1) |
|
|
request.uniqueID = uniqueID + 30 |
|
|
raid2.append(uniqueID + 30) |
|
|
partitions.autoPartitionRequests.append(request) |
|
|
|
|
|
filesystem = fileSystemTypeGet("software RAID") |
|
|
request = partRequests.PartitionSpec(filesystem, drive=[drive], size=1500/self.useabledrives, |
|
|
grow=1, primary=1, format=1) |
|
|
request.uniqueID = uniqueID + 60 |
|
|
raid3.append(uniqueID + 60) |
|
|
partitions.autoPartitionRequests.append(request) |
|
|
|
|
|
else: |
|
|
filesystem = fileSystemTypeGet("software RAID") |
|
|
if "multipart" in cmdline: |
|
|
request = partRequests.PartitionSpec(filesystem, drive=[drive], size=(swapMin+3000)/self.useabledrives, |
|
|
grow=1, format=1) |
|
|
else: |
|
|
request = partRequests.PartitionSpec(filesystem, drive=[drive], size=(swapMin+1500)/self.useabledrives, |
|
|
grow=1, format=1) |
|
|
request.uniqueID = uniqueID + 50 |
|
|
raid2.append(uniqueID + 50) |
|
|
partitions.autoPartitionRequests.append(request) |
|
|
|
|
|
uniqueID = uniqueID + 1 |
|
|
|
|
|
if "raid1" in cmdline and len(raid1)-spares >= 2: |
|
|
break |
|
|
|
|
|
filesystem = fileSystemTypeGet("ext3") |
|
|
request = partRequests.RaidRequestSpec(filesystem, mountpoint="/boot", raidminor=1, |
|
|
raidmembers=raid1, raidlevel="RAID1", format=1, raidspares=spares) |
|
|
partitions.autoPartitionRequests.append(request) |
|
231 |
|
|
232 |
if "nolvm" in cmdline: |
partitions.autoPartitionRequests.append(partRequests.RaidRequestSpec(fileSystemTypeGet("ext3"), |
233 |
filesystem = fileSystemTypeGet("swap") |
mountpoint="/boot", raidmembers=raid1, raidlevel="RAID1", raidminor=1, format=1, |
234 |
request = partRequests.RaidRequestSpec(filesystem, raidmembers=raid2, raidminor=2, |
raidspares=0)) |
235 |
raidlevel=raidLevel, format=1, raidspares=spares) |
|
236 |
|
if not self.cmdline.has_key("nolvm"): |
237 |
|
request = partRequests.RaidRequestSpec(fileSystemTypeGet("physical volume (LVM)"), |
238 |
|
raidmembers=raid2, raidlevel="RAID"+str(level), raidminor=2, format=1, |
239 |
|
raidspares=spares) |
240 |
|
request.uniqueID = 200 |
241 |
partitions.autoPartitionRequests.append(request) |
partitions.autoPartitionRequests.append(request) |
242 |
|
else: |
243 |
|
partitions.autoPartitionRequests.append(partRequests.RaidRequestSpec(fileSystemTypeGet("swap"), |
244 |
|
raidmembers=raid2, raidlevel="RAID"+str(level), raidminor=2, format=1, raidspares=spares)) |
245 |
|
|
246 |
filesystem = fileSystemTypeGet("ext3") |
partitions.autoPartitionRequests.append(partRequests.RaidRequestSpec(fileSystemTypeGet("ext3"), |
247 |
request = partRequests.RaidRequestSpec(filesystem, mountpoint="/", raidmembers=raid3, raidminor=3, |
mountpoint="/", raidmembers=raid3, raidlevel="RAID"+str(level), raidminor=3, format=1, |
248 |
raidlevel=raidLevel, format=1, raidspares=spares) |
raidspares=spares)) |
|
partitions.autoPartitionRequests.append(request) |
|
249 |
|
|
250 |
else: |
else: |
251 |
filesystem = fileSystemTypeGet("physical volume (LVM)") |
for drive in drives: |
252 |
request = partRequests.RaidRequestSpec(filesystem, raidmembers=raid2, raidminor=2, |
partitions.autoPartitionRequests.append(partRequests.PartitionSpec(fileSystemTypeGet("ext3"), |
253 |
raidlevel=raidLevel, format=1, raidspares=spares) |
mountpoint="/boot", drive=[drive], size=100, primary=1, format=1)) |
254 |
request.uniqueID = 200 |
|
255 |
partitions.autoPartitionRequests.append(request) |
if not self.cmdline.has_key("nolvm"): |
256 |
|
request = partRequests.PartitionSpec(fileSystemTypeGet("physical volume (LVM)"), |
257 |
|
drive=[drive], size=swapMin+4096, grow=1, primary=1, format=1) |
258 |
|
request.uniqueID = 200 |
259 |
|
partitions.autoPartitionRequests.append(request) |
260 |
|
else: |
261 |
|
partitions.autoPartitionRequests.append(partRequests.PartitionSpec(fileSystemTypeGet("ext3"), |
262 |
|
mountpoint="/", drive=[drive], size=4096, grow=1, primary=1, format=1)) |
263 |
|
|
264 |
|
partitions.autoPartitionRequests.append(partRequests.PartitionSpec(fileSystemTypeGet("swap"), |
265 |
|
drive=[drive], size=swapMin, maxSizeMB=swapMax, grow=1, primary=1, format=1)) |
266 |
|
|
267 |
if not "nolvm" in cmdline: |
if not self.cmdline.has_key("nolvm"): |
268 |
request = partRequests.VolumeGroupRequestSpec(vgname="main", physvols=[200], |
request = partRequests.VolumeGroupRequestSpec(vgname="main", physvols=[200], pesize=32768, format=1) |
|
pesize=32768, format=1) |
|
269 |
request.uniqueID = 201 |
request.uniqueID = 201 |
270 |
partitions.autoPartitionRequests.append(request) |
partitions.autoPartitionRequests.append(request) |
271 |
|
|
272 |
if "multipart" in cmdline: |
if not self.cmdline.has_key("multipart"): |
273 |
filesystem = fileSystemTypeGet("ext3") |
partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("ext3"), |
274 |
request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/", size=2048, |
mountpoint="/", size=1300, volgroup=201, lvname="root", grow=1, format=1)) |
|
maxSizeMB=4096, volgroup=201, lvname="root", grow=1, format=1) |
|
|
partitions.autoPartitionRequests.append(request) |
|
275 |
|
|
276 |
filesystem = fileSystemTypeGet("ext3") |
partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("swap"), |
277 |
request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/var", size=1024, |
size=swapMin, maxSizeMB=swapMax, volgroup=201, lvname="swap", grow=1, format=1)) |
278 |
maxSizeMB=4096, volgroup=201, lvname="var", grow=1, format=1) |
else: |
279 |
partitions.autoPartitionRequests.append(request) |
partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("ext3"), |
280 |
|
mountpoint="/", size=2048, maxSizeMB=4096, volgroup=201, lvname="root", grow=1, format=1)) |
281 |
|
|
282 |
filesystem = fileSystemTypeGet("ext3") |
partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("ext3"), |
283 |
request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/home/e-smith/files", size=1024, |
mountpoint="/var", size=1024, maxSizeMB=4096, volgroup=201, lvname="var", grow=1, format=1)) |
|
maxSizeMB=8192, volgroup=201, lvname="files", grow=1, format=1) |
|
|
partitions.autoPartitionRequests.append(request) |
|
284 |
|
|
285 |
filesystem = fileSystemTypeGet("ext3") |
partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("ext3"), |
286 |
request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/tmp", size=512, |
mountpoint="/home/e-smith/files", size=1024, maxSizeMB=8192, volgroup=201, lvname="files", grow=1, format=1)) |
|
maxSizeMB=4096, volgroup=201, lvname="tmp", grow=1, format=1) |
|
|
partitions.autoPartitionRequests.append(request) |
|
287 |
|
|
288 |
filesystem = fileSystemTypeGet("swap") |
partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("ext3"), |
289 |
request = partRequests.LogicalVolumeRequestSpec(filesystem, size=swapMin, maxSizeMB=swapMax, |
mountpoint="/tmp", size=512, maxSizeMB=4096, volgroup=201, lvname="tmp", grow=1, format=1)) |
|
volgroup=201, lvname="swap", grow=1, format=1) |
|
|
partitions.autoPartitionRequests.append(request) |
|
|
else: |
|
|
filesystem = fileSystemTypeGet("ext3") |
|
|
request = partRequests.LogicalVolumeRequestSpec(filesystem, mountpoint="/", size=1300, |
|
|
volgroup=201, lvname="root", grow=1, format=1) |
|
|
partitions.autoPartitionRequests.append(request) |
|
290 |
|
|
291 |
filesystem = fileSystemTypeGet("swap") |
partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("swap"), |
292 |
request = partRequests.LogicalVolumeRequestSpec(filesystem, size=swapMin, maxSizeMB=swapMax, |
size=swapMin, maxSizeMB=swapMax, volgroup=201, lvname="swap", grow=1, format=1)) |
|
volgroup=201, lvname="swap", grow=1, format=1) |
|
|
partitions.autoPartitionRequests.append(request) |
|
293 |
|
|
294 |
partitions.autoClearPartDrives = usedDrives |
partitions.autoClearPartType = CLEARPART_TYPE_ALL |
295 |
|
partitions.autoClearPartDrives = drives |
296 |
|
self.doPartition = False |
297 |
else: |
else: |
298 |
|
log("Not useable drives found. Enabling manual partitioning.") |
299 |
|
self.doPartition = True |
300 |
BaseInstallClass.setDefaultPartitioning(self, partitions, clear, doClear) |
BaseInstallClass.setDefaultPartitioning(self, partitions, clear, doClear) |
301 |
|
|
302 |
def setAsHeadless(self, dispatch, isHeadless = 0): |
def setAsHeadless(self, dispatch, isHeadless = 0): |