def directIOAllowed():
	FILE_OPEN = "modules.txt"
	SECTION = "/sbin/modinfo sg"
	CONTENT = []
	if Core.getExactSection(FILE_OPEN, SECTION, CONTENT):
		for LINE in CONTENT:
			if "/allow_dio=0" in LINE:
				return True
	return False
예제 #2
0
def getConfigFiles():
	"""
	Stores the non-XML Xen configuration files in list of dictionaries

	Args: None
	Returns: List of Dictionaries

	Example:
	Pending
	"""
	CONFIG_FILES = []
	CONFIG_FILE_LIST = []
	SECTION_LIST = {}
	MultiLine = re.compile("=\s*\[") # A line that has an =[ k
	IN_MULTI_LINE = False
	VALUES = []
	if Core.listSections("xen.txt", SECTION_LIST):
		for LINE in SECTION_LIST:
			if SECTION_LIST[LINE].startswith("/etc/xen/vm/"):
				if '.xml' not in SECTION_LIST[LINE]:
					CONFIG_FILE_LIST.append(SECTION_LIST[LINE])
		for CONFIG in CONFIG_FILE_LIST:
			#print "----------------------\nGetting", CONFIG
			CONTENT = []
			if Core.getExactSection("xen.txt", CONFIG, CONTENT):
				CONFIG_VALUES = {}
				for LINE in CONTENT:
					LINE = LINE.strip()
					if( IN_MULTI_LINE ):
						if LINE.endswith("]"):
							VALUES.append(LINE)
							VALUE_STRING = ' '.join(VALUES)
							TMP = VALUE_STRING.split("=", 1)
							#print "TMP", TMP
							CONFIG_VALUES[TMP[0].strip()] = TMP[1].strip('"').strip()
							#print "  CONFIG_VALUES", CONFIG_VALUES
							IN_MULTI_LINE = False
							VALUES = [] #prepare for new multiline value in config file
						else:
							VALUES.append(LINE)
					elif( MultiLine.search(LINE) and not LINE.endswith("]")):
						IN_MULTI_LINE = True
						VALUES.append(LINE)
					else: #assume single line entry
						TMP = LINE.split("=", 1)
						#print "TMP", TMP, "Length", len(TMP)
						if( len(TMP) != 2 ): #Invalid entry, assume the config file is invalid and ignore it.
							#print " Invalid config file"
							CONFIG_VALUES = {}
							break
						elif( "=" in TMP[1] and "]" not in TMP[1] ):
							#print " Invalid config file"
							CONFIG_VALUES = {}
							break
						else:
							CONFIG_VALUES[TMP[0].strip()] = TMP[1].strip('"').strip()
				#print "  CONFIG_VALUES", CONFIG_VALUES
				if( CONFIG_VALUES):
					CONFIG_FILES.append(CONFIG_VALUES)

		#if( CONFIG_FILES ):
			#print "======\n"
			#for I in range(len(CONFIG_FILES)):
				#print I, "==", CONFIG_FILES[I], "\n"
		#else:
			#print "CONFIG_FILES empty"

	return CONFIG_FILES