Exemple #1
0
def get_mpn_card(ip,oid,givenLembda,givenLembdaDir):
    for rack in range(1,Constants.MAX_RACKS+1):
        for subRack in range(1,Constants.MAX_SUBRACKS+1):
            tmpOid=oid+'.'+str(rack)+'.'+str(subRack)+'.0.0.0'
            api=snmpApi.SNMP(Constants.TIMEOUT,Constants.RETRIES)
            retStr,ErrorState=api.snmp_get(GlobalVars.gneIP1,tmpOid) 
            #print("givenLembda:%d %d"%(givenLembda,givenLembdaDir))
            if len(retStr)<=2 or ErrorState==Constants.GET_REQUEST_FAILED:
                print("Error!!!!!")
                return Constants.DEFAULT_LIST,Constants.GET_REQUEST_FAILED;
 
            else: 
                tpnCardDetail=[]
                print(str(retStr))            
                tpnConf=str(retStr).split("$")
                lst=tpnConf[1].split("#")
        
                for subLst in lst:
                    tpnInfo=subLst.split("-")
                    #print("tpnInfo[6]=%d %d"%(int(tpnInfo[6]),int(tpnInfo[5])))
                    if int(tpnInfo[6])==int(givenLembda) and int(tpnInfo[5])==int(givenLembdaDir):
                        tpnCardDetail.insert(0,rack)
                        tpnCardDetail.insert(1,subRack)
                        tpnCardDetail.insert(2,tpnInfo[0])
                        tpnCardDetail.insert(3,tpnInfo[1])
                        tpnCardDetail.insert(4,tpnInfo[2])
                        print(tpnCardDetail)
                        break
                print(tpnCardDetail)
                return tpnCardDetail,Constants.TPN_CARD_DETAIL_NOT_FOUND;
Exemple #2
0
def get_pa_ba_info(currNodeIp,givenLembdaDir,amplifierType):
    cardType=Constants.AMPLIFER[0]
    cardSubType=Constants.AMPLIFER[1]
    if GlobalVars.gneIP2subStr not in currNodeIp:
        ip=GlobalVars.iP2ToiP1Mapping.get(currNodeIp)[1]
    else:
        ip=currNodeIp
            
    endIP,ErrorState=get_end_ip(currNodeIp)
    if ip in GlobalVars.cardDetailsDict:
        if str(cardType) in GlobalVars.cardDetailsDict.get(ip):
            if str(cardSubType) in GlobalVars.cardDetailsDict.get(ip).get(str(cardType)):
                cardInfo=GlobalVars.cardDetailsDict.get(ip).get(str(cardType)).get(str(cardSubType))
                for info in cardInfo:
                    rack=info[0]
                    subRack=info[1]
                    slot=info[2]
                    api=snmpApi.SNMP(Constants.TIMEOUT,Constants.RETRIES)
                    retStr,ErrorState=api.snmp_get(GlobalVars.gneIP1,GlobalVars.AMPLIFIER_INFO_OID+'.'+str(endIP)+'.24.1.7.'+str(rack)+'.'+str(subRack)+'.'+str(slot)+'.'+str(cardType)+'.'+str(cardSubType)+'.'+str(amplifierType)) 
                    if not retStr:
                        print("Error!!!!!")
                        continue
 
                    else: 
                        print("PA/BA info=%s"%str(retStr))
                        amplfierInfo=str(retStr).split("#")
                        if int(amplfierInfo[3])==int(givenLembdaDir):
                            print("PA/BA card info for Given Lembda=%s"%str(retStr))
            else:
                print("Card Sub Type %d Not Found.."%int(cardSubType))                 
        else:
            print("Card Type %d Not Found.."%int(cardType))                    
    else:
        print("Card info dictionary in EMPTY!!!")       
Exemple #3
0
def get_system_info(ip,oid):
    api=snmpApi.SNMP(Constants.TIMEOUT,Constants.RETRIES)
    retStr,ErrorState=api.snmp_get(ip,oid) 
    if not retStr:
        print("Error!!!!!")
        return Constants.GET_REQUEST_FAILED;
 
    else: 
        return retStr;
Exemple #4
0
def get_mpn_sfp_status(mpnCard,endIP):
    oid=GlobalVars.CM_OID+str(endIP)+'.17.1.8.'+str(mpnCard[0])+'.'+str(mpnCard[1])+'.'+str(mpnCard[2])+'.'+str(mpnCard[3])+'.'+str(mpnCard[4])+'.1.0'
   
    api=snmpApi.SNMP(Constants.TIMEOUT,Constants.RETRIES)
    retStr,ErrorState=api.snmp_get(GlobalVars.gneIP1,oid) 
   
    if ErrorState ==Constants.GET_REQUEST_FAILED:
        print("Error!!!!!")
        return Constants.UNABLE_TO_GET_SUBAGENTINFO;
    else:
        print("MPN sfp status Received..")
        print("SFP STATUS=%s"%str(retStr))
