def getControllers():
"""
Query the controllers available, and return this in a list.
Returns: List with available 3ware controllers (list).
"""
T = TRACE()
cmd = "sudo /usr/local/sbin/tw_cli info"
stat, out = commands.getstatusoutput(cmd)
if (stat):
raise Exception, "Error invoking 3ware Command Line Tool: " + str(out)
contList = []
for line in out.split("\n"):
line = line.strip()
if (line):
if (line.find("Controller") == 0):
# "Controller 1: 8506-4LP (4)"
contNo = line.split(" ")[1].split(":")[0]
contList.append(contNo)
elif (line[0] == "c"):
contNo = int(line.split(" ")[0][1:])
contList.append(contNo)
contList.sort()
return contList
评论列表
文章目录