Exemplo n.º 1
0
def getVolumeState():
    global stat
    sessionid = SANtricityStorage.login(loginUrl, username, password)
    logger.debug("Inside getvolumestate")
    SANtricityStorage.getStorageSystemDetails(urlToServer, sessionid,
                                              SANtricityStorage.getTime())
    file = SANtricityStorage.getStoragePath() + "/controller.csv"
    fileForRead = open(file, "rb")
    csvReader = csv.reader(fileForRead, delimiter=",")
    firstLine = True
    controllername = {}
    controllerdetails = {}
    for row in csvReader:
        if firstLine:
            headerList = row
            firstLine = False
        else:
            if (hostipaddress and row[headerList.index("ip1")] == hostipaddress
                    or row[headerList.index("ip2")]
                    == hostipaddress) or hostipaddress == "":
                controllername[row[headerList.index("arrayId")] + "~" + row[headerList.index("controllerRef")]] = "\nArray Name:" + \
                    row[headerList.index("arrayName")] + ",Controller Name:" + row[headerList.index("controllerLabel")] + "\n"
                controllerdetails[row[headerList.index(
                    "controllerRef")]] = row[headerList.index(
                        "controllerLabel")]
    if len(controllername) == 0:
        strResult = "Unknown-  Host ip address not configured in web proxy."
        global stat
        stat = 3
        return strResult
    file = SANtricityStorage.getStoragePath() + "/VolumeGroup.csv"
    fileForRead = open(file, "rb")
    csvReader = csv.reader(fileForRead, delimiter=",")
    firstLine = True
    currentArrayId = ""
    controllerId = []

    arrayInfo = {}
    strResultData = ""
    strResultPerData = ""
    lstResult = []
    volumegroupName = {}
    for row in csvReader:
        if firstLine:
            headerList = row
            firstLine = False
        else:
            if hostipaddress and (row[headerList.index("ip1")] == hostipaddress
                                  or row[headerList.index("ip2")]
                                  == hostipaddress):
                controllerId.append(row[headerList.index("volumeGroupRef")])
                volumegroupName[row[headerList.index("volumeGroupRef")]] = row[
                    headerList.index("volumeGroup")]
                arrayId = row[headerList.index("arrayId")]
                arrayInfo[arrayId] = {
                    "arrayName": row[headerList.index("arrayName")],
                    "volumeGroup": volumegroupName
                }

            elif hostipaddress == "":

                arrayId = row[headerList.index("arrayId")]
                arrayInfo[arrayId] = {
                    "arrayName": row[headerList.index("arrayName")],
                    "volumeGroup": volumegroupName
                }
                if currentArrayId <> arrayId and len(controllerId) <> 0:
                    (arrayInfo[currentArrayId]
                     )["volumeGroup"] = volumegroupName
                    lstResult.append(
                        getVolumeInfo(currentArrayId, controllerId, sessionid,
                                      arrayInfo, controllername,
                                      controllerdetails))

                    controllerId = []
                    volumegroupName = {}
                    controllerId.append(
                        row[headerList.index("volumeGroupRef")])
                    volumegroupName[row[headerList.index(
                        "volumeGroupRef")]] = row[headerList.index(
                            "volumeGroup")]
                elif currentArrayId <> arrayId:
                    controllerId = []
                    volumegroupName = {}
                    controllerId.append(
                        row[headerList.index("volumeGroupRef")])
                    volumegroupName[row[headerList.index(
                        "volumeGroupRef")]] = row[headerList.index(
                            "volumeGroup")]
                else:
                    controllerId.append(
                        row[headerList.index("volumeGroupRef")])
                    volumegroupName[row[headerList.index(
                        "volumeGroupRef")]] = row[headerList.index(
                            "volumeGroup")]
                currentArrayId = arrayId
    if arrayId:
        (arrayInfo[arrayId])["volumeGroup"] = volumegroupName

        lstResult.append(
            getVolumeInfo(arrayId, controllerId, sessionid, arrayInfo,
                          controllername, controllerdetails))
        firstPerData = ""
        firstLine = True
        for listEle in lstResult:
            strResultData += listEle["strOutPut"]
            if firstLine:
                firstPerData = listEle["strPerData"]

                firstspace = firstPerData.index(" ")
                strResultPerData += firstPerData[firstspace + 1:] + " "
                firstPerData = firstPerData[0:firstPerData.index(" ")]

                firstLine = False
            else:
                strResultPerData += listEle["strPerData"]

        strResultPerData = strResultPerData.strip()
        strResultData = "Array Name : " + arrayInfo[arrayId][
            "arrayName"] + strResultData
        if stat == 0:
            strResult = "OK - Volume cache statistics fetched.|" + firstPerData + "\n" + strResultData + "|" + strResultPerData
        elif stat == 1:
            strResult = "Warning- Some volume  are functioning at threshold values.|" + firstPerData + "\n" + strResultData + "|" + strResultPerData
        elif stat == 2:
            strResult = "Critical- Some volume  are out side threshold values.|" + firstPerData + "\n" + strResultData + "|" + strResultPerData
    else:
        strResult = "Unknown -  Host ip address not configured in web proxy."

        stat = 3
    fileForRead.close()
    return strResult