Exemple #5
0
def get_mpn_tx_power(mpnCard,endIP):
    oid=GlobalVars.PM_OID+str(endIP)+'.8.1.9.'+str(mpnCard[0])+'.'+str(mpnCard[1])+'.'+str(mpnCard[2])+'.'+str(mpnCard[3])+'.'+str(mpnCard[4])+'.1.3.1'
    
    trapOid=GlobalVars.PM_TRAP_OID+str(endIP)+'.5.5.1.9.'+str(mpnCard[0])+'.'+str(mpnCard[1])+'.'+str(mpnCard[2])+'.'+str(mpnCard[3])+'.'+str(mpnCard[4])+'.1.3.1'
    if trapOid not in GlobalVars.TRAP_OID:
        GlobalVars.TRAP_OID[str(trapOid)]=1
        
    api=snmpApi.SNMP(Constants.TIMEOUT,Constants.RETRIES)
    retStr,ErrorState=api.snmp_get(GlobalVars.gneIP1,oid) 
    #print(trapOid)
    if ErrorState ==Constants.GET_REQUEST_FAILED:
        print("Error!!!!!")
        return Constants.UNABLE_TO_GET_SUBAGENTINFO;
    else:
        print("Response will be a trap..")
Exemple #6
0
def get_wss_current_configuration(ip,oid,givenLembda):
    print("Get WSS Current Configuration")
    api=snmpApi.SNMP(Constants.TIMEOUT,Constants.RETRIES)
    retStr,ErrorState=api.snmp_get(GlobalVars.gneIP1,oid) 
    if not retStr:
        print("Error!!!!!")
        return Constants.DEFAULT;
 
    else: 
        print(str(retStr))   
        info=str(retStr).split("#")
        if(len(info)>2):
            subInfo=info[9+int(givenLembda)-1].split("$")
            if(len(subInfo)>2):
                print("Attenuation=%f,ChannelPower=%f,Action=%d"%(float(subInfo[0]),float(subInfo[1]),int(subInfo[2])))
Exemple #7
0
def get_wss_channle_configuration(ip,oid,givenLembda):
    print("Get WSS channle Configuration for wavelength %d"%givenLembda)
    api=snmpApi.SNMP(Constants.TIMEOUT,Constants.RETRIES)
    retStr,ErrorState=api.snmp_get(GlobalVars.gneIP1,oid) 
    if not retStr:
        print("Error!!!!!")
        return Constants.DEFAULT;
 
    else: 
        wssTxDir=0  
        info=str(retStr).split("$")
        subInfo=info[1].split("#")
        
        for subSubInfo in subInfo:
            print(subSubInfo)
            channleInfo=subSubInfo.split("-")
            if channleInfo[0]==str(givenLembda):
                wssTxDir=channleInfo[1]
                break
        
        print(str(retStr))  
               
        return int(wssTxDir);  
Exemple #8
0
def get_wss_direction_configuration(ip,oid,givenLembdaDir):
    print("Get WSS Direction Configuration")
    api=snmpApi.SNMP(Constants.TIMEOUT,Constants.RETRIES)
    retStr,ErrorState=api.snmp_get(GlobalVars.gneIP1,oid) 
    print("WSSgivenLembdaDir:%s"%givenLembdaDir)
    if not retStr:
        print("Error!!!!!")
        return Constants.DEFAULT_LIST,givenLembdaDir,Constants.EMPTY_WSS_DIR_CONFIG;
 
    else: 
       
        print(str(retStr))            
        lst=str(retStr).split("#")
        if lst[0]=='0':
            return Constants.DEFAULT_LIST,givenLembdaDir,Constants.EMPTY_WSS_DIR_CONFIG;
        cardDetailList=[]
        
        for subLst in lst[1:]:
            tmpDir=givenLembdaDir
            wssDirInfo=subLst.split("-")
            #Adding Direction Offset
            if (wssDirInfo[3]==str(Constants.WSS219[0]) and wssDirInfo[4]==str(Constants.WSS2120[1]) or wssDirInfo[3]==str(Constants.WSS2120[0]) and wssDirInfo[4]==str(Constants.WSS2120[1])) and int(tmpDir)<Constants.WSS219[2]:
                tmpDir=int(givenLembdaDir)+Constants.WSS219[2]
            elif wssDirInfo[3]==str(Constants.WSS19[0]) and wssDirInfo[4]==str(Constants.WSS19[1]) and int(tmpDir)<Constants.WSS19[2]:    
                tmpDir=int(givenLembdaDir)+Constants.WSS19[2]
                
            if int(wssDirInfo[5])==tmpDir:
                cardDetailList.insert(0,wssDirInfo[0])
                cardDetailList.insert(1,wssDirInfo[1])
                cardDetailList.insert(2,wssDirInfo[2])
                cardDetailList.insert(3,wssDirInfo[3])
                cardDetailList.insert(4,wssDirInfo[4])
                print("CardList:%s"%cardDetailList)
                return cardDetailList,tmpDir,Constants.NO_ERROR;
            
        
        return cardDetailList,givenLembdaDir,Constants.GIVEN_DIR_CARD_UNAVAILABLE;
