Package Products :: Package ZenModel :: Module zenmib :: Class ZenMib |
[hide private]
[frames] | no frames]

# Class ZenMib

source code

                  object --+
                           |
    ZenUtils.CmdBase.CmdBase --+
                               |
    ZenUtils.ZenDaemon.ZenDaemon --+
                                   |
          ZenUtils.ZCmdBase.ZCmdBase --+
                                       |
                                      ZenMib

Wrapper around the smidump utilities used to convert MIB definitions into python code which is in turn loaded into the DMD tree.

Instance Methods | [hide private]
makeMibFileObj(self, fileName) Scan the MIB file to determine what MIBs are defined in the file and what their dependencies are. | source code
MibFile |
populateDependencyMap(self, importFileNames, depFileNames) Populates the self.mibToMibFile instance object with data. | source code
list of strings |
getDependencyFileNames(self, mibFileObj) smidump needs to know the list of dependent files for a MIB file in order to properly resolve external references. | source code
savePythonCode(self, pythonCode, fileName) Stores the smidump-generated Python code to a file. | source code
list |
generatePythonFromMib(self, fileName, dependencyFileNames, mibNamesInFile) Use the smidump program to convert a MIB into Python code. | source code
evalPythonToMibs(self, pythonCode, name) Evaluate the code and return an array of MIB dictionaries. | source code
evalAddSavedPythonCode(self) Read the file named in the command-line option, evaluate it, and add it to our list of MIBs. | source code
getDmdMibDict(self, dmdMibDict, mibOrganizer) Populate a dictionary containing the MIB definitions that have been loaded into the DMD Mibs directory | source code
int |
addMibEntries(self, leafType, pythonMib, mibModule) Add the different MIB leaves (ie nodes, notifications) into the DMD. | source code
boolean |
loadMibFile(self, mibFileObj, dmdMibDict) Attempt to load the MIB definitions in fileName into DMD | source code
commit(self, message) | source code
loadPythonMibs(self, pythonMibs) Walk through the MIB dictionaries and add the MIBs to the DMD. | source code
set |
getAllMibDepFileNames(self) Use command line parameters to create a list of files containing MIB definitions that will be used as a reference list for the files being loaded into the DMD | source code
list |
getMibsToImport(self) Uses command-line parameters to create a list of files containing MIB definitions that are to be loaded into the DMD | source code
main(self) Main loop of the program | source code
buildOptions(self) Command-line options | source code
Inherited from `ZenUtils.ZCmdBase.ZCmdBase`: `__init__`, `closeAll`, `closedb`, `findDevice`, `getConnection`, `getContext`, `getDataRoot`, `getDmdObj`, `login`, `logout`, `opendb`, `sigTerm`, `syncdb`, `zodbConnect` Inherited from `ZenUtils.ZenDaemon.ZenDaemon`: `audit`, `becomeDaemon`, `becomeWatchdog`, `changeUser`, `convertSocketOption`, `logname`, `niceDoggie`, `openPrivilegedPort`, `setupLogging`, `sighandler_USR1`, `watchdogCycleTime`, `watchdogMaxRestartTime`, `watchdogStartTimeout`, `writePidFile` Inherited from `ZenUtils.ZenDaemon.ZenDaemon` (private): `_sigUSR1_called` Inherited from `ZenUtils.CmdBase.CmdBase`: `buildParser`, `checkLogpath`, `generate_configs`, `generate_xml_configs`, `generate_xml_table`, `getConfigFileDefaults`, `getGlobalConfigFileDefaults`, `getParamatersFromConfig`, `loadConfigFile`, `parseOptions`, `pretty_print_config_comment`, `validateConfigFile`

Class Variables | [hide private]
Inherited from `ZenUtils.ZenDaemon.ZenDaemon`: `pidfile` Inherited from `ZenUtils.CmdBase.CmdBase`: `doesLogging`

Method Details | [hide private]