def getphysicalcomptstatus():
    global stat
    sessionid = SANtricityStorage.login(loginUrl, username, password)
    SANtricityStorage.getStorageSystemDetails(urlToServer, sessionid,
                                              SANtricityStorage.getTime())
    file = SANtricityStorage.getStoragePath() + "/controller.csv"
    fileforread = open(file, "rb")
    csvreader = csv.reader(fileforread, delimiter=",")
    firstline = True
    currentarrayid = ""
    arrayinfo = {}
    strresultdata = ""
    strresultperdata = ""
    lstresult = []
    firstarray = True
    controllername = {}
    contcount = 0
    arrayId = ""
    for row in csvreader:
        if firstline:
            headerList = row
            firstline = False
        else:
            if hostipaddress and (row[headerList.index("ip1")] == hostipaddress
                                  or row[headerList.index("ip2")]
                                  == hostipaddress):
                arrayId = row[headerList.index("arrayId")]
                arrayinfo[arrayId] = {
                    "arrayName": row[headerList.index("arrayName")]
                }
                controllername[row[headerList.index("controllerRef")]] = row[
                    headerList.index("controllerLabel")]
                contcount += 1
                if contcount == 2:
                    break
            elif hostipaddress == "":

                arrayId = row[headerList.index("arrayId")]
                arrayinfo[arrayId] = {
                    "arrayName": row[headerList.index("arrayName")]
                }
                if currentarrayid <> arrayId and firstarray == False:

                    lstresult.append(
                        get_phy_comp_stat_by_array(currentarrayid, sessionid,
                                                   arrayinfo, controllername))
                    controllername = {}
                    controllername[row[headerList.index(
                        "controllerRef")]] = row[headerList.index(
                            "controllerLabel")]

                else:
                    firstarray = False

                currentarrayid = arrayId
    if arrayId:

        lstresult.append(
            get_phy_comp_stat_by_array(arrayId, sessionid, arrayinfo,
                                       controllername))
        firstPerData = ""
        firstline = True

        for listEle in lstresult:
            strresultdata += listEle["strOutPut"]
            if firstline:
                firstPerData = listEle["strPerfData"]
                strArry = firstPerData.split(" ")
                if " " in firstPerData:
                    firstspace = firstPerData.index(" ")
                    strresultperdata += firstPerData[firstspace + 1:] + " "
                    firstPerData = firstPerData[0:firstPerData.index(" ")]

                firstline = False
            else:
                strresultperdata += listEle["strPerData"]

        # strResultPerData = strResultPerData.strip()

        if stat == 0:
            strResult = "OK - All " + msglist[
                mode] + " are in optimal stat.|" + firstPerData + "\n" + strresultdata + "|" + strresultperdata
        elif stat == 1 and (mode == '' or mode == 'ARRY'):
            strResult = "Warning - Array is in need attention stat|" + firstPerData + "\n" + strresultdata + "|" + strresultperdata
        elif stat == 1 and mode != "" and mode != 'ARRY':
            strResult = "OK - All " + msglist[
                mode] + " are in optimal stat.|" + firstPerData + "\n" + strresultdata + "|" + strresultperdata
        elif stat == 2:
            strResult = "Critical - Some physical components are down.|" + firstPerData + "\n" + strresultdata + "|" + strresultperdata
        elif stat == 3:
            strResult = "STATUS UNKNOWN - Physical component not found" + strresultdata
    else:
        strResult = "Unknown -  Host ip address is not configured in web proxy."
        stat = 3
    fileforread.close()
    return strResult
