diff options
author | elie <elie> | 2007-02-19 08:24:10 +0000 |
---|---|---|
committer | elie <elie> | 2007-02-19 08:24:10 +0000 |
commit | 146d1e6bdfd19adf425a9240cf707e2a2fefbfa9 (patch) | |
tree | a7a36fbb59a08e1b71e5147a6a03ec545458bee2 | |
parent | e3f87c669832b1a7776c7f693a17d7b3d536fbe1 (diff) | |
download | pysnmp-146d1e6bdfd19adf425a9240cf707e2a2fefbfa9.tar.gz |
SnmpEngineID default value generation algorithmic function changedrelease_4_1_7_a_tag
to allow multiple SNMP engines running on the same host.
-rw-r--r-- | pysnmp/smi/mibs/SNMP-FRAMEWORK-MIB.py | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/pysnmp/smi/mibs/SNMP-FRAMEWORK-MIB.py b/pysnmp/smi/mibs/SNMP-FRAMEWORK-MIB.py index ffb3dde..a386d5c 100644 --- a/pysnmp/smi/mibs/SNMP-FRAMEWORK-MIB.py +++ b/pysnmp/smi/mibs/SNMP-FRAMEWORK-MIB.py @@ -4,6 +4,7 @@ try: import socket + import os except ImportError: pass import string @@ -29,14 +30,18 @@ class SnmpEngineID(OctetString, TextualConvention): subtypeSpec = OctetString.subtypeSpec+constraint.ValueSizeConstraint(5,32) try: # Attempt to base engine ID on local IP address - defaultValue = '\x80\x00\x4f\xb8' + '\x01' + string.join( + defaultValue = '\x80\x00\x4f\xb8' + '\x05' + string.join( map(lambda x: chr(int(x)), string.split(socket.gethostbyname(socket.gethostname()),'.')), '' - ) + ) + chr(os.getpid() >> 8) + chr(os.getpid() & 0xff) except: # ...otherwise, use rudimentary text ID - defaultValue = '\x80\x00\x4f\xb8' + '\x04' + 'mozhinka' + defaultValue = '\x80\x00\x4f\xb8' + '\x05' + t = int(time.time()) + while t: + defaultValue = defaultValue + chr(t & 0xff) + t = t >> 8 class SnmpEngineTime(Integer32): def clone(self, value=None, tagSet=None, subtypeSpec=None): |