def sset(self, oid, data_type, value): req = self._create_request(SNMP_MSG_SET) oid = mkoid(oid) converter = CONVERTER_MAP[data_type] data, size = converter(value) lib.snmp_pdu_add_variable(req, oid, len(oid), data_type, data, size) response = netsnmp_pdu_p() if lib.snmp_synch_response(self.sess, req, byref(response)) == 0: _raise_on_protocol_error(response) result = dict(getResult(response.contents)) lib.snmp_free_pdu(response) return result else: _raise_on_error(self.sess.contents.s_snmp_errno)
def sset(self, varbinds): """:type varbinds: list[PDUVarbinds]""" req = self._create_request(SNMP_MSG_SET) for varbind in varbinds: oid = mkoid(varbind.oid) converter = CONVERTER_MAP[varbind.type] data, size = converter(varbind.value) lib.snmp_pdu_add_variable(req, oid, len(oid), varbind.type, data, size) response = netsnmp_pdu_p() if lib.snmp_synch_response(self.sess, req, byref(response)) == 0: _raise_on_protocol_error(response) result = dict(getResult(response.contents, self._log)) lib.snmp_free_pdu(response) return result else: _raise_on_error(self.sess.contents.s_snmp_errno)