コード例 #1
0
ファイル: _3com.py プロジェクト: soukudom/bachelor_project
 def getDeviceName(self,protocol):
     value = ["sysDescr"]
     obj = SNMP(protocol)
     try:
         conn = obj.connect()
     except Exception as e:
         #can not connect
         print("SNMP device module: can not connect to device")
         return None
     try:
         manufactor = obj.doCommand(value)
     except Exception as e:
         #can not do command
         print("SNMP device module: can not do command")
         return None
     manufactor = manufactor.split()
     #find version
     for pos,i in enumerate(manufactor,start=0):
         if str(i).lower() == "software":
             return ["_3com","_3com"+str(manufactor[pos-2])]
コード例 #2
0
ファイル: cisco.py プロジェクト: soukudom/bachelor_project
    def getDeviceName(self, protocol):
        value = ["sysDescr"]
        obj = SNMP(protocol)
        try:
            conn = obj.connect()
        except Exception as e:
            #can not connect
            print("SNMP device module: can not connect to device")
            return None
        try:
            manufactor = obj.doCommand(value)
        except Exception as e:
            #can not do command
            print("SNMP device module: can not do command")
            return None

        manufactor = manufactor.split()
        #find version
        for pos, i in enumerate(manufactor, start=0):
            if re.match("C[0-9][0-9][0-9][0-9]", i):
                return ["cisco", "cisco" + str(i)]