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

Diff of /cdrom.image/sme7/product/installclasses/smeinstallclass.py

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

Revision 1.2 by slords, Sun Jun 7 02:30:05 2009 UTC Revision 1.6 by slords, Thu Aug 26 22:09:11 2010 UTC
# Line 13  import partedUtils Line 13  import partedUtils
13    
14  class Script:  class Script:
15      def __repr__(self):      def __repr__(self):
16          str = ("(s: '%s' i: %s c: %d)") %  \          str = ("(s: '%s' i: %s c: %d)") % \
17              (self.script, self.interp, self.inChroot)              (self.script, self.interp, self.inChroot)
18          return string.replace(str, "\n", "|")          return string.replace(str, "\n", "|")
19    
# Line 62  class InstallClass(BaseInstallClass): Line 62  class InstallClass(BaseInstallClass):
62    
63      sortPriority = 1      sortPriority = 1
64    
     cmdline = {}  
     doPartition = False  
   
65      parentClass = ( _("Install SME Server"), "smeserver.png" )      parentClass = ( _("Install SME Server"), "smeserver.png" )
66    
67      def requiredDisplayMode(self):      def requiredDisplayMode(self):
# Line 85  class InstallClass(BaseInstallClass): Line 82  class InstallClass(BaseInstallClass):
82    
83          return cmdlineDict          return cmdlineDict
84    
     def mediaPresent(self, device):  
         try:  
             fd = os.open("/dev/%s" % device, os.O_RDONLY)  
         except OSError, (errno, strerror):  
             # error 123 = No medium found  
             if errno == 123:  
                 return False  
             else:  
                 return True  
         else:  
             os.close(fd)  
             return True  
   