def getVolumeState():
    global stat
    sessionId = SANtricityStorage.login(loginUrl,username,password)
    logger.debug("In getVolume State method")
    SANtricityStorage.getStorageSystemDetails(urlToServer, sessionId, SANtricityStorage.getTime())

    file = SANtricityStorage.getStoragePath() + "/controller.csv"
    fileForRead = open(file, "rb")
    csvReader = csv.reader(fileForRead, delimiter=",")
    firstLine = True
    currentArrayId = ""
    controllerId = []
    arrayInfo = {}
    strResultData = ""
    strResultPerData = ""
    lstResult = []
    controllerName = {}
    arrayId = ""
    for row in csvReader:
        if firstLine:
            headerList = row
            firstLine = False
        else:
            if hostipaddress and (
                    row[headerList.index("ip1")] == hostipaddress or row[headerList.index("ip2")] == hostipaddress):
                controllerId.append(row[headerList.index("controllerRef")])
                controllerName[row[headerList.index("controllerRef")]] = row[headerList.index("controllerLabel")]
                arrayId = row[headerList.index("arrayId")]
                arrayInfo[arrayId] = {"arrayName": row[headerList.index("arrayName")],
                                      "controllerLabel": controllerName}

            elif hostipaddress == "":

                arrayId = row[headerList.index("arrayId")]
                arrayInfo[arrayId] = {"arrayName": row[headerList.index("arrayName")],
                                      "controllerLabel": controllerName}
                if currentArrayId <> arrayId and len(controllerId) <> 0:
                    (arrayInfo[currentArrayId])["controllerLabel"] = controllerName
                    lstResult.append(get_volume_info(currentArrayId, controllerId, sessionId, arrayInfo))
                    controllerId = []
                    controllerName = {}
                    controllerId.append(row[headerList.index("controllerRef")])
                    controllerName[row[headerList.index("controllerRef")]] = row[headerList.index("controllerLabel")]
                elif currentArrayId <> arrayId:
                    controllerId = []
                    controllerName = {}
                    controllerId.append(row[headerList.index("controllerRef")])
                    controllerName[row[headerList.index("controllerRef")]] = row[headerList.index("controllerLabel")]
                else:
                    controllerId.append(row[headerList.index("controllerRef")])
                    controllerName[row[headerList.index("controllerRef")]] = row[headerList.index("controllerLabel")]
                currentArrayId = arrayId
    if arrayId:
        (arrayInfo[arrayId])["controllerLabel"] = controllerName

        lstResult.append(get_volume_info(arrayId, controllerId, sessionId, arrayInfo))
        firstPerData = ""
        firstLine = True
        for listEle in lstResult:
            strResultData += listEle["strOutPut"]
            if firstLine:
                firstPerData = listEle["strPerData"]
                strArry = firstPerData.split(" ")
                firstPerData = strArry[0]
                strResultPerData += strArry[1] + " "
                firstLine = False
            else:
                strResultPerData += listEle["strPerData"]

        strResultPerData = strResultPerData.strip()

        strResultData = "\nThreshold Values - Range Selector : "+range +", Warning : " + str(low) + ", Critical : " \
                        + str(high)+"\nVolume Statistics by Controller\nTotal : "+str(total)+", OK : "+\
                        str(total -(warningdrive +criticaldrive))+", Warning : "+str(warningdrive)+\
                        ", Critical : "+str(criticaldrive) + strResultData


        if stat == 0:
            strResult = "OK - All controllers are within defined threshold.|" + firstPerData + "\n" + strResultData + "|" + strResultPerData
        elif stat == 1:
            strResult = "Warning - Some controllers are functioning at threshold values.|" + firstPerData + "\n" + strResultData + "|" + strResultPerData
        elif stat == 2:
            strResult = "Critical - Some controllers are out side threshold values.|" + firstPerData + "\n" + strResultData + "|" + strResultPerData

    else:

        stat = 3
        strResult = "Unknown - Host Ip is not configured with web proxy"

    fileForRead.close()
    return strResult
