cisco IOS XE 17.16.x — Cisco Python Module

C H A P T E R 5 Python API Python programmabililty supports Python APIs. About Python , on page 133 Additional References for Python API, on page 141 Feature Information for Python API, on page 141 About Python The Cisco IOS XE devices support Python Version 2.7 in both interactive and non-interactive (script) modes within the Guest Shell. The Python scripting capability gives programmatic access to a device's CLI to perform various tasks and Zero Touch Provisioning or Embedded Event Manager (EEM) actions. Cisco Python Module Cisco provides a Python module that provides access to run EXEC and configuration commands.

You can display the details of the Cisco Python module by entering the help() command. The help() command displays the properties of the Cisco CLI module. The following example displays information about the Cisco Python module: Device# guestshell run python Python 2.7.5 (default, Jun 17 2014, 18:11:42) [GCC 4.8.2 20140120 (Red Hat 4.8.2-16)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> >>> from cli import cli,clip,configure,configurep, execute, executep >>> help(configure) Help on function configure in module cli: configure(configuration) Apply a configuration (set of Cisco IOS CLI config-mode commands) to the device and return a list of results.

configuration = '''interface gigabitEthernet 0/0 no shutdown''' # push it through the Cisco IOS CLI. try: results = cli.configure(configuration) print "Success!" Programmability Configuration Guide, Cisco IOS XE 17.16.x 133