85      def setSteps(self, dispatch):      def setSteps(self, dispatch):
86            self.anaconda = dispatch
87            self.cmdline = self.createCmdlineDict()
88    
89          dispatch.setStepList(          dispatch.setStepList(
90                     "betanag",
91                   "language",                   "language",
92                   "keyboard",                   "keyboard",
93                   "findrootparts",                   "findrootparts",
                  "betanag",  
94                   "installtype",                   "installtype",
95                   "partitionobjinit",                   "partitionobjinit",
96                   "autopartitionexecute",                   "autopartitionexecute",
                  "partition",  
97                   "partitiondone",                   "partitiondone",
98                   "bootloadersetup",                   "bootloadersetup",
99                   "languagesupport",                   "languagesupport",
# Line 125  class InstallClass(BaseInstallClass): Line 111  class InstallClass(BaseInstallClass):
111                   "postinstallconfig",                   "postinstallconfig",
112                   "writeconfig",                   "writeconfig",
113                   "instbootloader",                   "instbootloader",
                  "dopostaction",  
114                   "writeksconfig",                   "writeksconfig",
                  "methodcomplete",  
                  "copylogs",  
115                   "setfilecon",                   "setfilecon",
116                     "copylogs",
117                     "dopostaction",
118                     "methodcomplete",
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 self.cmdline.has_key("partition"):          dispatch.skipStep("partition", skip = (1,0)[self.cmdline.has_key("partition")])
             dispatch.skipStep("partition", skip = 0)  
         else:  
             dispatch.skipStep("partition", skip = 1)  
125    
126      def setDefaultPartitioning(self, partitions, clear = CLEARPART_TYPE_LINUX, doClear = 1):      def setDefaultPartitioning(self, partitions, clear = CLEARPART_TYPE_LINUX, doClear = 1):
127          self.cmdline = self.createCmdlineDict()          diskset = self.anaconda.id.diskset
128          diskset = partedUtils.DiskSet()  
129            if self.cmdline.has_key("exclude"):
130                alldrives = filter(lambda x:not (partedUtils.hasProtectedPartitions(x, self.anaconda) or
131                                                 x in self.cmdline["exclude"].split(",")), diskset.driveList())
132            else:
133                alldrives = filter(lambda x:not partedUtils.hasProtectedPartitions(x, self.anaconda), diskset.disks.keys())
134    
         alldrives = diskset.driveList()  
135          if self.cmdline.has_key("drives"):          if self.cmdline.has_key("drives"):
136              drives = filter(lambda x:self.mediaPresent(x) and              if self.cmdline["drives"] == "all":
137                                       x in self.cmdline["drives"].split(","), alldrives)                  drives = alldrives
138                else:
139                    drives = filter(lambda x:x in self.cmdline["drives"].split(","), alldrives)
140          else:          else:
141              drives = filter(lambda x:not isys.driveIsRemovable(x) and              drives = filter(lambda x:not isys.driveUsesModule(x, ["usb-storage", "ub", "sbp2"]), alldrives)
                                      self.mediaPresent(x) and  
                                      not isys.driveUsesModule(x, ["usb-storage", "ub", "sbp2"]), alldrives)  
142    
143          if self.cmdline.has_key("spares"):          if self.cmdline.has_key("spares"):
144              spares = max(0,min(int(self.cmdline["spares"]),len(drives)-2))              if self.cmdline["spares"] == "none":
145                    spares = 0
146                else:
147                    try:
148                        spares = max(0,min(int(self.cmdline["spares"]),len(drives)-2))
149                    except:
150                        spares = (len(drives)+4)/7
151          else:          else:
152              spares = (len(drives)+4)/7              spares = (len(drives)+4)/7
153    
# Line 175  class InstallClass(BaseInstallClass): Line 167  class InstallClass(BaseInstallClass):
167                  if spares > 1 and not self.cmdline.has_key("spares"):                  if spares > 1 and not self.cmdline.has_key("spares"):
168                      spares = 1                      spares = 1
169                  del drives[2+spares:]                  del drives[2+spares:]
170            elif len(drives) > 1 and len(drives) == len(filter(lambda x:x.startswith('mapper/'), alldrives)):
171                level = -1
172                del drives[1:]
173                spares = 0
174          else:          else:
175              if len(drives) - spares >= 6:              if len(drives) - spares >= 6:
176                  level = 6                  level = 6
# Line 185  class InstallClass(BaseInstallClass): Line 181  class InstallClass(BaseInstallClass):
181    
182          if len(drives) >= 1:          if len(drives) >= 1:
183              log("Using the following drives: %s" % drives)              log("Using the following drives: %s" % drives)
184                excluded = filter(lambda x:x not in drives, diskset.disks.keys())
185                if excluded:
186                    log("Excluding the following drives: %s" % excluded)
187                skipped = filter(lambda x:x not in diskset.disks.keys(), diskset.driveList())
188                if skipped:
189                    log("Skipping the following drives: %s" % skipped)
190              if level >= 1:              if level >= 1:
191                  log("Installing using RAID%s" % level)                  log("Installing using RAID%s" % level)
192                  log("Using %s spare drives" % spares)                  log("Using %s spare drives" % spares)
193                elif level < 0:
194                    log("Detected BIOS raid (skipping raid)")
195              else:              else:
196                  log("Installing without using RAID")                  log("Installing without using RAID")
197    
# Line 206  class InstallClass(BaseInstallClass): Line 210  class InstallClass(BaseInstallClass):
210                      partitions.autoPartitionRequests.append(request)                      partitions.autoPartitionRequests.append(request)
211    
212                      if not self.cmdline.has_key("nolvm"):                      if not self.cmdline.has_key("nolvm"):
213                          request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"),                          if not self.cmdline.has_key("multipart"):
214                                  size=(swapMin+4096)/(len(drives)-spares-max(0,level-4)),                              request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"),
215                                  drive=[drive], primary=1, grow=1, format=1)                                      size=(swapMin+1536)/(len(drives)-spares-max(0,level-4)),
216                                        drive=[drive], primary=1, grow=1, format=1)
217                            else:
218                                request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"),
219                                        size=(swapMin+5120)/(len(drives)-spares-max(0,level-4)),
220                                        drive=[drive], primary=1, grow=1, format=1)
221                          request.uniqueID = uniqueID + 50                          request.uniqueID = uniqueID + 50
222                          raid2.append(uniqueID + 50)                          raid2.append(uniqueID + 50)
223                          partitions.autoPartitionRequests.append(request)                          partitions.autoPartitionRequests.append(request)
# Line 221  class InstallClass(BaseInstallClass): Line 230  class InstallClass(BaseInstallClass):
230                          partitions.autoPartitionRequests.append(request)                          partitions.autoPartitionRequests.append(request)
231    
232                          request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"),                          request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"),
233                                  size=1500/(len(drives)-spares-max(0,level-4)),                                  size=1536/(len(drives)-spares-max(0,level-4)),
234                                  drive=[drive], grow=1, primary=1, format=1)                                  drive=[drive], grow=1, primary=1, format=1)
235                          request.uniqueID = uniqueID + 60                          request.uniqueID = uniqueID + 60
236                          raid3.append(uniqueID + 60)                          raid3.append(uniqueID + 60)
# Line 244  class InstallClass(BaseInstallClass): Line 253  class InstallClass(BaseInstallClass):
253                              raidmembers=raid2, raidlevel="RAID"+str(level), raidminor=2, format=1, raidspares=spares))                              raidmembers=raid2, raidlevel="RAID"+str(level), raidminor=2, format=1, raidspares=spares))
254    
255                      partitions.autoPartitionRequests.append(partRequests.RaidRequestSpec(fileSystemTypeGet("ext3"),                      partitions.autoPartitionRequests.append(partRequests.RaidRequestSpec(fileSystemTypeGet("ext3"),
256                              mountpoint="/", raidmembers=raid3,  raidlevel="RAID"+str(level), raidminor=3, format=1,                              mountpoint="/", raidmembers=raid3, raidlevel="RAID"+str(level), raidminor=3, format=1,
257                              raidspares=spares))                              raidspares=spares))
258    
259              else:              else:
260                  for drive in drives:                  for drive in drives:
261                      partitions.autoPartitionRequests.append(partRequests.PartitionSpec(fileSystemTypeGet("ext3"),                      partitions.autoPartitionRequests.append(partRequests.PartitionSpec(fileSystemTypeGet("ext3"),
262                          mountpoint="/boot", drive=[drive], size=100, primary=1, format=1))                              mountpoint="/boot", drive=[drive], size=100, primary=1, format=1))
263    
264                      if not self.cmdline.has_key("nolvm"):                      if not self.cmdline.has_key("nolvm"):
265                          request = partRequests.PartitionSpec(fileSystemTypeGet("physical volume (LVM)"),                          if not self.cmdline.has_key("multipart"):
266                                  drive=[drive], size=swapMin+4096, grow=1, primary=1, format=1)                              request = partRequests.PartitionSpec(fileSystemTypeGet("physical volume (LVM)"),
267                                        drive=[drive], size=swapMin+1536, grow=1, primary=1, format=1)
268                            else:
269                                request = partRequests.PartitionSpec(fileSystemTypeGet("physical volume (LVM)"),
270                                        drive=[drive], size=swapMin+5120, grow=1, primary=1, format=1)
271                          request.uniqueID = 200                          request.uniqueID = 200
272                          partitions.autoPartitionRequests.append(request)                          partitions.autoPartitionRequests.append(request)
273                      else:                      else:
274                          partitions.autoPartitionRequests.append(partRequests.PartitionSpec(fileSystemTypeGet("ext3"),                          partitions.autoPartitionRequests.append(partRequests.PartitionSpec(fileSystemTypeGet("ext3"),
275                                  mountpoint="/", drive=[drive], size=4096, grow=1, primary=1, format=1))                                  mountpoint="/", drive=[drive], size=1536, grow=1, primary=1, format=1))
276    
277                          partitions.autoPartitionRequests.append(partRequests.PartitionSpec(fileSystemTypeGet("swap"),                          partitions.autoPartitionRequests.append(partRequests.PartitionSpec(fileSystemTypeGet("swap"),
278                                  drive=[drive], size=swapMin, maxSizeMB=swapMax, grow=1, primary=1, format=1))                                  drive=[drive], size=swapMin, maxSizeMB=swapMax, grow=1, primary=1, format=1))
# Line 271  class InstallClass(BaseInstallClass): Line 284  class InstallClass(BaseInstallClass):
284    
285                  if not self.cmdline.has_key("multipart"):                  if not self.cmdline.has_key("multipart"):
286                      partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("ext3"),                      partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("ext3"),
287                              mountpoint="/", size=1300, volgroup=201, lvname="root", grow=1, format=1))                              mountpoint="/", size=1536, volgroup=201, lvname="root", grow=1, format=1))
288    
289                      partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("swap"),                      partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("swap"),
290                              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 286  class InstallClass(BaseInstallClass): Line 299  class InstallClass(BaseInstallClass):
299                              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))
300    
301                      partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("ext3"),                      partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("ext3"),
302                              mountpoint="/tmp", size=512, maxSizeMB=4096, volgroup=201, lvname="tmp", grow=1, format=1))                              mountpoint="/tmp", size=1024, maxSizeMB=4096, volgroup=201, lvname="tmp", grow=1, format=1))
303    
304                      partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("swap"),                      partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("swap"),
305                              size=swapMin, maxSizeMB=swapMax, volgroup=201, lvname="swap", grow=1, format=1))                              size=swapMin, maxSizeMB=swapMax, volgroup=201, lvname="swap", grow=1, format=1))
306    
307              partitions.autoClearPartType = CLEARPART_TYPE_ALL              partitions.autoClearPartType = CLEARPART_TYPE_ALL
308              partitions.autoClearPartDrives = drives              partitions.autoClearPartDrives = drives
             self.doPartition = False  
309          else:          else:
310              log("Not useable drives found.  Enabling manual partitioning.")              log("Not useable drives found.  Enabling manual partitioning.")
311              self.doPartition = True              BaseInstallClass.setDefaultPartitioning(self, partitions, clear = CLEARPART_TYPE_ALL, doClear = True)
312              BaseInstallClass.setDefaultPartitioning(self, partitions, clear, doClear)              self.anaconda.skipStep("partition", skip = 0)
313    
314      def setAsHeadless(self, dispatch, isHeadless = 0):      def setAsHeadless(self, dispatch, isHeadless = 0):
315          if isHeadless == 0:          if isHeadless == 0:
# Line 331  class InstallClass(BaseInstallClass): Line 343  class InstallClass(BaseInstallClass):
343          self.setRootPassword(id, pw="ThisIsGoingToBeDisabledAnyway", isCrypted=0)          self.setRootPassword(id, pw="ThisIsGoingToBeDisabledAnyway", isCrypted=0)
344          self.setZeroMbr(id, zeroMbr=1)          self.setZeroMbr(id, zeroMbr=1)
345          self.setClearParts(id, clear=CLEARPART_TYPE_ALL, initAll=1)          self.setClearParts(id, clear=CLEARPART_TYPE_ALL, initAll=1)
         self.setDefaultPartitioning(id.partitions, doClear=0)  
346          self.setBootloader(id, useLilo=0, location="mbr", linear=1)          self.setBootloader(id, useLilo=0, location="mbr", linear=1)
347    
348      def __init__(self, expert):      def __init__(self, expert):


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