--- cdrom.image/sme8/updates/installclasses/smeinstallclass.py 2009/06/06 23:51:54 1.1 +++ cdrom.image/sme8/updates/installclasses/smeinstallclass.py 2009/06/07 02:30:05 1.2 @@ -75,6 +75,14 @@ class InstallClass(BaseInstallClass): def requiredDisplayMode(self): return 't' + def driveIsRemovable(self, device): + try: + removable = bool(int(open("/sys/block/%s/removable" % device).read())) + except: + removable = False + + return removable + def setSteps(self, dispatch): dispatch.setStepList( "language", @@ -110,7 +118,7 @@ class InstallClass(BaseInstallClass): "complete" ) - # 'partition' can be used on the command line to force + # 'partition' can be used on the command line to force # verification of partitions. useful in some cases... if self.doPartition or flags.cmdline.has_key("partition"): if not self.doPartition: @@ -125,9 +133,12 @@ class InstallClass(BaseInstallClass): alldrives = diskset.driveList() if flags.cmdline.has_key("drives"): - drives = filter(lambda x:isys.mediaPresent(x) and x in flags.cmdline["drives"].split(","), alldrives) + drives = filter(lambda x:isys.mediaPresent(x) and + x in flags.cmdline["drives"].split(","), alldrives) else: - 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 + isys.mediaPresent(x) and + not isys.driveUsesModule(x, ["usb-storage", "ub", "sbp2"]), alldrives) if flags.cmdline.has_key("spares"): spares = max(0,min(int(flags.cmdline["spares"]),len(drives)-2)) @@ -158,15 +169,15 @@ class InstallClass(BaseInstallClass): else: level = 1 - 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() if len(drives) >= 1: + 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() if level >= 1: raid1 = [] raid2 = [] @@ -174,29 +185,29 @@ class InstallClass(BaseInstallClass): uniqueID = 100 for drive in drives: - request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"), + request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"), drive=[drive], size=100, primary=1, format=1) request.uniqueID = uniqueID raid1.append(uniqueID) partitions.autoPartitionRequests.append(request) if not flags.cmdline.has_key("nolvm"): - request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"), + request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"), size=(swapMin+4096)/(len(drives)-spares-max(0,level-4)), drive=[drive], primary=1, grow=1, format=1) request.uniqueID = uniqueID + 50 raid2.append(uniqueID + 50) partitions.autoPartitionRequests.append(request) else: - request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"), + request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"), drive=[drive], size=swapMin/(len(drives)-spares-max(0,level-4))+10, grow=1, maxSizeMB=swapMax/(len(drives)-spares-max(0,level-4)), format=1, primary=1) request.uniqueID = uniqueID + 30 raid2.append(uniqueID + 30) partitions.autoPartitionRequests.append(request) - request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"), - size=1500/(len(drives)-spares-max(0,level-4)), + request = partRequests.PartitionSpec(fileSystemTypeGet("software RAID"), + size=1500/(len(drives)-spares-max(0,level-4)), drive=[drive], grow=1, primary=1, format=1) request.uniqueID = uniqueID + 60 raid3.append(uniqueID + 60) @@ -204,27 +215,27 @@ class InstallClass(BaseInstallClass): uniqueID = uniqueID + 1 - partitions.autoPartitionRequests.append(partRequests.RaidRequestSpec(fileSystemTypeGet("ext3"), + partitions.autoPartitionRequests.append(partRequests.RaidRequestSpec(fileSystemTypeGet("ext3"), mountpoint="/boot", raidmembers=raid1, raidlevel="RAID1", raidminor=1, format=1, raidspares=0)) if not flags.cmdline.has_key("nolvm"): - request = partRequests.RaidRequestSpec(fileSystemTypeGet("physical volume (LVM)"), - raidmembers=raid2, raidlevel="RAID"+str(level), raidminor=2, format=1, + request = partRequests.RaidRequestSpec(fileSystemTypeGet("physical volume (LVM)"), + raidmembers=raid2, raidlevel="RAID"+str(level), raidminor=2, format=1, raidspares=spares) request.uniqueID = 200 partitions.autoPartitionRequests.append(request) else: - partitions.autoPartitionRequests.append(partRequests.RaidRequestSpec(fileSystemTypeGet("swap"), + partitions.autoPartitionRequests.append(partRequests.RaidRequestSpec(fileSystemTypeGet("swap"), raidmembers=raid2, raidlevel="RAID"+str(level), raidminor=2, format=1, raidspares=spares)) partitions.autoPartitionRequests.append(partRequests.RaidRequestSpec(fileSystemTypeGet("ext3"), - mountpoint="/", raidmembers=raid3, raidlevel="RAID"+str(level), raidminor=3, format=1, + mountpoint="/", raidmembers=raid3, raidlevel="RAID"+str(level), raidminor=3, format=1, raidspares=spares)) else: for drive in drives: - partitions.autoPartitionRequests.append(partRequests.PartitionSpec(fileSystemTypeGet("ext3"), + partitions.autoPartitionRequests.append(partRequests.PartitionSpec(fileSystemTypeGet("ext3"), mountpoint="/boot", drive=[drive], size=100, primary=1, format=1)) if not flags.cmdline.has_key("nolvm"): @@ -257,7 +268,7 @@ class InstallClass(BaseInstallClass): partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("ext3"), mountpoint="/var", size=1024, maxSizeMB=4096, volgroup=201, lvname="var", grow=1, format=1)) - partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("ext3"), + partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("ext3"), mountpoint="/home/e-smith/files", size=1024, maxSizeMB=8192, volgroup=201, lvname="files", grow=1, format=1)) partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("ext3"), @@ -266,7 +277,7 @@ class InstallClass(BaseInstallClass): partitions.autoPartitionRequests.append(partRequests.LogicalVolumeRequestSpec(fileSystemTypeGet("swap"), size=swapMin, maxSizeMB=swapMax, volgroup=201, lvname="swap", grow=1, format=1)) - partitions.autoClearPartType = clear + partitions.autoClearPartType = CLEARPART_TYPE_ALL partitions.autoClearPartDrives = drives self.doPartition = False else: