<< Click to Display Table of Contents >> Raynet One > 1.1 > User Guide > Technical overview > Custom inventory scripting Python inventory scripting |
The Python language is the recommended device inventory scripting language. Create powerful custom device inventory processes with this modern object-oriented programming language.
The IronPython language implementation is used. Default Python standard runtime libraries are excluded for robustness and increased security.
This chapter describes the provided API for Python script execution.
This object contains all of the API functions for communication with both the inventory device and the runner. It is imported into every executed script by default for convenience.
Requests the execution of a command on the remote system, the inventory device. The command is run with the same credentials as specified for this particular device. There is no further privilege elevation if not specified in the device credentials settings.
The command to execute remotely on the inventory device.
If true, error messages should be written to a device-local temporary error log file. On some platforms, the device command is amended with a shell-powered output redirection operator.
Default: False
Creates a new device inventory object of type InventoryItem and returns it. If create_custom_property is false, the value of class_name is used to categorize the inventory object for import. Otherwise, the object is not touched by the built-in device inventory import system at all. These objects are considered custom. They are exposed by API for self-built customer inventory processes (endpoint InventoryScriptResults).
The inventory object is not added to the device inventory process automatically. Use the PythonConnector.add_item function to add it.
If create_custom_property is false, the value of the name parameter is used internally only. Otherwise, the value is retrievable by API.
The class name of the object for distinct categorization and property expectation. It gives the object meaning.
The (internal) name of the object.
Decides whether the object should be excluded from built-in device inventory import logic or not.
Default: True
Adds a property to a device inventory object. Two properties with the same key can be added.
The value for the property's Name field.
The value for the property's Value field.
The device inventory object to assign the property to.
Adds the device inventory object pointed at by item to the device inventory process. As a result, the object is transfered to the system for import into the device inventory database.
The device inventory object to add.
Returns the string naming the device operating system category defined by the system for the inventory device.
Available operating system categories:
•"Unknown"
•"Solaris"
•"HPUX"
•"AIX"
•"OSX"
•"Linux"
•"Windows"
Returns the hostname string related to the inventory device. If there is no hostname related to the inventory device or its retrieval has failed, the empty string is returned.
Puts the message string as log entry of the critical category to the instrument log.
The message to put into the log.
Puts the message string as log entry of the error category to the instrument log.
The message to put into the log.
Puts the message string as log entry of the warning category to the instrument log.
The message to put into the log.
Puts the message string as log entry of the information category to the instrument log.
The message to put into the log.
Puts the message string as log entry of the debug category to the instrument log.
The message to put into the log.
Set the instrument log level of the runner to Verbose and view the executing instrument logs of inventory devices. There should be log lines related to the PythonScanner runner component.
The instrument log of a device which executed the program in the distributed device command execution use-case. There are many log lines. At some point, the PythonScanner runner software component is mentioned. You can see the line with the content "Collected ping inventory". This is the information-level log entry as output by the Python inventory script. Use log lines to reconstruct or trace the script's path of execution.