[Uludag-commits] r17121 - in branches/yali4-md/yali4: . gui
uludag-commits at pardus.org.tr
uludag-commits at pardus.org.tr
12 Şub 2008 Sal 23:15:23 EET
Author: isbaran
Date: Tue Feb 12 23:15:23 2008
New Revision: 17121
Modified:
branches/yali4-md/yali4/filesystem.py
branches/yali4-md/yali4/gui/DiskWidgets.py
branches/yali4-md/yali4/gui/ScrCheckCD.py
branches/yali4-md/yali4/gui/runner.py
branches/yali4-md/yali4/mdutils.py
branches/yali4-md/yali4/partedutils.py
branches/yali4-md/yali4/partition.py
branches/yali4-md/yali4/partitionrequest.py
branches/yali4-md/yali4/partitiontype.py
branches/yali4-md/yali4/raid.py
branches/yali4-md/yali4/storage.py
branches/yali4-md/yali4/sysutils.py
Log:
nothing important ..
commit to save
Modified: branches/yali4-md/yali4/filesystem.py
=================================================================
--- branches/yali4-md/yali4/filesystem.py (original)
+++ branches/yali4-md/yali4/filesystem.py Tue Feb 12 23:15:23 2008
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
-# Copyright (C) 2005 - 2008 TUBITAK/UEKAE
+# Copyright (C) TUBITAK/UEKAE
# Copyright 2001 - 2004 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify it under
@@ -31,7 +31,6 @@
pass
-
def get_filesystem(name):
# Hardcoding available filesystems like this is TOO
@@ -49,6 +48,10 @@
return XFSFileSystem()
elif name == "fat32":
return FatFileSystem()
+ elif name == "software raid":
+ return RaidFileSystem()
+ elif name == "ext2":
+ return RaidFileSystem()
return None
@@ -176,7 +179,6 @@
def isImplemented(self):
return self._implemented
-
##
# set if filesystem is resizeable
def setResizeable(self, bool):
@@ -187,7 +189,19 @@
def isResizeable(self):
return self._resizeable
+##
+# for dummy raid members
+class RaidFileSystem(FileSystem):
+ _name = "ext2"
+ def __init__(self):
+ FileSystem.__init__(self)
+
+ def format(self, partition):
+ pass
+
+
+
##
# ext3 file system
class Ext3FileSystem(FileSystem):
Modified: branches/yali4-md/yali4/gui/DiskWidgets.py
=================================================================
--- branches/yali4-md/yali4/gui/DiskWidgets.py (original)
+++ branches/yali4-md/yali4/gui/DiskWidgets.py Tue Feb 12 23:15:23 2008
@@ -36,7 +36,8 @@
1:parttype.root,
2:parttype.home,
3:parttype.swap,
- 4:parttype.archive}
+ 4:parttype.archive,
+ 5:parttype.raid}
class DiskList(QtGui.QWidget):
@@ -104,6 +105,7 @@
# add the DiskItem object to tabwidget
# and increase disk count
def addDisk(self,dw):
+ print "Inside addDisk, adding disk : ", self.tabWidget.count()-1, "%s - %s" % (dw.model,dw.name)
# QWidget page, QString label
self.tabWidget.addTab(dw,dw.name)
self.tabWidget.setTabToolTip(self.tabWidget.count()-1,"%s - %s" % (dw.model,dw.name))
@@ -114,10 +116,12 @@
_cur = self.tabWidget.currentIndex()
if _cur==-1: _cur = 0
self.tabWidget.clear()
+ print "cleared the tabwidget"
self.diskCount = 1
for dev in self.devs:
ctx.debugger.log("Device Found %s" % dev.getModel())
+ print "device found %s" % dev.getModel()
# add Device objects representing block devices
# @see storage.py global devices[] and Device
self.addDevice(dev)
@@ -181,10 +185,13 @@
# @see storage.py
def initDevices(self):
self.devs = []
- if not yali4.storage.init_devices():
- raise GUIException, _("Can't find a storage device!")
+ if not yali4.storage.devices:
+ "diskwidgets, init"
+ if not yali4.storage.init_devices():
+ raise GUIException, _("Can't find a storage device!")
self.devs = [i for i in yali4.storage.devices]
+ print self.devs
def resetChanges(self):
yali4.storage.clear_devices()
@@ -194,6 +201,7 @@
def addDevice(self, dev):
# get the size as human readable
+ print "in addDevice %s " % dev._path
def sizeStr(mb):
if mb > 1024:
return _("%0.1f GB free") % long(round(mb/1024.0))
@@ -202,6 +210,7 @@
# add the device to the list
devstr = u"Disk %d (%s)" % (self.diskCount, dev.getName())
+
freespace = dev.getFreeMB()
if freespace:
size_str = dev.getSizeStr() + " (%s)" % sizeStr(freespace)
@@ -214,22 +223,35 @@
# adding the tabwidget page is done
# add partitions on device
- for part in dev.getOrderedPartitionList():
- # we dont show extended partition
- if part.isExtended():
- continue
- # if minor is -1, its freespace
- if part.getMinor() != -1:
- name = _("Partition %d") % part.getMinor()
- if part.isFileSystemReady():
- try:
- name = part.getFSLabel() or name
- except:
- pass
- else:
- name = _("Free Space")
- ctx.debugger.log("Partition added with %s mb" % part.getMB())
- diskItem.addPartition(name,part)
+ print "now will work with partitions of ", dev._path
+ if dev.isRaid():
+ memList = dev.getRaidMembers()
+ if memList:
+ for i in memList:
+ diskItem.addPartition(i)
+ else:
+ for part in dev.getOrderedPartitionList():
+ print "Partition: ", part.getPath()
+ # we dont show extended partition
+ if part.isExtended():
+ print "%s is extended, skip it" % part.getPath()
+ continue
+ # if minor is -1, its freespace
+ if part.getMinor() != -1:
+ name = _("Partition %d") % part.getMinor()
+ if part.isFileSystemReady():
+ try:
+ print "File system ready for %s " % part.getPath()
+ name = part.getFSLabel() or name
+ except:
+ pass
+ else:
+ print "found a freespace : ", part.getPath()
+ name = _("Free Space")
+
+ ctx.debugger.log("Partition added with %s mb" % part.getMB())
+ print "(gui) partition added with %s mb" % part.getMB()
+ diskItem.addPartition(name,part)
diskItem.updateSizes(self.tabWidget.width())
@@ -353,6 +375,7 @@
_data = None
def __init__(self, name, model, partEdit, totalSize):
+ print "initing DiskItem for %s, model: %s, total size: %d" % (name, model, totalSize)
QtGui.QWidget.__init__(self,None)
self.setAutoFillBackground(False)
self.setAttribute(Qt.WA_AlwaysShowToolTips)
@@ -365,11 +388,6 @@
spacerItem1 = QtGui.QSpacerItem(40,20,QtGui.QSizePolicy.Expanding,QtGui.QSizePolicy.Minimum)
self.hboxlayout.addItem(spacerItem1)
- self.raidPushButton = QtGui.QPushButton(_("RAID"), self)
- self.hboxlayout.addWidget(self.raidPushButton)
- self.lvmPushButton = QtGui.QPushButton(_("LVM"), self)
- self.hboxlayout.addWidget(self.lvmPushButton)
-
self.deleteAllPartitions = QtGui.QPushButton(_("Delete All Partitions"),self)
self.hboxlayout.addWidget(self.deleteAllPartitions)
self.vboxlayout.addLayout(self.hboxlayout)
@@ -392,8 +410,6 @@
self.vboxlayout.addItem(spacerItem2)
self.connect(self.deleteAllPartitions,QtCore.SIGNAL("clicked()"),self.deleteAll)
- self.connect(self.raidPushButton, QtCore.SIGNAL("clicked()"),self.slotRaid)
- self.connect(self.lvmPushButton, QtCore.SIGNAL("clicked()"),self.slotLvm)
# this containts dictionary type members as we fill the list
# ex: {"name":name, "data":data} where data is Partition type object
@@ -404,8 +420,10 @@
self.model = model
self.totalSize = totalSize
self.partEdit = partEdit
+
+ print "End of constructer of DiskItem for %s" % name
- # data is Partition type object and name is label for partition
+ # @param data is Partition type object and @param name is label for partition
# like "Free Space" or "Partition /dev/hda1"
# @see partition.py
def addPartition(self,name=None,data=None):
@@ -429,7 +447,10 @@
"icon" :"linux"},
"linux-swap(new)":{"bgcolor":"#C1665A",
"fgcolor":"#FFFFFF",
- "icon" :"linux"}}
+ "icon" :"linux"},
+ "software raid":{"bgcolor":"#000000",
+ "fgcolor":"#999999",
+ "icon" :"other"}}
if metaTypes.has_key(fs_type):
return metaTypes[fs_type]
@@ -437,7 +458,29 @@
"fgcolor":"#000000",
"icon" :"other"}
+ print "inside diskItem.addPartition"
+ print "trying to add : %s" % name
+
+ if not data:
+ _name = "\n" + _("Software Raid Partition")
+ _mpoint = "[]"
+
+ partition = QtGui.QRadioButton("%s%s" % (name, _name), self.diskGroup)
+ partition.setFocusPolicy(Qt.NoFocus)
+ meta = getFSMeta("software raid")
+ icon = meta["icon"]
+
+ partition.setIcon(QtGui.QIcon(":/gui/pics/%s.png" % icon))
+ partition.setIconSize(QSize(32,32))
+ partition.setStyleSheet("background-color:%s;color:%s" % (meta["bgcolor"],meta["fgcolor"]))
+
+ self.splinter.addWidget(partition)
+ return
+
partitionType = getPartitionType(data)
+ print "BREAK POINT"
+ print "partitionType is : ", partitionType
+
_name = ''
_mpoint = ''
if partitionType:
@@ -453,6 +496,10 @@
elif partitionType == partitionTypes[4]:
_name += "\n" +_("Backup or archive files will store here")
_mpoint= "[ /mnt/archive ]"
+ elif partitionType == partitionTypes[5]:
+ _name += "\n" +_("A Software Raid Partition")
+ _mpoint= "[]"
+
partition = QtGui.QRadioButton("%s%s\n%s %s" % (name, _name, data.getSizeStr(), _mpoint), self.diskGroup)
partition.setFocusPolicy(Qt.NoFocus)
if data._parted_type == parteddata.freeSpaceType:
@@ -537,14 +584,19 @@
# pt are objects derived from PartitionType class
# like RootPartitionType or SwapPartitionType objects
# @see partitiontype.py
+ print "inside getPartitionType"
for pt in partitionTypes.values():
+ print "iterating over partitiontypes :"
# We use MountRequest type for search keyword
# which is 1, defined in partitionrequest.py
req = ctx.partrequests.searchPartTypeAndReqType(pt, rt)
if req:
+ print "request ok from searchPartTypeAndReqType for : ", pt.name
if req.partition() == part:
+ print "req.partition == part"
return pt
+ return None
class PartEdit(QtGui.QWidget):
Modified: branches/yali4-md/yali4/gui/ScrCheckCD.py
=================================================================
--- branches/yali4-md/yali4/gui/ScrCheckCD.py (original)
+++ branches/yali4-md/yali4/gui/ScrCheckCD.py Tue Feb 12 23:15:23 2008
@@ -60,7 +60,7 @@
self.ui.checkLabel.setText(_('<font color="#FF6D19">Please wait while checking CD.</font>'))
yali4.pisiiface.initialize(ui=PisiUI())
yali4.pisiiface.add_cd_repo()
- ctx.mainScreen.proceesEvents()
+ ctx.mainScreen.processEvents()
pkg_names = yali4.pisiiface.get_available()
self.ui.progressBar.setMaximum(len(pkg_names))
Modified: branches/yali4-md/yali4/gui/runner.py
=================================================================
--- branches/yali4-md/yali4/gui/runner.py (original)
+++ branches/yali4-md/yali4/gui/runner.py Tue Feb 12 23:15:23 2008
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
-# Copyright (C) 2005-2007, TUBITAK/UEKAE
+# Copyright (C) TUBITAK/UEKAE
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
Modified: branches/yali4-md/yali4/mdutils.py
=================================================================
--- branches/yali4-md/yali4/mdutils.py (original)
+++ branches/yali4-md/yali4/mdutils.py Tue Feb 12 23:15:23 2008
@@ -10,11 +10,11 @@
# Please read the COPYING file.
#
-from sysutils import execWithCapture
+from yali4.sysutils import execWithCapture
import sys
import os
import string
-import partedutils
+import yali4.partedutils
mdadmOutput = "/tmp/mdadmout"
raidCount = {}
@@ -61,7 +61,7 @@
# @return A tuple of contents of the RAID superblock, or ValueError.
def raidsbFromDevice(device):
try:
- info = partedutils._getRaidInfo(device)
+ info = yali4.partedutils._getRaidInfo(device)
return (info['major'], info['minor'], info['uuid'], info['level'],
info['nrDisks'], info['totalDisks'], info['mdMinor'])
except:
@@ -96,7 +96,7 @@
else:
minor = int(mdDevice[2:])
try:
- info = partedutils._getRaidInfo(mbrInode)
+ info = yali4.partedutils._getRaidInfo(mbrInode)
if info.has_key('mdMinor'):
minor = info['mdMinor']
_startRaid( mdInode, minor, info['uuid'])
Modified: branches/yali4-md/yali4/partedutils.py
=================================================================
--- branches/yali4-md/yali4/partedutils.py (original)
+++ branches/yali4-md/yali4/partedutils.py Tue Feb 12 23:15:23 2008
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
-# Copyright (C) 2008 TUBITAK/UEKAE
+# Copyright (C) TUBITAK/UEKAE
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
@@ -14,9 +14,10 @@
import string
import os.path
import subprocess
-import mdutils
import parted
+import yali4.mdutils
+
def get_partition_name(partition):
""" Return the device name for the PedPartition partition """
if( partition.geom.dev.type == parted.DEVICE_DAC960
@@ -61,10 +62,10 @@
def _getRaidInfo(drive, raidDevice=False):
try:
if raidDevice:
- lines = mdutils._mdadm("--detail", drive)
+ lines = yali4.mdutils._mdadm("--detail", drive)
else:
- lines = mdutils._mdadm("-E", drive)
- except mdutils.MdadmError:
+ lines = yali4.mdutils._mdadm("-E", drive)
+ except yali4.mdutils.MdadmError:
ei = sys.exc_info()
ei[1].name = drive
raise ei[0], ei[1], ei[2]
Modified: branches/yali4-md/yali4/partition.py
=================================================================
--- branches/yali4-md/yali4/partition.py (original)
+++ branches/yali4-md/yali4/partition.py Tue Feb 12 23:15:23 2008
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
-# Copyright (C) 2005-2008, TUBITAK/UEKAE
+# Copyright (C) TUBITAK/UEKAE
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
@@ -26,6 +26,7 @@
class Partition:
def __init__(self, device, parted_part, minor, mb, start, end, fs_name, fs_ready=True):
+ print "inside constructer of Partition object, for %s%d " % (device._path, minor)
self._device = device
self._partition = parted_part
self._minor = minor
@@ -68,7 +69,10 @@
# check if partition is extended
def isExtended(self):
return self._partition.type == parted.PARTITION_EXTENDED
-
+
+ # later
+ def isRaid(self):
+ return self._partition.type == parted.PARTITION_RAID
##
# get freespace on extended partition
@@ -177,6 +181,7 @@
class FreeSpace(Partition):
def __init__(self, device, parted_part, mb, start, end):
+ print "Creating a freespace Partition for %s%d" % (device._path, parted_part.num)
Partition.__init__(self, device,
parted_part,
-1,
Modified: branches/yali4-md/yali4/partitionrequest.py
=================================================================
--- branches/yali4-md/yali4/partitionrequest.py (original)
+++ branches/yali4-md/yali4/partitionrequest.py Tue Feb 12 23:15:23 2008
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
-# Copyright (C) 2005-2008, TUBITAK/UEKAE
+# Copyright (C) TUBITAK/UEKAE
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
@@ -22,13 +22,15 @@
from yali4.constants import consts
import yali4.partitiontype as parttype
import yali4.sysutils
+import yali4.raid
class RequestException(YaliException):
pass
# poor man's enum ;)
formatRequestType, mountRequestType, \
- swapFileRequestType, labelRequestType = range(4)
+ swapFileRequestType, labelRequestType, \
+ raidRequestType = range(5)
##
# requests object holds the list of requests
@@ -155,33 +157,51 @@
# @param pt: Partition Type (defined in partitiontype.py)
# @param rt: Request Type
def searchPartTypeAndReqType(self, pt, rt):
- req = [x for x in self.searchPartTypeAndReqTypeIterate(pt, rt)]
- # this should give (at most) one result
- # cause we are storing one request for a partitionType()
- assert(len(req) <= 1)
-
- if not req:
- return None
- else:
- # return the only request found.
- return req.pop()
-
+ reqList = []
+ for x in self.searchPartTypeAndReqTypeIterate(pt, rt):
+ # if request type is a custom request type
+ # we'll allow multiple pt/rt instances
+ reqList.append(x)
+ if ( x.requestType() in range(4) ):
+ # this should give (at most) one result
+ # cause we are storing one request for a partitionType()
+ assert(len(reqList) <= 1)
+ if reqList:
+ return reqList
+ return None
##
# add/append a request
def append(self, req):
+ # whats this for ?
self.removeRequest(req.partition(), req.requestType())
rt = req.requestType()
pt = req.partitionType()
found = self.searchPartTypeAndReqType(pt, rt)
- # RequestList stores only one request for a requestType() -
+ # FIXME RequestList stores only one request for a requestType() -
# partitionType() pair.
if found:
- e = _("There is a request for the same Partition Type.")
- raise RequestException, e
-
+ if ( rt in range(4) ):
+ # request - type pair that should exist once
+ e = _("There is a request for the same Partition Type.")
+ raise RequestException, e
+ for request in found:
+ # now request is a request on a custom or raid partition type
+ if request.partitionType().mountpoint:
+ # has a mount point
+ if request.partitionType().mountpoint == pt.mountpoint:
+ # there's already a partition request for that mount point
+ e = _("There is a request for that Mount Point.")
+ raise RequestException, e
+ else:
+ if rt == raidRequestType:
+ # this is a raidPartitionRequest, all found request should be raid requests
+ if pt.getMinor() == request.partitionType().getMinor():
+ e = _("There is a Raid request for that partition")
+ raise RequestException, e
+
list.append(self, req)
@@ -386,7 +406,42 @@
PartRequest.applyRequest(self)
+##
+# raid partition request
+class RaidRequest(PartRequest):
+
+ def __init__(self, partition, part_type):
+
+ PartRequest.__init__(self)
+ self.setPartition(partition)
+ self.setPartitionType(part_type)
+ self.setRequestType(raidRequestType)
+
+ def applyRequest(self):
+ pass
+ # PartRequest.applyRequest(self)
+
+##
+# @param drive is the drive to remove
+# @param start is the start sector of deleted partition
+# @param end is the end sector of deleted partition
+class DeletePartitionRequest:
+ """ A preexisting partition which will be removed """
+ def __init__(self, drive, start, end):
+
+ self.drive = drive
+ self.start = start
+ self.end = end
+
+
+class DeleteRaidRequest:
+ """ A preexisting Raid device which will be removed """
+ def __init__(self, minor):
+
+ self.minor = minor
+
+
# partition requests singleton.
partrequests = RequestList()
Modified: branches/yali4-md/yali4/partitiontype.py
=================================================================
--- branches/yali4-md/yali4/partitiontype.py (original)
+++ branches/yali4-md/yali4/partitiontype.py Tue Feb 12 23:15:23 2008
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
-# Copyright (C) 2005-2008, TUBITAK/UEKAE
+# Copyright (C) TUBITAK/UEKAE
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
@@ -89,8 +89,68 @@
elif filesystem == "ext3":
self.filesystem = yali4.filesystem.Ext3FileSystem()
+##
+# mountpoint'e göre custom partition oluştur.
+class CustomPartitionType(PartitionType):
+ def __init__(self, name, mountpoint, mountoptions, parted_type,
+ parted_flags, filesystem=None, label=None):
+ self.name = name
+ if filesystem:
+ self.filesystem = filesystem
+ self.mountpoint = mountpoint
+ self.parted_type = parted_type
+ self.parted_flags = parted_flags
+ if label:
+ self.label = label
+ else:
+ self.label = "ARCHIVE"
+
+
+class RaidPartitionType(PartitionType):
+ def __init__(self, raidminor=None, raidlevel = None, raidmembers = None,
+ raidspares = None, chunksize = None, isdummy = True):
+ self.name = _("Software RAID")
+ self.filesystem = yali4.filesystem.RaidFileSystem()
+ self.mountpoint = None
+ self.mountoptions = None
+ self.parted_type = parted.PARTITION_RAID
+ self.parted_flags = []
+ self.label = "SOFTWARE_RAID"
+
+ self._isdummy = isdummy
+ self._raidminor = raidminor
+ # we dont need this for dummy raid partitions
+ if not isdummy:
+ self._raidlevel = raidlevel
+ self._raidmembers = raidmembers
+ self._raidspares = raidspares
+ self._chunksize = chunksize
+
+ def sanityCheck(self):
+ minmembers = yali4.raid.get_raid_min_members(self._raidlevel)
+ if len(self._raidmembers) < minmembers:
+ return _("A Raid device of type %s "
+ "requires at least %s members.") % (self._raidlevel,
+ minmembers)
+
+ if len(self._raidmembers) > 27:
+ return "Raid devices are limited to 27 members"
+
+ if self._raidspares:
+ if (len(self._raidmembers) - self._raidspares) < minmembers:
+ return _("This Raid device can have a maximum of %s spares. "
+ "To have more spares, you should add more members "
+ "to raid device.") % ( len(self._raidmembers) - minmembers )
+
+ return None
+
+ def getMinor(self):
+ return self._raidminor
+
+
root = RootPartitionType()
home = HomePartitionType()
swap = SwapPartitionType()
archive = ArchivePartitionType()
+raid = RaidPartitionType()
Modified: branches/yali4-md/yali4/raid.py
=================================================================
--- branches/yali4-md/yali4/raid.py (original)
+++ branches/yali4-md/yali4/raid.py Tue Feb 12 23:15:23 2008
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-
#
-# Copyright (C) 2008 TUBITAK/UEKAE
+# Copyright (C) TUBITAK/UEKAE
+# Copyright 2001 - 2004 Red Hat, Inc.
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
@@ -34,10 +35,9 @@
availRaidLevels = getRaidLevels()
-import parted
-import partedutils
-import os
-import mdutils
+import parted, os
+import yali4.partedutils
+import yali4.mdutils
import yali4.storage
# these arches can have their /boot on RAID
@@ -53,17 +53,21 @@
raidDevices = {}
if not yali4.storage.devices:
+ print "device list empty, calling yali4.storage.init_devices()"
if not yali4.storage.init_devices():
- print "no devices attached"
+ print "no devices returned from storage"
devs = yali4.storage.devices
+ print "devices on system are: ",
+ for i in devs:
+ print " ", i._path,
for d in devs:
# scan for Device objects
parts = []
try:
- raidParts = partedutils.get_raid_partitions(d._disk)
+ raidParts = yali4.partedutils.get_raid_partitions(d._disk)
for part in raidParts:
- parts.append(partedutils.get_partition_name(part))
+ parts.append(yali4.partedutils.get_partition_name(part))
except:
pass
@@ -72,7 +76,7 @@
for dev in parts:
try:
# get the superblock from raid device
- (major, minor, raidSet, level, nrDisks, totalDisks, mdMinor) = mdutils.raidsbFromDevice("/dev/%s"%dev)
+ (major, minor, raidSet, level, nrDisks, totalDisks, mdMinor) = yali4.mdutils.raidsbFromDevice("/dev/%s"%dev)
except ValueError:
# cant be part of raid set
print "reading raid sb failed for %s", dev
@@ -118,23 +122,25 @@
def startAllRaid():
""" Start raid on raid devices, returns same struct as scanForRaid """
- global mdList
rc = []
rl = yali4.storage.mdList
if not rl:
rl = scanForRaid()
for mdDevice, deviceList, level, numActive in rl:
devName = "md%d" % (mdDevice,)
- mdutils.raidstart(devName, deviceList[0])
+ yali4.mdutils.raidstart(devName, deviceList[0])
rc.append((devName, deviceList, level, numActive))
+ yali4.storage.mdList = rl
return rc
def stopAllRaid():
""" Stop all raid devices in tuple mdList """
- global mdList
rl = yali4.storage.mdList
+ if not rl:
+ print "scanning raidlist"
+ rl = scanForRaid()
for dev, devices, level, numActive in rl:
- mdutils.raidstop(dev)
+ yali4.mdutils.raidstop("md%s"%dev)
def isRaid10(raidlevel):
""" Return whether raidlevel is a valid descriptor of RAID10. """
@@ -201,18 +207,12 @@
def register_raid_device(mdname, newdevices, newlevel, newnumActive):
""" Register a new RAID device in storage.mdList """
- for dev, devices, level, numActive in storage.mdList:
+ for dev, devices, level, numActive in yali4.storage.mdList:
if mdname == dev:
if (devices!=newdevices or level!=newlevel or numActive!=newnumActive):
raise ValueError, "%s is already in the mdlist!" %(mdname,)
else:
return
- storage.mdList.append((mdname, newdevices[:], newlevel, newnumActive))
+ yali4.storage.mdList.append((mdname, newdevices[:], newlevel, newnumActive))
-def lookup_raid_device(mdname):
- """ Return requested RAID device information """
- for dev, devices, level, numActive in storage.mdList:
- if mdname == dev:
- return (dev, devices, level, numActive)
- raise KeyError, "md device not found"
Modified: branches/yali4-md/yali4/storage.py
=================================================================
--- branches/yali4-md/yali4/storage.py (original)
+++ branches/yali4-md/yali4/storage.py Tue Feb 12 23:15:23 2008
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
-# Copyright (C) 2005-2008, TUBITAK/UEKAE
+# Copyright (C) TUBITAK/UEKAE
# Copyright 1999-2005 Gentoo Foundation
#
# This program is free software; you can redistribute it and/or modify it under
@@ -25,8 +25,6 @@
import glob
import struct
import binascii
-import raid
-import partedutils
from yali4.parteddata import *
from yali4.partition import Partition, FreeSpace
@@ -52,34 +50,42 @@
global raidMembers
if devices and not force:
+ print "inited before, run with force=True"
return True
- # this keeps the raid devices that wont be added to device list
- # because they're part of a software raid
restricteds = []
+ devices = []
# all devices including raid devices
devs = detect_devices()
# find software raid devices and exclude their members from global device list
for i in devs:
- if os.path.exists("/sys/block/%s/md" % i.split('/')[-1:][0]):
- for root, dirs, files in os.walk("/sys/block/%s/slaves" % i.split('/')[-1:][0]):
+ md = i.split('/')[-1:][0]
+ if os.path.exists("/sys/block/%s/md" % md):
+ for root, dirs, files in os.walk("/sys/block/%s/slaves" % md):
for name in dirs:
# append members of raid to restricteds
restricteds.append("/dev/%s" % name)
+ raidMembers.append((i, restricteds,
+ open("/sys/block/%s/md/level" % md).read().strip(), len(restricteds)))
+ restricteds = []
for dev_path in devs:
- # dont put raid members to devices, we only want top level devices
- if dev_path in restricteds:
- continue
- else:
+ check = True
+ # dont put raid members to devices
+ for rm in raidMembers:
+ if dev_path in rm[1]:
+ check = False
+ if check:
d = Device(dev_path)
devices.append(d)
# devices are appended in reverse order
devices.reverse()
- raidMembers = restricteds
+
+ print devices
+ print raidMembers
if devices:
return True
@@ -113,10 +119,22 @@
self._length = 0 # total sectors
self._sector_size = 0
self._parted_type = deviceType
-
+ self._isRaid = False
+ self._raidMembers = []
+ global raidMembers
+
+ for i in raidMembers:
+ if device_path == i[0]:
+ print "init raid %s" % device_path
+ self._isRaid = True
+ self._raidMembers = i[1]
+
dev = parted.PedDevice.get(device_path)
- self._model = dev.model
+ if self._isRaid:
+ self._model = "software raid"
+ else:
+ self._model = dev.model
self._length = dev.length
self._sector_size = dev.sector_size
@@ -125,6 +143,7 @@
self._disk = parted.PedDisk.new(dev)
except:
label = archinfo[self._arch]["disklabel"]
+ # PedDiskType object disk_type
disk_type = parted.disk_type_get(label)
self._disk = self._dev.disk_new_fresh(disk_type)
@@ -132,24 +151,70 @@
self._path = device_path
- self.update()
-
+ if not self._isRaid:
+ print "init %s" % device_path
+ self.update()
##
+ # print summary for device
+ def printSummary(self):
+ print "%s için özet: (debug) " % self._path
+ if self._isRaid:
+ print "%s bir raid device" % self._path,
+ print "üyeleri: ", self._raidMembers
+ else:
+ print "%s raid device degil" % self._path
+ print "%s'nin modeli : " % self._path, self._model
+ print "%s'nin uzunluğu : " % self._path, self._length
+ print "%s'nin sektör büyüklüğü : " % self._path, self._sector_size
+ print "%s'nin disk etiketi : " % self._path, self._disklabel
+
+ ##
# clear and re-fill partitions dict.
def update(self):
self._partitions = []
+ print "updating partitions of ", self._path
+ #if self.isRaid():
+ # return
part = self._disk.next_partition()
+
while part:
- self.__addToPartitionsDict(part)
+ if part.num >= 1:
+ if not self.isPartOfRaid("%s%d" % (self._path, part.num)):
+ self.__addToPartitionsDict(part)
part = self._disk.next_partition(part)
##
- # @return Returns if dev is part of a software raid
- def isPartOfRaid(dev):
- if dev in raidMembers:
- return True
+ # @return Returns if part is a RAID type partition
+ # @param part is a Partition object
+ def isPartitionRaidType(self, part):
+ flag = parted.PARTITION_RAID
+ if not part._parted_type == freeSpaceType:
+ ped = part.getPartition()
+ if ped.is_flag_available(flag) and ped.get_flag(flag):
+ return True
+ return False
+
+ ##
+ # @return Returns raid type partitions of device
+ def getRaidTypePartitions(self):
+ flag = parted.PARTITION_RAID
+ raidParts = []
+
+ for p in self.getPartitions():
+ if not p._parted_type == freeSpaceType:
+ ped = p.getPartition()
+ if ped.is_flag_available(flag) and ped.get_flag(flag):
+ raidParts.append(p)
+ return raidParts
+
+ ##
+ # Checks if path is in global raidMembers list
+ def isPartOfRaid(self, path):
+ for i in raidMembers:
+ if path in i[1]:
+ return True
return False
##
@@ -162,7 +227,12 @@
return False
return True
-
+ def getRaidMembers(self):
+ return self._raidMembers
+
+ def isRaid(self):
+ return self._isRaid
+
def getType(self):
return self._parted_type
@@ -427,14 +497,22 @@
#
# @returns: Partition
def __addToPartitionsDict(self, part, fs_ready=True):
+ print "[inside] addToPartitionsDict for : %s%d " % (self._path, part.num)
geom = part.geom
part_mb = long((geom.end - geom.start + 1) * self._sector_size / MEGABYTE)
+ print part_mb
if part.num >= 1:
fs_name = ""
if part.fs_type:
fs_name = part.fs_type.name
+ print "setting fs_name to :", fs_name
elif part.type & parted.PARTITION_EXTENDED:
fs_name = "extended"
+ print "settings fs_name to :", fs_name
+ elif part.type & parted.PARTITION_RAID:
+ print "setting fs_name to software raid"
+ fs_name = "software raid"
+ fs_ready = False
self._partitions.append(Partition(self, part,
part.num,
Modified: branches/yali4-md/yali4/sysutils.py
=================================================================
--- branches/yali4-md/yali4/sysutils.py (original)
+++ branches/yali4-md/yali4/sysutils.py Tue Feb 12 23:15:23 2008
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
-# Copyright (C) 2005-2008, TUBITAK/UEKAE
+# Copyright (C) TUBITAK/UEKAE
#
# This program is free software; you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free
@@ -180,4 +180,38 @@
return rc
+import re
+import string
+
+# Based on RedHat's ZoneTab class
+class TimeZoneEntry:
+ def __init__(self, code=None, timeZone=None):
+ self.code = code
+ self.timeZone = timeZone
+
+class TimeZoneList:
+ def __init__(self, fromFile='/usr/share/zoneinfo/zone.tab'):
+ self.entries = []
+ self.readTimeZone(fromFile)
+
+ def getEntries(self):
+ return self.entries
+
+ def readTimeZone(self, fn):
+ f = open(fn, 'r')
+ comment = re.compile("^#")
+ while 1:
+ line = f.readline()
+ if not line:
+ break
+ if comment.search(line):
+ continue
+ fields = string.split(line, '\t')
+ if len(fields) < 3:
+ continue
+ code = fields[0]
+ timeZone = string.strip(fields[2])
+ entry = TimeZoneEntry(code, timeZone)
+ self.entries.append(entry)
+
Uludag-commits mesaj listesiyle ilgili
daha fazla bilgi