|
|
|
@ -612,17 +612,27 @@ class MultiPartitions:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PartitionDistributive(Distributive):
|
|
|
|
|
formatUtilities = { 'ext2':'/sbin/mkfs.ext2 %s',
|
|
|
|
|
'ext3':'/sbin/mkfs.ext3 %s',
|
|
|
|
|
'ext4':'/sbin/mkfs.ext4 %s',
|
|
|
|
|
'jfs':'/sbin/mkfs.jfs -f %s',
|
|
|
|
|
'reiserfs':'/sbin/mkfs.reiserfs -f %s',
|
|
|
|
|
'xfs':'/sbin/mkfs.xfs -f %s',
|
|
|
|
|
'vfat':'/usr/sbin/mkfs.vfat -F 32 %s',
|
|
|
|
|
'ntfs-3g':'/usr/sbin/mkfs.ntfs -FQ %s',
|
|
|
|
|
'ntfs':'/usr/sbin/mkfs.ntfs -FQ %s',
|
|
|
|
|
formatUtilities = { 'ext2':'/sbin/mkfs.ext2 %s %s',
|
|
|
|
|
'ext3':'/sbin/mkfs.ext3 %s %s',
|
|
|
|
|
'ext4':'/sbin/mkfs.ext4 %s %s',
|
|
|
|
|
'jfs':'/sbin/mkfs.jfs %s -f %s',
|
|
|
|
|
'reiserfs':'/sbin/mkfs.reiserfs %s -f %s',
|
|
|
|
|
'xfs':'/sbin/mkfs.xfs %s -f %s',
|
|
|
|
|
'vfat':'/usr/sbin/mkfs.vfat %s -F 32 %s',
|
|
|
|
|
'ntfs-3g':'/usr/sbin/mkfs.ntfs %s -FQ %s',
|
|
|
|
|
'ntfs':'/usr/sbin/mkfs.ntfs %s -FQ %s',
|
|
|
|
|
'swap':'/sbin/mkswap %s'
|
|
|
|
|
}
|
|
|
|
|
labelForUtilities = { 'ext2':'-L %s',
|
|
|
|
|
'ext3':'-L %s',
|
|
|
|
|
'ext4':'-L %s',
|
|
|
|
|
'jfs':'-L %s',
|
|
|
|
|
'reiserfs':'-l %s',
|
|
|
|
|
'xfs':'-L %s',
|
|
|
|
|
'vfat':'-n %s',
|
|
|
|
|
'ntfs-3g':'-L %s',
|
|
|
|
|
'ntfs':'-L %s',
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
formatId = { 'ext2' : '83',
|
|
|
|
|
'ext3' : '83',
|
|
|
|
@ -636,7 +646,8 @@ class PartitionDistributive(Distributive):
|
|
|
|
|
|
|
|
|
|
def __init__(self,partition,parent=None,mdirectory="/mnt/calculate",
|
|
|
|
|
check=False,multipartition=None,flagRemoveDir=True,
|
|
|
|
|
fileSystem="reiserfs", isFormat=True,systemId=None):
|
|
|
|
|
fileSystem="reiserfs", isFormat=True,systemId=None,
|
|
|
|
|
rootLabel="Calculate"):
|
|
|
|
|
"""Initialize partition distributive
|
|
|
|
|
|
|
|
|
|
mdirectory - directory for mount
|
|
|
|
@ -652,6 +663,7 @@ class PartitionDistributive(Distributive):
|
|
|
|
|
self.isFormat = isFormat
|
|
|
|
|
self.DirectoryObject = None
|
|
|
|
|
self.systemId = systemId
|
|
|
|
|
self.rootLabel = rootLabel
|
|
|
|
|
|
|
|
|
|
def _mountPartition(self,partition,directory,opts=""):
|
|
|
|
|
"""Mount partition to directory"""
|
|
|
|
@ -745,7 +757,11 @@ class PartitionDistributive(Distributive):
|
|
|
|
|
if fileSystem=="swap":
|
|
|
|
|
self.formatSwapPartition(dev)
|
|
|
|
|
else:
|
|
|
|
|
self.formatPartition(dev, format=fileSystem)
|
|
|
|
|
if dev == self.partition:
|
|
|
|
|
self.formatPartition(dev, format=fileSystem,
|
|
|
|
|
label=self.rootLabel)
|
|
|
|
|
else:
|
|
|
|
|
self.formatPartition(dev, format=fileSystem)
|
|
|
|
|
changeidPartitions = map(lambda x: (x[3],x[1]),
|
|
|
|
|
filter(lambda x: x[3],
|
|
|
|
|
dataPartitions))
|
|
|
|
@ -753,7 +769,7 @@ class PartitionDistributive(Distributive):
|
|
|
|
|
self.changeSystemID(dev,systemid)
|
|
|
|
|
return True
|
|
|
|
|
|
|
|
|
|
def formatPartition(self, dev,format="reiserfs"):
|
|
|
|
|
def formatPartition(self, dev,format="reiserfs",label=""):
|
|
|
|
|
"""Format partition"""
|
|
|
|
|
if not format in self.formatUtilities:
|
|
|
|
|
raise DistributiveError(
|
|
|
|
@ -770,7 +786,13 @@ class PartitionDistributive(Distributive):
|
|
|
|
|
if not os.access(dev,os.W_OK):
|
|
|
|
|
raise DistributiveError(_("Cann't format partition") + " %s:\n%s"%
|
|
|
|
|
(dev,_("Permission denied")))
|
|
|
|
|
execStr = self.formatUtilities[format]%dev
|
|
|
|
|
if label:
|
|
|
|
|
labelStr = self.labelForUtilities.get(format,"")
|
|
|
|
|
if labelStr:
|
|
|
|
|
labelStr = labelStr%label
|
|
|
|
|
else:
|
|
|
|
|
labelStr = ""
|
|
|
|
|
execStr = self.formatUtilities[format]%(labelStr,dev)
|
|
|
|
|
res,errmes = self.runOsCommand(execStr)
|
|
|
|
|
if res == 0:
|
|
|
|
|
return True
|
|
|
|
@ -783,7 +805,8 @@ class PartitionDistributive(Distributive):
|
|
|
|
|
if self.multipartition:
|
|
|
|
|
self.formatAllPartitions()
|
|
|
|
|
elif self.isFormat:
|
|
|
|
|
self.formatPartition(self.partition,format=self.fileSystem)
|
|
|
|
|
self.formatPartition(self.partition,format=self.fileSystem,
|
|
|
|
|
label=self.rootLabel)
|
|
|
|
|
|
|
|
|
|
def changeSystemID(self,dev,systemid):
|
|
|
|
|
parentDir = path.split(dev)[0]
|
|
|
|
|