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

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

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

Revision 1.1 by slords, Sat Jun 6 23:51:54 2009 UTC Revision 1.4 by slords, Wed Jun 10 14:22:18 2009 UTC
# Line 67  class InstallClass(BaseInstallClass): Line 67  class InstallClass(BaseInstallClass):
67      description = N_("This option performs a new install of "      description = N_("This option performs a new install of "
68                       "SME Server.  All attached hard drives "                       "SME Server.  All attached hard drives "
69                       "will be repartitioned and formated.")                       "will be repartitioned and formated.")
70    
71      sortPriority = 1      sortPriority = 1
72      doPartition = False      doPartition = False
73    
# Line 75  class InstallClass(BaseInstallClass): Line 76  class InstallClass(BaseInstallClass):
76      def requiredDisplayMode(self):      def requiredDisplayMode(self):
77          return 't'          return 't'
78    
79        def driveIsRemovable(self, device):
80            try:
81                removable = bool(int(open("/sys/block/%s/removable" % device).read()))
82            except:
83                removable = False
84                
85            return removable
86    
87      def setSteps(self, dispatch):      def setSteps(self, dispatch):
88          dispatch.setStepList(          dispatch.setStepList(
89                   "language",                   "language",
# Line 110  class InstallClass(BaseInstallClass): Line 119  class InstallClass(BaseInstallClass):
119                   "complete"                   "complete"
120                  )                  )
121    
122          # 'partition' can be used on the command line to force          # 'partition' can be used on the command line to force
123          # verification of partitions.  useful in some cases...          # verification of partitions.  useful in some cases...
124          if self.doPartition or flags.cmdline.has_key("partition"):          if self.doPartition or flags.cmdline.has_key("partition"):
125              if not self.doPartition:              if not self.doPartition:
# Line 123  class InstallClass(BaseInstallClass): Line 132  class InstallClass(BaseInstallClass):
132      def setDefaultPartitioning(self, partitions, clear = CLEARPART_TYPE_LINUX, doClear = 1):      def setDefaultPartitioning(self, partitions, clear = CLEARPART_TYPE_LINUX, doClear = 1):
133          diskset = partedUtils.DiskSet()          diskset = partedUtils.DiskSet()
134    
135          alldrives = diskset.driveList()          if flags.cmdline.has_key("exclude"):
136                alldrives = filter(lambda x:not x in flags.cmdline["exclude"].split(","), diskset.driveList())
137            else:
138                alldrives = diskset.driveList()
139    
140          if flags.cmdline.has_key("drives"):          if flags.cmdline.has_key("drives"):
141              drives = filter(lambda x:isys.mediaPresent(x) and x in flags.cmdline["drives"].split(","), alldrives)              if flags.cmdline["drives"] == "all":
142                    drives = filter(lambda x:isys.mediaPresent(x), alldrives)
143                else:
144                    drives = filter(lambda x:isys.mediaPresent(x) and
145                                             x in flags.cmdline["drives"].split(","), alldrives)
146          else:          else:
147              drives = filter(lambda x:isys.mediaPresent(x) and not isys.driveUsesModule(x, ["usb-storage", "sbp2"]), alldrives)              drives = filter(lambda x:not self.driveIsRemovable(x) and
148                                         isys.mediaPresent(x) and
149                                         not isys.driveUsesModule(x, ["usb-storage", "ub", "sbp2"]), alldrives)
150    
151          if flags.cmdline.has_key("spares"):          if flags.cmdline.has_key("spares"):
152              spares = max(0,min(int(flags.cmdline["spares"]),len(drives)-2))              if flags.cmdline["spares"] == "none":
153                    spares = 0
154                else:
155                    try:
156                        spares = max(0,min(int(flags.cmdline["spares"]),len(drives)-2))
157                    except:
158                        spares = (len(drives)+4)/7
159          else:          else:
160              spares = (len(drives)+4)/7              spares = (len(drives)+4)/7
161    
# Line 158  class InstallClass(BaseInstallClass): Line 183  class InstallClass(BaseInstallClass):
183              else:              else:
184                  level = 1                  level = 1
185    
         log.info("Using the following drives: %s" % drives)  
         if level >= 1:  
             log.info("Installing using RAID%s" % level)  
             log.info("Using %s spare drives" % spares)  
         else:  
             log.warning("Installing without using RAID")  
   
         (swapMin, swapMax) = iutil.swapSuggestion()  
186          if len(drives) >= 1:          if len(drives) >= 1:
187                excluded = filter(lambda x:x not in drives, diskset.driveList())
188                log.info("Using the following drives: %s" % drives)
189                log.info("Excluding the following drives: %s" % excluded)
190                if level >= 1:
191                    log.info("Installing using RAID%s" % level)
192                    log.info("Using %s spare drives" % spares)
193                else:
194                    log.warning("Installing without using RAID")
195    
196                (swapMin, swapMax) = iutil.swapSuggestion()
197              if level >= 1:              if level >= 1:
198                  raid1 = []                  raid1 = []
199                  raid2 = []                  raid2 = []
# Line 174  class InstallClass(BaseInstallClass): Line 201  class InstallClass(BaseInstallClass):
201                  uniqueID = 100                  uniqueID = 100
202    
203                  for drive in drives:                  for drive in drives:
204                      request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"),                      request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"),
205                              drive=[drive], size=100, primary=1, format=1)                              drive=[drive], size=100, primary=1, format=1)
206                      request.uniqueID = uniqueID                      request.uniqueID = uniqueID
207                      raid1.append(uniqueID)                      raid1.append(uniqueID)
208                      partitions.autoPartitionRequests.append(request)                      partitions.autoPartitionRequests.append(request)
209    
210                      if not flags.cmdline.has_key("nolvm"):                      if not flags.cmdline.has_key("nolvm"):
211                          request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"),                          request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"),
212                                  size=(swapMin+4096)/(len(drives)-spares-max(0,level-4)),                                  size=(swapMin+4096)/(len(drives)-spares-max(0,level-4)),
213                                  drive=[drive], primary=1, grow=1, format=1)                                  drive=[drive], primary=1, grow=1, format=1)
214                          request.uniqueID = uniqueID + 50                          request.uniqueID = uniqueID + 50
215                          raid2.append(uniqueID + 50)                          raid2.append(uniqueID + 50)
216                          partitions.autoPartitionRequests.append(request)                          partitions.autoPartitionRequests.append(request)
217                      else:                      else:
218                          request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"),                          request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"),
219                                  drive=[drive], size=swapMin/(len(drives)-spares-max(0,level-4))+10, grow=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)                                  maxSizeMB=swapMax/(len(drives)-spares-max(0,level-4)), format=1, primary=1)
221                          request.uniqueID = uniqueID + 30                          request.uniqueID = uniqueID + 30
222                          raid2.append(uniqueID + 30)                          raid2.append(uniqueID + 30)
223                          partitions.autoPartitionRequests.append(request)                          partitions.autoPartitionRequests.append(request)
224    
225                          request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"),                          request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"),
226                                  size=1500/(len(drives)-spares-max(0,level-4)),                                  size=1500/(len(drives)-spares-max(0,level-4)),
227                                  drive=[drive], grow=1, primary=1, format=1)                                  drive=[drive], grow=1, primary=1, format=1)
228                          request.uniqueID = uniqueID + 60                          request.uniqueID = uniqueID + 60
229                          raid3.append(uniqueID + 60)                          raid3.append(uniqueID + 60)
# Line 204  class InstallClass(BaseInstallClass): Line 231  class InstallClass(BaseInstallClass):
231    
232                      uniqueID = uniqueID + 1                      uniqueID = uniqueID + 1
233    
234                  partitions.autoPartitionRequests.append(partRequests.RaidRequestSpec(fileSystemTypeGet("ext3"),                  partitions.autoPartitionRequests.append(partRequests.RaidRequestSpec(fileSystemTypeGet("ext3"),
235                          mountpoint="/boot", raidmembers=raid1, raidlevel="RAID1", raidminor=1, format=1,                          mountpoint="/boot", raidmembers=raid1, raidlevel="RAID1", raidminor=1, format=1,
236                          raidspares=0))                          raidspares=0))
237    
238                  if not flags.cmdline.has_key("nolvm"):                  if not flags.cmdline.has_key("nolvm"):
239                      request = partRequests.RaidRequestSpec(fileSystemTypeGet("physical volume (LVM)"),                      request = partRequests.RaidRequestSpec(fileSystemTypeGet("physical volume (LVM)"),
240                              raidmembers=raid2, raidlevel="RAID"+str(level), raidminor=2, format=1,                              raidmembers=raid2, raidlevel="RAID"+str(level), raidminor=2, format=1,
241                              raidspares=spares)                              raidspares=spares)
242                      request.uniqueID = 200                      request.uniqueID = 200
243                      partitions.autoPartitionRequests.append(request)                      partitions.autoPartitionRequests.append(request)
244                  else:                  else:
245                      partitions.autoPartitionRequests.append(partRequests.RaidRequestSpec(fileSystemTypeGet("swap"),                      partitions.autoPartitionRequests.append(partRequests.RaidRequestSpec(fileSystemTypeGet("swap"),
246                              raidmembers=raid2, raidlevel="RAID"+str(level), raidminor=2, format=1, raidspares=spares))                              raidmembers=raid2, raidlevel="RAID"+str(level), raidminor=2, format=1, raidspares=spares))
247    
248                      partitions.autoPartitionRequests.append(partRequests.RaidRequestSpec(fileSystemTypeGet("ext3"),                      partitions.autoPartitionRequests.append(partRequests.RaidRequestSpec(fileSystemTypeGet("ext3"),
249                              mountpoint="/", raidmembers=raid3, raidlevel="RAID"+str(level), raidminor=3, format=1,                              mountpoint="/", raidmembers=raid3, raidlevel="RAID"+str(level), raidminor=3, format=1,
250                              raidspares=spares))                              raidspares=spares))
251    
252              else:              else:
253                  for drive in drives:                  for drive in drives:
254                      partitions.autoPartitionRequests.append(partRequests.PartitionSpec(fileSystemTypeGet("ext3"),                      partitions.autoPartitionRequests.append(partRequests.PartitionSpec(fileSystemTypeGet("ext3"),
255                              mountpoint="/boot", drive=[drive], size=100, primary=1, format=1))                              mountpoint="/boot", drive=[drive], size=100, primary=1, format=1))
256    
257                      if not flags.cmdline.has_key("nolvm"):                      if not flags.cmdline.has_key("nolvm"):
# Line 246  class InstallClass(BaseInstallClass): Line 273  class InstallClass(BaseInstallClass):
273    
274                  if not flags.cmdline.has_key("multipart"):                  if not flags.cmdline.has_key("multipart"):
275                      partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("ext3"),                      partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("ext3"),
276                          mountpoint="/", size=1300, volgroup=201, lvname="root", grow=1, format=1))                              mountpoint="/", size=1300, volgroup=201, lvname="root", grow=1, format=1))
277    
278                      partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("swap"),                      partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("swap"),
279                              size=swapMin, maxSizeMB=swapMax, volgroup=201, lvname="swap", grow=1, format=1))                              size=swapMin, maxSizeMB=swapMax, volgroup=201, lvname="swap", grow=1, format=1))
# Line 257  class InstallClass(BaseInstallClass): Line 284  class InstallClass(BaseInstallClass):
284                      partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("ext3"),                      partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("ext3"),
285                              mountpoint="/var", size=1024, maxSizeMB=4096, volgroup=201, lvname="var", grow=1, format=1))                              mountpoint="/var", size=1024, maxSizeMB=4096, volgroup=201, lvname="var", grow=1, format=1))
286    
287                      partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("ext3"),                      partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("ext3"),
288                              mountpoint="/home/e-smith/files", size=1024, maxSizeMB=8192, volgroup=201, lvname="files", grow=1, format=1))                              mountpoint="/home/e-smith/files", size=1024, maxSizeMB=8192, volgroup=201, lvname="files", grow=1, format=1))
289    
290                      partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("ext3"),                      partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("ext3"),
# Line 266  class InstallClass(BaseInstallClass): Line 293  class InstallClass(BaseInstallClass):
293                      partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("swap"),                      partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("swap"),
294                              size=swapMin, maxSizeMB=swapMax, volgroup=201, lvname="swap", grow=1, format=1))                              size=swapMin, maxSizeMB=swapMax, volgroup=201, lvname="swap", grow=1, format=1))
295    
296              partitions.autoClearPartType = clear              partitions.autoClearPartType = CLEARPART_TYPE_ALL
297              partitions.autoClearPartDrives = drives              partitions.autoClearPartDrives = drives
298              self.doPartition = False              self.doPartition = False
299          else:          else:


Legend:
Removed lines/characters  
Changed lines/characters
  Added lines/characters

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