Change IP or Mask of Management VLAN locally in EXOS

Procedure

Login to your switch
Use VI to create a python script, or use TFTP to transfer the Python file to EXOS.
Type vi <Python_FILE_NAME>.py to create the Python file
In the Vi editor, type press the i key to enter insert mode.
Create the Python script.
Exit insert mode by pressing the Esc key.
Save and exit by typing :wq
Run your Python script.
To run the script use the command load script <Python_FILE_NAME>.py

Example:

# vi chg_mask.py
import exsh
exsh.clicmd(“unconfigure vlan MGMT ipaddress”)
exsh.clicmd(“configure vlan MGMT ipaddress 10.10.10.130 255.255.255.192”)
print (“Change complete!”)

# cat chg_mask.py
import exsh
exsh.clicmd(“unconfigure vlan MGMT ipaddress”)
exsh.clicmd(“configure vlan MGMT ipaddress 10.10.10.130 255.255.255.192”)
print (“Change complete!”)

# load sc chg_mask.py

Note: Used this on a live switch and changed the mask remotely without losing connection. Existing SSH session stayed connected which is why I scripted it, in case doing this procedure one line at a time without a script would cut me off.

Python Clear Screen Function

Have you wondered how to clear the screen of your python interpreter?

Create a function that can be called to do this.

>>> import os

>>> def clear():

… os.system(‘cls’ if os.name == ‘nt’ else ‘clear’)

Microsoft Windows uses cls and Linux uses clear command.

Tip:

If you import inspect module you can see the code inside a function.

>>> import inspect

>>> print(inspect.getsource(clear))

The output will look like this:

def clear():

os.system(‘cls’ if os.name == ‘nt’ else ‘clear’)

Now to try clearing the screen.

Type clear() and the screen will clear…

>>>

Type dir() shows the three modules installed like ‘clear’, ‘inspect’ and ‘os’ in our session above amongst others.