Exemplo n.º 4
0
def getVolumeState():
    global stat
    sessionid = SANtricityStorage.login(loginUrl, username, password)

    SANtricityStorage.getStorageSystemDetails(urlToServer, sessionid,
                                              SANtricityStorage.getTime())
    file = SANtricityStorage.getStoragePath() + "/controller.csv"
    fileForRead = open(file, "rb")
    csvReader = csv.reader(fileForRead, delimiter=",")
    firstLine = True
    controllername = {}
    controllerDetails = {}
    for row in csvReader:
        if firstLine:
            headerList = row
            firstLine = False
        else:
            if (hostipaddress and row[headerList.index("ip1")] == hostipaddress
                    or row[headerList.index("ip2")]
                    == hostipaddress) or hostipaddress == "":
                controllername[
                    row[headerList.index("arrayId")] + "~" +
                    row[headerList.index(
                        "controllerRef")]] = "\nArray Name : " + row[
                            headerList.index(
                                "arrayName")] + ", Controller Name : " + row[
                                    headerList.index("controllerLabel")] + "\n"
                controllerDetails[row[headerList.index(
                    "controllerRef")]] = row[headerList.index(
                        "controllerLabel")]
    file = SANtricityStorage.getStoragePath() + "/VolumeGroup.csv"
    fileForRead = open(file, "rb")
    csvReader = csv.reader(fileForRead, delimiter=",")
    firstLine = True
    currentArrayId = ""
    controllerId = []

    arrayInfo = {}
    strresultdata = ""
    strResultPerData = ""
    lstResult = []
    volumegroupname = {}
    arrayId = ""
    for row in csvReader:
        if firstLine:
            headerList = row
            firstLine = False
        else:
            if hostipaddress and (row[headerList.index("ip1")] == hostipaddress
                                  or row[headerList.index("ip2")]
                                  == hostipaddress):
                controllerId.append(row[headerList.index("volumeGroupRef")])
                volumegroupname[row[headerList.index("volumeGroupRef")]] = row[
                    headerList.index("volumeGroup")]
                arrayId = row[headerList.index("arrayId")]
                arrayInfo[arrayId] = {
                    "arrayName": row[headerList.index("arrayName")],
                    "volumeGroup": volumegroupname
                }

            elif hostipaddress == "":

                arrayId = row[headerList.index("arrayId")]
                arrayInfo[arrayId] = {
                    "arrayName": row[headerList.index("arrayName")],
                    "volumeGroup": volumegroupname
                }
                if currentArrayId <> arrayId and len(controllerId) <> 0:
                    (arrayInfo[arrayId])["volumeGroup"] = volumegroupname
                    lstResult.append(
                        getVolumeInfo(currentArrayId, controllerId, sessionid,
                                      arrayInfo, controllername,
                                      controllerDetails))
                    controllerId = []
                    volumegroupname = {}
                    controllerId.append(
                        row[headerList.index("volumeGroupRef")])
                    volumegroupname[row[headerList.index(
                        "volumeGroupRef")]] = row[headerList.index(
                            "volumeGroup")]
                elif currentArrayId <> arrayId:
                    controllerId = []
                    volumegroupname = {}
                    controllerId.append(
                        row[headerList.index("volumeGroupRef")])
                    volumegroupname[row[headerList.index(
                        "volumeGroupRef")]] = row[headerList.index(
                            "volumeGroup")]
                else:
                    controllerId.append(
                        row[headerList.index("volumeGroupRef")])
                    volumegroupname[row[headerList.index(
                        "volumeGroupRef")]] = row[headerList.index(
                            "volumeGroup")]
                currentArrayId = arrayId
    if arrayId:
        (arrayInfo[arrayId])["volumeGroup"] = volumegroupname

        lstResult.append(
            getVolumeInfo(arrayId, controllerId, sessionid, arrayInfo,
                          controllername, controllerDetails))
        firstPerData = ""
        firstLine = True
        for listEle in lstResult:
            strresultdata += listEle["strOutPut"]
            if firstLine:
                firstPerData = listEle["strPerData"]
                strArry = firstPerData.split(" ")
                firstspace = firstPerData.index(" ")
                strResultPerData += firstPerData[firstspace + 1:] + " "
                firstPerData = firstPerData[0:firstPerData.index(" ")]

                firstLine = False
            else:
                strResultPerData += listEle["strPerData"]

        strResultPerData = strResultPerData.strip()
        strresultdata = "\nThreshold Values - Range Selector : "+range +", Warning : " + str(low) + ", Critical : " \
                        + str(high)+"\n Volume Statistics By Volume Group\nTotal : "+str(total) +", Ok : "+ \
                        str(total - (warningdrive + criticaldrive))+", Warning : "+str(warningdrive)\
                        +", Critical : "+str(criticaldrive)+ strresultdata
        if stat == 0:
            strResult = "OK - All volume groups are within the defined threshold.|" + firstPerData + strresultdata + "|" + strResultPerData
        elif stat == 1:
            strResult = "Warning - Some volume groups are functioning at threshold values.|" + firstPerData + "\n" + strresultdata + "|" + strResultPerData
        elif stat == 2:
            strResult = "Critical - Some volume groups are out side threshold values.|" + firstPerData + "\n" + strresultdata + "|" + strResultPerData

    else:
        strResult = "Unknown -  Host ip address is not configured in web proxy."

        stat = 3
    fileForRead.close()
    return strResult
