Use this procedure to access a Python shell, within which you can use Python commands that call and manipulate Extreme operating system commands.
Note
The Python shell is accessible only to admin-role users.Python syntax is case-sensitive.
device# python
device#
prompt
changes to a Python prompt:
device# python Python 3.5.2 (default, Apr 11 2019, 13:05:18) [GCC 4.8.2] on linux Type "help", "copyright", "credits" or "license" for more information.
exit()
Ctrl-D
CLI( )
command.
>>> cmd_show_running_ve = CLI('show running-config interface ve') !Command: show running-config interface ve !Time: Mon Aug 22 16:53:13 2019
cmd_show_running_ve
\n
.
>>> cmd_config_ve = CLI('configure \n interface ve 101-103') !Command: configure interface ve 101-103 !Time: Mon Aug 22 16:53:13 2019
Note
There is a difference between running a sequence of Extreme operating system CLI commands in the Python shell rather than in the standard Extreme operating system interface. Whereas in the standard interface the result of a command is persistent, in the Python shell eachCLI( )
statement is independent of any preceding ones.
In the following example, the lines beginning with # are added for explanation.
device# python
Python 3.5.2 (default, Apr 11 2019, 13:05:18)
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> cmd_show_running_ve = CLI('show running-config interface ve')
!Command: show running-config interface ve
!Time: Mon Aug 22 16:53:13 2019
% No entries found.
# The SLX-OS show running-config interface ve command is run,
# and that command is assigned to the Python variable cmd_show_running_ve.
>>> cmd_config_ve = CLI('configure \n interface ve 101-103')
# A series of three commands are run and assigned to the Python variable cmd_config_ve.
!Command: configure
interface ve 101-103
!Time: Mon Aug 22 16:53:13 2019
>>> cmd_show_running_ve.rerun()
# The rerun() function appended to cmd_show_running_ve gives the following output:
!Command: show running-config interface ve
!Time: Mon Aug 22 16:53:13 2019
interface Ve 101
shutdown
!
interface Ve 102
shutdown
!
interface Ve 103
shutdown
!
!