Administrator Guide

18 Python Scripting for Dell Networking N-Series | Version 1.0.1
print ("Creating 1000 VLANs on the switch")
for x in range(2, 1002):
cmd = "vlan %d" %(x)
send (cmd + '\r')
expect(confPrompt)
send ('exit\r')
expect(confPrompt)
#parse to count vlans created
print ("Verifying the VLAN database")
send('show vlan\r')
vlan = expect(confPrompt)
totalVlan = re.findall(r"VLAN(\d+){3}", vlan)
exp = len(range(2, 1002))
#if-else to determine output
if len(totalVlan) == exp:
print exp,("VLANs are created on the switch")
else:
print ("Failed to create required number of VLANs on the switch")
#close the telnet session
print ("Closing the telnet session")
t.close()
Switch commands
Enter the following commands from the switch command line. Replace xx.xx.xx.xx with the TFTP server’s IP
address. Replace <filename1> with the name of the compressed file. Replace <filename2> with the name of
the decompressed file (which automatically unzips during the copy):
console#copy tftp
://xx.xx.xx.xx/<filename1> application <filename1>
console#configure
console(config)#application install <filename2>
console(config)#exit
These commands install the script and mark it for execution. Administrators may then enter the start
command below when ready to run the script. The resulting output is shown: