cancel
Showing results for 
Search instead for 
Did you mean: 

Does the X435 support phyton scripting?

Does the X435 support phyton scripting?

AntonS
Contributor II
Hello,
I have an X435 switch and try to run a phyton script according to https://extremeportal.force.com/ExtrArticleDetail?an=000079734&q=python%20script

xxxx-SW1.8 # cat test.py

print ("Script Start!")

for number in range(1,11):

    print ("The number count is {0}").format(number)

 

showvlan = exsh.clicmd("show vlan", True)

print showvlan

xxxx-SW1.9 # load script test.py

Script Start!

The number count is 1

The number count is 2

The number count is 3

The number count is 4

The number count is 5

The number count is 6

The number count is 7

The number count is 8

The number count is 9

The number count is 10

Traceback (most recent call last):

  File "/usr/local/cfg/test.py", line 5, in <module>

    showvlan = exsh.clicmd("show vlan", True)

NameError: name 'exsh' is not defined

Does the X435 support Phyton scripting?

1 ACCEPTED SOLUTION

CThompsonEXOS
Extreme Employee
Hi,

You have to import the exsh module as your first line like below:
import exsh​

From there you should get the following:
#before importing the module
X435-8P-2T-W.8 # run script test
Script Start!
The number count is 1
The number count is 2
The number count is 3
The number count is 4
The number count is 5
The number count is 6
The number count is 7
The number count is 8
The number count is 9
The number count is 10
Traceback (most recent call last):
  File "/usr/local/cfg/test.py", line 5, in <module>
    showvlan = exsh.clicmd("show vlan", True)
NameError: name 'exsh' is not defined


#after importing the module
* X435-8P-2T-W.9 # vi test.py
* X435-8P-2T-W.10 # run script test
Script Start!
The number count is 1
The number count is 2
The number count is 3
The number count is 4
The number count is 5
The number count is 6
The number count is 7
The number count is 8
The number count is 9
The number count is 10
Untagged ports auto-move: Inform
-----------------------------------------------------------------------------------------------
Name            VID  Protocol Addr       Flags                         Proto  Ports  Virtual
                                                                              Active router
                                                                              /Total
-----------------------------------------------------------------------------------------------
Default         1    10.67.72.83    /24  ------------T-------------    ANY    2 /10  VR-Default
-----------------------------------------------------------------------------------------------
Flags : (B) BFD Enabled, (c) 802.1ad customer VLAN, (C) EAPS Control VLAN,
        (d) Dynamically created VLAN, (D) VLAN Admin Disabled,
        (E) ESRP Enabled, (f) IP Forwarding Enabled,
        (F) Learning Disabled, (i) ISIS Enabled,
        (I) Inter-Switch Connection VLAN for MLAG, (k) PTP Configured,
        (l) MPLS Enabled, (L) Loopback Enabled, (m) IPmc Forwarding Enabled,
        (M) Translation Member VLAN or Subscriber VLAN, (n) IP Multinetting Enabled,
        (N) Network Login VLAN, (o) OSPF Enabled, (O) Virtual Network Overlay,
        (p) PIM Enabled, (P) EAPS protected VLAN, (r) RIP Enabled,
        (R) Sub-VLAN IP Range Configured, (s) Sub-VLAN, (S) Super-VLAN,
        (t) Translation VLAN or Network VLAN, (T) Member of STP Domain,
        (v) VRRP Enabled, (V) VPLS Enabled, (W) VPWS Enabled,
        (Y) Policy Enabled

Total number of VLAN(s) : 1
​

Below is more information on Python and EXOS:

https://documentation.extremenetworks.com/pdfs/exos/Python_Getting_Started_Guide.pdf


766fa748ae0a45f8a2904db85e627675.png


Thanks,
Chris Thompson

View solution in original post

4 REPLIES 4

CThompsonEXOS
Extreme Employee
Hi Anton,

Also, there is a decent repo here of Python scripts for EXOS:

https://github.com/extremenetworks/ExtremeScripting/tree/master/EXOS/Python

Thanks,
Chris Thompson

AntonS
Contributor II

Hello Christopher, Thank you for your reply. It works now.  

Python Getting Started Guide - that guide is awesome!

CThompsonEXOS
Extreme Employee
I also edited the original article to include the line of importing the module.

Thanks,
Chris Thompson

CThompsonEXOS
Extreme Employee
Hi,

You have to import the exsh module as your first line like below:
import exsh​

From there you should get the following:
#before importing the module
X435-8P-2T-W.8 # run script test
Script Start!
The number count is 1
The number count is 2
The number count is 3
The number count is 4
The number count is 5
The number count is 6
The number count is 7
The number count is 8
The number count is 9
The number count is 10
Traceback (most recent call last):
  File "/usr/local/cfg/test.py", line 5, in <module>
    showvlan = exsh.clicmd("show vlan", True)
NameError: name 'exsh' is not defined


#after importing the module
* X435-8P-2T-W.9 # vi test.py
* X435-8P-2T-W.10 # run script test
Script Start!
The number count is 1
The number count is 2
The number count is 3
The number count is 4
The number count is 5
The number count is 6
The number count is 7
The number count is 8
The number count is 9
The number count is 10
Untagged ports auto-move: Inform
-----------------------------------------------------------------------------------------------
Name            VID  Protocol Addr       Flags                         Proto  Ports  Virtual
                                                                              Active router
                                                                              /Total
-----------------------------------------------------------------------------------------------
Default         1    10.67.72.83    /24  ------------T-------------    ANY    2 /10  VR-Default
-----------------------------------------------------------------------------------------------
Flags : (B) BFD Enabled, (c) 802.1ad customer VLAN, (C) EAPS Control VLAN,
        (d) Dynamically created VLAN, (D) VLAN Admin Disabled,
        (E) ESRP Enabled, (f) IP Forwarding Enabled,
        (F) Learning Disabled, (i) ISIS Enabled,
        (I) Inter-Switch Connection VLAN for MLAG, (k) PTP Configured,
        (l) MPLS Enabled, (L) Loopback Enabled, (m) IPmc Forwarding Enabled,
        (M) Translation Member VLAN or Subscriber VLAN, (n) IP Multinetting Enabled,
        (N) Network Login VLAN, (o) OSPF Enabled, (O) Virtual Network Overlay,
        (p) PIM Enabled, (P) EAPS protected VLAN, (r) RIP Enabled,
        (R) Sub-VLAN IP Range Configured, (s) Sub-VLAN, (S) Super-VLAN,
        (t) Translation VLAN or Network VLAN, (T) Member of STP Domain,
        (v) VRRP Enabled, (V) VPLS Enabled, (W) VPWS Enabled,
        (Y) Policy Enabled

Total number of VLAN(s) : 1
​

Below is more information on Python and EXOS:

https://documentation.extremenetworks.com/pdfs/exos/Python_Getting_Started_Guide.pdf


766fa748ae0a45f8a2904db85e627675.png


Thanks,
Chris Thompson
GTM-P2G8KFN