예제 #1
0
파일: SNMP.py 프로젝트: wildone/pycopia
 def _get_request_message(self):
     comm = self.sessiondata.get_community(RO)
     if not comm: # then try to use a RW community if no RO community
         comm = self.sessiondata.get_community(RW)
         if not comm:
             raise SNMPBadCommunity("No community strings!")
     return CommunityBasedMessage(comm, GetRequestPDU(), self.sessiondata.version )
예제 #2
0
파일: SNMP.py 프로젝트: tijmengit/pycopia
 def getbulk(self, bulkpdu):
     comm = self.sessiondata.get_community(RO)
     if not comm:  # then try to use a RW community if no RO community
         comm = self.sessiondata.get_community(RW)
         if not comm:
             raise SNMPBadCommunity("No community!")
     mo = CommunityBasedMessage(comm, bulkpdu, self.sessiondata.version)
     resp = self._send_and_receive(mo)
     if resp.pdu.error_status:
         raise EXCEPTION_MAP[resp.pdu.error_status](resp.pdu.error_index)
     else:
         return resp.pdu.varbinds
예제 #3
0
파일: SNMP.py 프로젝트: wildone/pycopia
 def getnext(self, *oids):
     comm = self.sessiondata.get_community(RO)
     if not comm: # then try to use a RW community if no RO community
         comm = self.sessiondata.get_community(RW)
         if not comm:
             raise SNMPBadCommunity("No community!")
     mo = CommunityBasedMessage(comm, GetNextRequestPDU(), self.sessiondata.version  )
     for oid in oids:
         mo.add_oid(oid)
     resp = self._send_and_receive(mo)
     if resp.pdu.error_status:
         raise EXCEPTION_MAP[resp.pdu.error_status](resp.pdu.error_index)
     else:
         return resp.pdu.varbinds
예제 #4
0
파일: SNMP.py 프로젝트: wildone/pycopia
    def set(self, varbindlist):
        """
set(varbindlist)
Where varbindlist is a VarBindList containing VarBind objects.

        """
        comm = self.sessiondata.get_community(RW)
        if not comm:
            raise SNMPBadCommunity("No community!")
        mo = CommunityBasedMessage(comm, SetRequestPDU() , self.sessiondata.version )
        for vb in varbindlist:
            mo.add_varbind(vb)
        resp = self._send_and_receive(mo)
        if resp.pdu.error_status:
            raise EXCEPTION_MAP[resp.pdu.error_status](resp.pdu.error_index)
        else:
            return resp.pdu.varbinds