def set_name(self, slot, unit, name): from netsnmp import VarList, Varbind, Session try: name = name[:16] session = Session(Version=2, DestHost=self._ip, Community=SC['snmp']['write_community'], UseNumeric=1, Timeout=100000, Retries=2) setobj = VarList( Varbind("enterprises", "10418.17.2.5.5.1.4.1.{}.{}".format(slot, unit), name, "OPAQUE")) session.set(setobj) return "{0}.{1}:'{2}'".format(slot, unit, name) except Exception as exception_error: self.log_msg("Avocent : error setting name " + str(exception_error)) return "Error setting name '%s'" % (name)
def set_state(self, slot, unit, state): from netsnmp import VarList, Varbind, Session try: session = Session(Version=2, DestHost=self._ip, Community=SC['snmp']['write_community'], UseNumeric=1, Timeout=100000, Retries=2) setobj = VarList( Varbind("enterprises", "10418.17.2.5.5.1.6.1.{}.{}".format(slot, unit), Device.set_outlet_state(state), "INTEGER")) session.set(setobj) self.log_msg("Avocent : {0} set state to {1} on {2}.{3}".format( self._ip, state, slot, unit)) return {'res': 'OK'} except Exception as exception_error: self.log_msg("Avocent : error setting state " + str(exception_error)) return {'res': 'NOT_OK', 'info': str(exception_error)}