diff --git a/CHANGES.rst b/CHANGES.rst index 1ca7ec5..8446fb2 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -5,6 +5,8 @@ Revision 0.1.3, XX-05-2017 * INET-ADDRESS-MIB configured as pre-built at pysnmp codegen * JSON codegen produces "nodetype" element for OBJECT-TYPE * Fix to mibdump.py --destination-directory option +* Fix to pysnmp and JSON code generators to properly refer to MIB module + defining particular MIB object Revision 0.1.2, 12-04-2017 -------------------------- diff --git a/pysmi/codegen/jsondoc.py b/pysmi/codegen/jsondoc.py index dc56474..221fa8e 100644 --- a/pysmi/codegen/jsondoc.py +++ b/pysmi/codegen/jsondoc.py @@ -331,7 +331,7 @@ def genNotificationGroup(self, data): outDict['class'] = 'notificationgroup' if objects: - outDict['objects'] = [{'module': self.moduleName[0], 'object': self.transOpers(obj)} for obj in objects] + outDict['objects'] = [{'module': self._importMap.get(obj, self.moduleName[0]), 'object': self.transOpers(obj)} for obj in objects] if status: outDict['status'] = status @@ -360,7 +360,7 @@ def genNotificationType(self, data): outDict['class'] = 'notificationtype' if objects: - outDict['objects'] = [{'module': self.moduleName[0], 'object': self.transOpers(obj)} for obj in objects] + outDict['objects'] = [{'module': self._importMap.get(obj, self.moduleName[0]), 'object': self.transOpers(obj)} for obj in objects] if status: outDict['status'] = status @@ -388,7 +388,7 @@ def genObjectGroup(self, data): 'class': 'objectgroup'}) if objects: - outDict['objects'] = [{'module': self.moduleName[0], 'object': self.transOpers(obj)} for obj in objects] + outDict['objects'] = [{'module': self._importMap.get(obj, self.moduleName[0]), 'object': self.transOpers(obj)} for obj in objects] if status: outDict['status'] = status @@ -501,7 +501,7 @@ def genTrapType(self, data): outDict['class'] = 'notificationtype' if variables: - outDict['objects'] = [{'module': self.moduleName[0], 'object': self.transOpers(obj)} for obj in variables] + outDict['objects'] = [{'module': self._importMap.get(obj, self.moduleName[0]), 'object': self.transOpers(obj)} for obj in variables] if self.genRules['text'] and description: outDict['description'] = description diff --git a/pysmi/codegen/pysnmp.py b/pysmi/codegen/pysnmp.py index 4982cb1..76c5f21 100644 --- a/pysmi/codegen/pysnmp.py +++ b/pysmi/codegen/pysnmp.py @@ -387,7 +387,7 @@ def genNotificationGroup(self, data, classmode=False): oidStr, parentOid = oid if objects: - objects = ['("' + self.moduleName[0] + '", "' + self.transOpers(obj) + '")' for obj in objects] + objects = ['("' + self._importMap.get(obj, self.moduleName[0]) + '", "' + self.transOpers(obj) + '")' for obj in objects] objStr = ', '.join(objects) outStr = name + ' = NotificationGroup(' + oidStr + ')' + label @@ -417,7 +417,7 @@ def genNotificationType(self, data, classmode=False): oidStr, parentOid = oid if objects: - objects = ['("' + self.moduleName[0] + '", "' + self.transOpers(obj) + '")' for obj in objects] + objects = ['("' + self._importMap.get(obj, self.moduleName[0]) + '", "' + self.transOpers(obj) + '")' for obj in objects] objStr = ', '.join(objects) outStr = name + ' = NotificationType(' + oidStr + ')' + label @@ -446,7 +446,7 @@ def genObjectGroup(self, data, classmode=False): oidStr, parentOid = oid if objects: - objects = ['("' + self.moduleName[0] + '", "' + self.transOpers(obj) + '")' for obj in objects] + objects = ['("' + self._importMap.get(obj, self.moduleName[0]) + '", "' + self.transOpers(obj) + '")' for obj in objects] objStr = ', '.join(objects) outStr = name + ' = ObjectGroup(' + oidStr + ')' + label @@ -519,7 +519,7 @@ def genObjectType(self, data, classmode=False): if augmention: augmention = self.transOpers(augmention) - outStr += augmention + '.registerAugmentions(("' + self.moduleName[0] + '", "' + name + '"))\n' + outStr += augmention + '.registerAugmentions(("' + self._importMap.get(name, self.moduleName[0]) + '", "' + name + '"))\n' outStr += name + '.setIndexNames(*' + augmention + '.getIndexNames())\n' if status: @@ -547,7 +547,7 @@ def genTrapType(self, data, classmode=False): enterpriseStr, parentOid = enterprise if variables: - variables = ['("' + self.moduleName[0] + '", "' + self.transOpers(var) + '")' for var in variables] + variables = ['("' + self._importMap.get(var, self.moduleName[0]) + '", "' + self.transOpers(var) + '")' for var in variables] varStr = ', '.join(variables)