...
- Access to the Python exit function from within a script. If the Python script exits with a zero exit code, the script ceases operation and NetMRI sets the job status to OK. If the Python script exits with a non-zero exit code it causes the script to cease operation and NetMRI sets the job status to Error;
- Ability to mark problem commands and perform try/catch exception handling;
- A logging function, available in the infoblox_job.pl file;
- A Libraries page (see Using Perl or Python Libraries for more information) containing blocks of Python code to be referenced by other Python scripts. The Libraries page supports creation, editing, deletion, and import and export of snippets of Python code;
- Refer to lists of data to fill variables and find matches during job batch processing, extract information and parse the returned data (see the section Defining Lists for ACM, Perl, Python, and CCS Script Reference for more information);
- Use of standard NetMRI variables and data model objects in scripting logic. NetMRI automatically associates variables with target devices during runtime. Users can define input and internal variables that can be mapped to the NetMRI data model. The data model also provides access to device and interface attributes;
- Users can open multiple, simultaneous, device connections from within scripts, enabling change coordination between multiple devices in sequence or in parallel, based on common elements such as VLAN membership or neighbor topology. The feature is helpful in advanced use cases: for example, a script opens a connection to a network device, encounters a configuration element, and opens new connections to other, similar devices for comparison and determines the action to take on the current device;
- Regular expression processing, without restrictions on data structure types where regular expressions can be used, including script input variables, device output, data from external files, lists and NetMRI data model information.
Anatomy of a Python Script
Well-known variables for Python scripting are listed in the topic
...
Python scripts run inside the sandbox, using the Pyrthon API to communicate with the Device Interaction Server (DIS) on NetMRI. The DIS proxies CLI requests/responses to/from network devices on behalf of the Python scripts. Before commands can be sent to a network device, a Python script must first establish a DIS session (see v2 API object DisSession). After a session has been established, a CLI connection with the target device must be established for the given session (see v2 API object CliConnection). The majority of the time, a Python script will follow this same initialization sequence. First, establish the API session, establish the DIS session, then establish a CLI connection with the target device. For this reason, netmri_easy.py, a pre-installed Python library, is provided in the appliance (see Configuration Management –> Job Management –> Library –> netmri_easy).
About netmri_easy.py
The netmri_easy.py provides an interface to the NetMRI API from python scripts run on the NetMRI appliance.
...