Administrator Guide
13 Python Scripting for Dell Networking N-Series | Version 1.0.1
3 Examples of Python scripting on Dell N-Series
Three examples are provided below to demonstrate various ways a Python script can be used to configure
and manage Dell N-Series switches. Example 1: Quick Steps
is a short illustration showing the fundamental
commands to express how quickly scripts can be created and applied. Example 2: Applying Python scripts
for execution at reload and 3.3 provide more intricate details to build a better understanding of these features
while covering the remaining commands.
3.1 Example 1: Quick Steps
The following is a list of steps to create and execute a simple Python script on an N-Series switch:
a. Use your favorite script editor (for example, gedit) to create the following script named “hello”
#!/usr/bin/env python
print “\n Hello World! \n”
b. Set execute permissions on the script file and compress the file into a .tgz or .tar.gz format (as discussed
on page 8
)
c. From the switch console screen, use the commands below (in bold) to:
i. Copy the file to “user-apps” (be sure to use the “application” option)
ii. Verify the file appears in the user-apps directory
iii. Install the application
iv. Start the application
console#copy tft
p://xx.xx.xx.xx/hello.tar.gz application hello.tar.gz < copies to user-apps
console#dir user-apps < shows file was copied
console#configure
console(config)#application install hello < readies file for execution
console(config)#show application < shows file is ready
console(config)#exit
console#application start hello < executes the script
Application started.
console#
Hello World!
Note: Refer to the more elaborate examples below for details on what each of these commands do.
Note: Along with Python scripting, a second scripting method available for use with the Dell N-Series is to
use the copy tftp <…> script command to load a .SCR script file. This offers a simple static script technique
that may be accommodating in certain situations, but does not offer the robustness and control of Python
scripting such as parsing, looping, if-then-else, etc. For more information on .SCR scripting, see the Images
and File Management chapter of the User Guide.