def getProcPartitions(): procPartitionsDict = {} s = MyAPI.readFile("/proc/partitions", lines=True) for line in s[2:]: tokens = line.strip().split() procPartitionsDict[tokens[3]] = {"Size": long(tokens[2])} return procPartitionsDict
def getProcPartitions(): procPartitionsDict = {} s = MyAPI.readFile("/proc/partitions", lines=True) for line in s[2:]: tokens = line.strip().split() procPartitionsDict[tokens[3]] = {"Size" : long(tokens[2])} return procPartitionsDict
def getDeviceMountPoint(device): lines = MyAPI.readFile("/proc/mounts", lines=True) uuid = getUuidByDiskPartition(device) for line in lines: tokens = line.split() if tokens[0] == device or (uuid and tokens[0].endswith(uuid)): return tokens[1] return None
def isBrick(device): lines = MyAPI.readFile("/proc/mounts", lines=True) uuid = getUuidByDiskPartition(device) device = getDevice(device) for line in lines: tokens = line.split() if tokens[0] == device or (uuid and tokens[0].endswith(uuid)): if tokens[1] in glob.glob("/brick/*"): return True return False
def getProcMdstat(): raidArrayDict = {} lines = MyAPI.readFile("/proc/mdstat", lines=True) for line in lines[1:]: tokens = line.strip().split() if not tokens: continue if tokens[0].startswith("md"): raidArrayDict[tokens[0]] = {"Status" : tokens[2], "Type" : tokens[3], "Member" : [token.split('[')[0] for token in tokens[4:]]} return raidArrayDict
def getProcMdstat(): raidArrayDict = {} lines = MyAPI.readFile("/proc/mdstat", lines=True) for line in lines[1:]: tokens = line.strip().split() if not tokens: continue if tokens[0].startswith("md"): raidArrayDict[tokens[0]] = { "Status": tokens[2], "Type": tokens[3], "Member": [token.split('[')[0] for token in tokens[4:]] } return raidArrayDict
def CheckRaidfix(): scriptfile = "/opt/glustermg/1.0.0alpha/backend/fixraid.py" flag = os.access(scriptfile,os.F_OK) confflag = False conf = MyAPI.readFile('/etc/udev/rules.d/60-raw.rules',lines=True) for line in conf: if re.search(scriptfile,line): confflag = True if not flag: return "Not installed" elif not confflag: return "Not configured" else: return "Configured"
def CheckRaidfix(): scriptfile = "/opt/glustermg/1.0.0alpha/backend/fixraid.py" flag = os.access(scriptfile, os.F_OK) confflag = False conf = MyAPI.readFile('/etc/udev/rules.d/60-raw.rules', lines=True) for line in conf: if re.search(scriptfile, line): confflag = True if not flag: return "Not installed" elif not confflag: return "Not configured" else: return "Configured"
def CheckAlert(): alertfile = '/opt/glustermg/1.0.0alpha/backend/alert.py' flag = os.access(alertfile,os.F_OK) confflag = False conf = MyAPI.readFile('/etc/crontab',lines=True) for line in conf: if re.search(alertfile,line): confflag = True if not flag: res = "Not installed" elif not confflag: res = "Not configured" else: res = "Configured" return res
def CheckAlert(): alertfile = '/opt/glustermg/1.0.0alpha/backend/alert.py' flag = os.access(alertfile, os.F_OK) confflag = False conf = MyAPI.readFile('/etc/crontab', lines=True) for line in conf: if re.search(alertfile, line): confflag = True if not flag: res = "Not installed" elif not confflag: res = "Not configured" else: res = "Configured" return res
def isDirMounted(mountpoint): mountflag = 0 errorflag = 0 lines = MyAPI.readFile("/proc/mounts", lines=True) for line in lines: tokens = line.split() if tokens[1] == mountpoint: mountflag = 1 if mountflag == 1: rv = MyAPI.runCommand(["df", mountpoint], output=True) if rv["Status"] == 0: try: diskspace = long(rv["Stdout"].split("\n")[1].split()[2]) except IndexError, e: errorflag = 1 except ValueError, e: errorflag = 1
def isDirMounted(mountpoint): mountflag = 0 errorflag = 0 lines = MyAPI.readFile("/proc/mounts", lines=True) for line in lines: tokens = line.split() if tokens[1] == mountpoint: mountflag = 1 if mountflag == 1: rv = MyAPI.runCommand(["df", mountpoint], output=True) if rv["Status"] == 0: try: diskspace = long(rv["Stdout"].split("\n")[1].split()[2]) except IndexError, e: errorflag=1 except ValueError, e: errorflag=1