Exemple #9
0
def card_info(currNodeIp1,oid,rack,subRack):
    
    api=snmpApi.SNMP(Constants.TIMEOUT,Constants.RETRIES)
    retStr,ErrorState=api.snmp_get(GlobalVars.gneIP1,oid) 
    if not retStr:
        #print("Error!!!!!")
        return Constants.DEFAULT;
    
    else: 
        #ControllerCardStatus1-State1-IP1-MAC1-UUID1-SlotIndex1-CardType1-CardSubType1#ControllerCardStatus2-State2-IP2-MAC2-UUID2
        #-SlotIndex2-CardType2-CardSubType2$CardState1-SlotIndex1-CardType1-CarfdSubType1#Cardtate2-SlotIndex2-CardType2-CarfdSubType2#..#UP TO 12   
        #print("CardInfo=%s"%str(retStr)) 
        cards=str(retStr).split("$")
        controllerCards=cards[0].split("#")
        lineCards=cards[1].split("#")
        if GlobalVars.gneIP2subStr not in currNodeIp1:
            currNodeIp=GlobalVars.iP2ToiP1Mapping.get(currNodeIp1)[1]
        else:
            currNodeIp=currNodeIp1    
        #---Adding Controller Cards _START_
        for controllerCard in controllerCards:
            controllerCardInfo=controllerCard.split("-")
            slot=controllerCardInfo[5]
            cardType=controllerCardInfo[6]
            cardSubType=controllerCardInfo[7]
            state=controllerCardInfo[1]
            status=controllerCardInfo[0]
            if state == Constants.ACTIVE :
                tmpList=[int(rack),int(subRack),int(slot),int(state),int(status)]
                if currNodeIp not in GlobalVars.cardDetailsDict:
                    GlobalVars.cardDetailsDict[currNodeIp]={} 
                
                if cardType not in GlobalVars.cardDetailsDict.get(currNodeIp):
                    GlobalVars.cardDetailsDict.get(currNodeIp)[cardType]={}
                
                if cardSubType not in GlobalVars.cardDetailsDict.get(currNodeIp).get(cardType):
                    GlobalVars.cardDetailsDict.get(currNodeIp).get(cardType)[cardSubType]=[]             
            
                GlobalVars.cardDetailsDict.get(currNodeIp).get(cardType).setdefault(cardSubType,[]).append(tmpList)     
        #print("ffff %s"%GlobalVars.cardDetailsDict)
        #---Adding Controller Cards _END_
        
        #---Adding Line Cards _START_
        for lineCard in lineCards:
            lineCardInfo=lineCard.split("-")
            slot=lineCardInfo[1]
            cardType=lineCardInfo[2]
            cardSubType=lineCardInfo[3]
            state=lineCardInfo[0]
            status=0
            if state == Constants.READY :
                tmpList=[int(rack),int(subRack),int(slot),int(state),int(status)]
                if currNodeIp not in GlobalVars.cardDetailsDict:
                    GlobalVars.cardDetailsDict[currNodeIp]={} 
                
                if cardType not in GlobalVars.cardDetailsDict.get(currNodeIp):
                    GlobalVars.cardDetailsDict.get(currNodeIp)[cardType]={}
                
                if cardSubType not in GlobalVars.cardDetailsDict.get(currNodeIp).get(cardType):
                    GlobalVars.cardDetailsDict.get(currNodeIp).get(cardType)[cardSubType]=[]             
            
                GlobalVars.cardDetailsDict.get(currNodeIp).get(cardType).setdefault(cardSubType,[]).append(tmpList)