Skip to content

Commit eb716b9

Browse files
committed
properly refer to MIB modules defining symbols rather than assuming current module
1 parent d15dc61 commit eb716b9

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

CHANGES.rst

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ Revision 0.1.3, XX-05-2017
55
* INET-ADDRESS-MIB configured as pre-built at pysnmp codegen
66
* JSON codegen produces "nodetype" element for OBJECT-TYPE
77
* Fix to mibdump.py --destination-directory option
8+
* Fix to pysnmp and JSON code generators to properly refer to MIB module
9+
defining particular MIB object
810

911
Revision 0.1.2, 12-04-2017
1012
--------------------------

pysmi/codegen/jsondoc.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ def genNotificationGroup(self, data):
331331
outDict['class'] = 'notificationgroup'
332332

333333
if objects:
334-
outDict['objects'] = [{'module': self.moduleName[0], 'object': self.transOpers(obj)} for obj in objects]
334+
outDict['objects'] = [{'module': self._importMap.get(obj, self.moduleName[0]), 'object': self.transOpers(obj)} for obj in objects]
335335

336336
if status:
337337
outDict['status'] = status
@@ -360,7 +360,7 @@ def genNotificationType(self, data):
360360
outDict['class'] = 'notificationtype'
361361

362362
if objects:
363-
outDict['objects'] = [{'module': self.moduleName[0], 'object': self.transOpers(obj)} for obj in objects]
363+
outDict['objects'] = [{'module': self._importMap.get(obj, self.moduleName[0]), 'object': self.transOpers(obj)} for obj in objects]
364364

365365
if status:
366366
outDict['status'] = status
@@ -388,7 +388,7 @@ def genObjectGroup(self, data):
388388
'class': 'objectgroup'})
389389

390390
if objects:
391-
outDict['objects'] = [{'module': self.moduleName[0], 'object': self.transOpers(obj)} for obj in objects]
391+
outDict['objects'] = [{'module': self._importMap.get(obj, self.moduleName[0]), 'object': self.transOpers(obj)} for obj in objects]
392392

393393
if status:
394394
outDict['status'] = status
@@ -501,7 +501,7 @@ def genTrapType(self, data):
501501
outDict['class'] = 'notificationtype'
502502

503503
if variables:
504-
outDict['objects'] = [{'module': self.moduleName[0], 'object': self.transOpers(obj)} for obj in variables]
504+
outDict['objects'] = [{'module': self._importMap.get(obj, self.moduleName[0]), 'object': self.transOpers(obj)} for obj in variables]
505505

506506
if self.genRules['text'] and description:
507507
outDict['description'] = description

pysmi/codegen/pysnmp.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ def genNotificationGroup(self, data, classmode=False):
387387
oidStr, parentOid = oid
388388

389389
if objects:
390-
objects = ['("' + self.moduleName[0] + '", "' + self.transOpers(obj) + '")' for obj in objects]
390+
objects = ['("' + self._importMap.get(obj, self.moduleName[0]) + '", "' + self.transOpers(obj) + '")' for obj in objects]
391391

392392
objStr = ', '.join(objects)
393393
outStr = name + ' = NotificationGroup(' + oidStr + ')' + label
@@ -417,7 +417,7 @@ def genNotificationType(self, data, classmode=False):
417417
oidStr, parentOid = oid
418418

419419
if objects:
420-
objects = ['("' + self.moduleName[0] + '", "' + self.transOpers(obj) + '")' for obj in objects]
420+
objects = ['("' + self._importMap.get(obj, self.moduleName[0]) + '", "' + self.transOpers(obj) + '")' for obj in objects]
421421

422422
objStr = ', '.join(objects)
423423
outStr = name + ' = NotificationType(' + oidStr + ')' + label
@@ -446,7 +446,7 @@ def genObjectGroup(self, data, classmode=False):
446446
oidStr, parentOid = oid
447447

448448
if objects:
449-
objects = ['("' + self.moduleName[0] + '", "' + self.transOpers(obj) + '")' for obj in objects]
449+
objects = ['("' + self._importMap.get(obj, self.moduleName[0]) + '", "' + self.transOpers(obj) + '")' for obj in objects]
450450

451451
objStr = ', '.join(objects)
452452
outStr = name + ' = ObjectGroup(' + oidStr + ')' + label
@@ -519,7 +519,7 @@ def genObjectType(self, data, classmode=False):
519519

520520
if augmention:
521521
augmention = self.transOpers(augmention)
522-
outStr += augmention + '.registerAugmentions(("' + self.moduleName[0] + '", "' + name + '"))\n'
522+
outStr += augmention + '.registerAugmentions(("' + self._importMap.get(name, self.moduleName[0]) + '", "' + name + '"))\n'
523523
outStr += name + '.setIndexNames(*' + augmention + '.getIndexNames())\n'
524524

525525
if status:
@@ -547,7 +547,7 @@ def genTrapType(self, data, classmode=False):
547547
enterpriseStr, parentOid = enterprise
548548

549549
if variables:
550-
variables = ['("' + self.moduleName[0] + '", "' + self.transOpers(var) + '")' for var in variables]
550+
variables = ['("' + self._importMap.get(var, self.moduleName[0]) + '", "' + self.transOpers(var) + '")' for var in variables]
551551

552552
varStr = ', '.join(variables)
553553

0 commit comments

Comments
 (0)