def getphysicalcomtemprature():
    global stat
    sessionid= SANtricityStorage.login(loginUrl,username,password)
    SANtricityStorage.getStorageSystemDetails(urlToServer,sessionid, SANtricityStorage.getTime())
    file = SANtricityStorage.getStoragePath() + "/controller.csv"
    fileforread=open(file,"rb")
    csvreader=csv.reader(fileforread,delimiter=",")
    firstline=True
    currentarrayid=""
    arrayinfo={}
    strresultdata=""
    strresultperdata=""
    lstresult=[]
    firstarray=True
    contcount=0
    arrayid =""
    for row in csvreader:
        if firstline:
             headerList=row
             firstline =False
        else:
            if hostipaddress and (row[headerList.index("ip1")] == hostipaddress or row[headerList.index("ip2")] == hostipaddress):
                arrayid=row[headerList.index("arrayId")]
                arrayinfo[arrayid]={"arrayName":row[headerList.index("arrayName")]}
                contcount+=1
                if contcount ==2:
                    break
            elif hostipaddress == "":
                arrayid=row[headerList.index("arrayId")]
                arrayinfo[arrayid]={"arrayName":row[headerList.index("arrayName")]}
                if currentarrayid <> arrayid and firstarray ==False:
                        lstresult.append(get_phy_comp_temprature(currentarrayid,sessionid,arrayinfo))
                else:
                     firstarray =False

                currentarrayid =arrayid
    if arrayid :
        lstresult.append(get_phy_comp_temprature(arrayid,sessionid,arrayinfo))
        firstPerData=""
        firstline =True

        for listEle in lstresult:
            strresultdata += listEle["strOutPut"]
            if firstline :
                firstPerData =listEle["strPerData"]
                strArry=firstPerData.split(" ")
                firstspace=firstPerData.index(" ")
                strresultperdata +=firstPerData[firstspace +1:] +" "
                firstPerData=firstPerData[0:firstPerData.index(" ")]

                firstline=False
            else:
                strresultperdata+= listEle["strPerData"]

        strresultperdata = strresultperdata.strip()
        strresultdata = "\nThreshold Values - Warning : " + str(warning) + ", Critical : "+str(critical) +strresultdata
        if stat ==0 :
           strResult = "OK -Temperature of all physical components is good |"+firstPerData +"\n"+strresultdata +"|"+strresultperdata
        elif stat ==1 :
           strResult = "Warning -Temperature of some physical components is above threshold level |"+firstPerData +"\n"+strresultdata +"|"+strresultperdata
        elif stat == 2:
            strResult="Critical- Temperature of some physical components is above critical threshold.|"+firstPerData +"\n"+strresultdata +"|"+strresultperdata
    else:
        strResult = "Unknown-  Host ip address is not configured in web proxy."

        stat=3
    fileforread.close()
    return strResult