Lab3 EMC Python: Edit Ports

#@MetaDataStart
#@VariableFieldLabel (description = “Name of action to perform on (s)Witch port ?”,
#                     type = string,
#                     required = yes,
#                     validValues = [Burn-now, Burn-today, Burn-tomorrow, Burn-anyway],
#                     readOnly = no
#                     )
set var witchPort Burn-tomorrow
#@MetaDataEnd

def main():

try:
selectedPorts = emc_vars[‘port’]
except:
selectedPorts = None

if selectedPorts == None:
print “Performed no action as no ports selected on this switch”
return

assignName = emc_vars[‘witchPort’]

familyType = emc_vars[‘family’]

if familyType == ‘VSP Series’:
emc_cli.send(‘enable’)
emc_cli.send(‘config term’)
cmd = ‘interface gigabitEthernet ‘+selectedPorts
emc_cli.send(cmd)
cmd = ‘name “‘+assignName+'”‘
emc_cli.send(cmd)

elif familyType == ‘Summit Series’:
cmd = ‘configure ports ‘+selectedPorts+’ display-string “‘+assignName+'”‘
emc_cli.send(cmd)

else:
raise RuntimeError(“Unexpected switch family type!!”)

print “Successfully configured ports {} with name ‘{}'”.format(selectedPorts, assignName)

main()

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s