The documentation set for this product strives to use bias-free language. For the purposes of this documentation set, bias-free is defined as language that does not imply discrimination based on age, disability, gender, racial identity, ethnic identity, sexual orientation, socioeconomic status, and intersectionality. Exceptions may be present in the documentation due to language that is hardcoded in the user interfaces of the product software, language used based on RFP documentation, or language that is used by a referenced third-party product. Learn more about how Cisco is using Inclusive Language.
This chapter provides the overview and installation information needed to use the Python Application Programming Interface (API) support on Cisco Nexus 5000 and Cisco Nexus 6000 Series switches.
Python is an easy to learn, powerful programming language. It has efficient high-level data structures and a simple but effective approach to object-oriented programming. Python’s elegant syntax and dynamic typing, together with its interpreted nature, make it an ideal language for scripting and rapid application development in many areas on most platforms.
The Python interpreter and the extensive standard library are freely available in source or binary form for all major platforms from the Python website:
The same site also contains distributions of and pointers to many free third-party Python modules, programs and tools, and additional documentation.
Note You can know the latest development on Cisco Nexus 5000 Series switches and contribute your ideas by joining the community codesharing page:
https://github.com/datacenter
The Cisco Nexus 5000 series switches with Releases 5.2(1)N1(1) and later and the Cisco Nexus 6000 series switches with Releases 6.0(2)N1(1)and later, support all the features available in Python v2.7.2.
The Python scripting capability on Cisco Nexus 5000 and Cisco Nexus 6000 series switches enables you to perform the following tasks:
The Python interpreter is available by default on the Cisco NX-OS software.You can invoke Python by entering the python command, and write scripts to access Cisco NX-OS APIs by importing the cisco.py module using the import cisco command.
You can install the third party pure Python package by copying mypkg.tgz on your server. Perform the following steps to extract and install the third party package:
Note You will be able to install the third party packages using the easy_install command, in the future releases.
This section describes how to write and execute Python scripts by passing parameters and includes the following topics:
You can enter the Python shell by using the python command without any parameters.
For NX-OS releases earlier than 7.0N, you can execute a Python script by using the python < filename > command.
For NX-OS releases 7.0N and later, you can execute a Python script by using the source < filename > command.
For NX-OS releases earlier than 7.0N, you can pass parameters to a Python script by using the python < filename > [ arg1, arg2, arg3,.....] command.
For NX-OS releases 7.0N and later, you can pass parameters to a Python script by using the source < filename > [ arg1, arg2, arg3,.....] command.