Пример #1
0
 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
 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
 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
    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