summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorShireesh Anjal <anjalshireesh@gmail.com>2011-07-21 08:42:29 -0700
committerShireesh Anjal <anjalshireesh@gmail.com>2011-07-21 08:42:29 -0700
commitc5fd622463dba84b5586bdd4a3e6c1feb443e687 (patch)
treeccdfa2064f715d79eab4f4c2e2779e0459b1ac27 /src
parent7d87a6d6fe26c6e406e1bf0362f77af74f94c090 (diff)
parent6fd3466cd4b386362d77a62178d90ddb39edb831 (diff)
Merge pull request #137 from TimothyAsir/master
Added function to get disk details from proc/mounts when HAL does not able to provide disk details.
Diffstat (limited to 'src')
-rw-r--r--src/com.gluster.storage.management.server.scripts/src/DiskUtils.py35
1 files changed, 33 insertions, 2 deletions
diff --git a/src/com.gluster.storage.management.server.scripts/src/DiskUtils.py b/src/com.gluster.storage.management.server.scripts/src/DiskUtils.py
index bffbe940..1e22ebdf 100644
--- a/src/com.gluster.storage.management.server.scripts/src/DiskUtils.py
+++ b/src/com.gluster.storage.management.server.scripts/src/DiskUtils.py
@@ -125,6 +125,27 @@ def getRootPartition(fsTabFile=Globals.FSTAB_FILE):
return getDeviceName(fsTabEntry["Device"])
return None
+def getMounts():
+ mounts = {}
+ for line in readFile("/proc/mounts"):
+ str = line.strip()
+ if str.startswith("/dev/"):
+ tokens = str.split()
+ device = {}
+ mountPoint = tokens[1].strip()
+ device["MountPoint"] = mountPoint
+ device["FsType"] = tokens[2].strip()
+ device["Uuid"] = getDiskPartitionUuid(tokens[0].strip())
+ device["Status"] = "INITIALIZED"
+ if mountPoint:
+ if "/export/" in mountPoint:
+ device["Type"] = "DATA"
+ else:
+ device["Type"] = "BOOT"
+ else:
+ device["Type"] = "UNKNOWN"
+ mounts[tokens[0].strip()] = device
+ return mounts
def getRaidDisk():
array = []
@@ -203,6 +224,7 @@ def getDiskInfo(diskDeviceList=None):
if Utils.isString(diskDeviceList):
diskDeviceList = [diskDeviceList]
+ mounts = getMounts()
if Utils.runCommand("/usr/bin/lshal") != 0:
Utils.log("failed running /usr/bin/lshal")
@@ -232,6 +254,7 @@ def getDiskInfo(diskDeviceList=None):
disk["Size"] = long(halDevice.GetProperty('storage.size')) / 1024**2
disk["Interface"] = str(halDevice.GetProperty('storage.bus'))
disk["DriveType"] = str(halDevice.GetProperty('storage.drive_type'))
+ disk["Status"] = None
disk["Uuid"] = None
disk["Init"] = False
disk["Type"] = None
@@ -241,9 +264,7 @@ def getDiskInfo(diskDeviceList=None):
disk["ReadOnlyAccess"] = None
disk["SpaceInUse"] = None
- partitionList = []
partitionUdiList = halManager.FindDeviceStringMatch("info.parent", udi)
- disk["Status"] = "UNINITIALIZED"
if isDiskInFormatting(disk["Device"]):
disk["Status"] = "INITIALIZING"
else:
@@ -251,6 +272,16 @@ def getDiskInfo(diskDeviceList=None):
disk["Status"] = "INITIALIZED"
else:
disk["Status"] = "UNINITIALIZED"
+ disk["Type"] = "UNKNOWN"
+
+ if mounts and mounts.has_key(disk["Device"]):
+ disk["Uuid"] = mounts[disk["Device"]]["Uuid"]
+ disk["Type"] = mounts[disk["Device"]]["Type"]
+ disk["Status"] = mounts[disk["Device"]]["Status"]
+ disk["FsType"] = mounts[disk["Device"]]["FsType"]
+ disk["MountPoint"] = mounts[disk["Device"]]["MountPoint"]
+
+ partitionList = []
diskSpaceInUse = 0
for partitionUdi in partitionUdiList:
used = 0