### makeMibFileObj(self, fileName) | source code
    Scan the MIB file to determine what MIBs are defined in the file and
    what their dependencies are.

    @param fileName: MIB fileName
    @type fileName: string
    @return: dependencyDict, indexDict
        dependencyDict - a dictionary that associates MIB definitions
            found in fileName with their dependencies
        indexDict - a dictionary that associates MIB definitions with their
            ordinal position within fileName}
    @rtype:
        dependencyDict = {mibName: [string list of MIB definition names
            that mibName is dependant on]}
        indexDict = {mibname: number}

### populateDependencyMap(self, importFileNames, depFileNames) | source code
Populates the self.mibToMibFile instance object with data. Exit the program if we're missing any files. Parameters: `importFileNames` (list of strings) - fully qualified file names of MIB files to import `depFileNames` (list of strings) - fully qualified file names of all MIB files Returns: MibFile mibFileObjects of files to import

### getDependencyFileNames(self, mibFileObj) | source code
smidump needs to know the list of dependent files for a MIB file in order to properly resolve external references. Parameters: `mibFileObj` (MibFile) - MibFile object Returns: list of strings list of dependency fileNames

### generatePythonFromMib(self, fileName, dependencyFileNames, mibNamesInFile) | source code
Use the smidump program to convert a MIB into Python code. One major caveat: smidump by default only outputs the last MIB definition in a file. For that matter, it always outputs the last MIB definition in a file whether it is requested or not. Therefore, if there are multiple MIB definitions in a file, all but the last must be explicitly named on the command line. If you name the last, it will come out twice. We don't want that. OK, so we need to determine if there are multiple MIB definitions in fileName and then add all but the last to the command line. That works except the resulting python code will create a dictionary for each MIB definition, all of them named MIB. Executing the code is equivalent to running a=1; a=2; a=3. You only wind up with a=3. Therefore, we separate each dictionary definition into its own string and return a list of strings so each one can be executed individually. Parameters: `fileName` (string) - name of the file containing MIB definitions `dependencyFileNames` (list of strings) - list of fileNames that fileName is dependent on `mibNamesInFile` (list of strings) - names of MIB definitions in file Returns: list list of dictionaries. Each dictionary containing the contents of a MIB definition. [ {'mibName': MIB data} ]

### getDmdMibDict(self, dmdMibDict, mibOrganizer) | source code
    Populate a dictionary containing the MIB definitions that have been
    loaded into the DMD Mibs directory

    @param dmdMibDict: maps a MIB definition to the path where
            it is located with in the DMD.
        Format:
            {'mibName': 'DMD path where mibName is stored'}
        Example: MIB-Dell-10892 is located in the DMD tree at
            Mibs/SITE/Dell, Directory entry is
            {'MIB-Dell-10892': '/SITE/Dell'] }
    @param mibOrganizer: the DMD directory to be searched
    @type mibOrganizer: MibOrganizer

### addMibEntries(self, leafType, pythonMib, mibModule) | source code
Add the different MIB leaves (ie nodes, notifications) into the DMD. Parameters: `leafType` (string) `mibModule` (class) `pythonMib` (dictionary) Returns: int number of leaves added

### loadMibFile(self, mibFileObj, dmdMibDict) | source code
Attempt to load the MIB definitions in fileName into DMD Parameters: `fileName` (string) - name of the MIB file to be loaded Returns: boolean whether the MIB load was successful or not

### getAllMibDepFileNames(self) | source code
Use command line parameters to create a list of files containing MIB definitions that will be used as a reference list for the files being loaded into the DMD Returns: set set of file names

### getMibsToImport(self) | source code
Uses command-line parameters to create a list of files containing MIB definitions that are to be loaded into the DMD Returns: list list of file names that are to be loaded into the DMD

### buildOptions(self) | source code
Command-line options Overrides: ZenUtils.CmdBase.CmdBase.buildOptions