The unified diff between revisions [5b5ff777..] and [d6b8931f..] is displayed below. It can also be downloaded as a raw diff.

#
#
# add_dir "templates"
#
# add_dir "templates/fmi2900"
#
# add_file "templates/fmi2900/commands.py"
#  content [c49ba5091542ac6afc971e31ec449013eb912259]
#
============================================================
--- templates/fmi2900/commands.py	c49ba5091542ac6afc971e31ec449013eb912259
+++ templates/fmi2900/commands.py	c49ba5091542ac6afc971e31ec449013eb912259
@@ -0,0 +1,37 @@
+
+import telnetlib
+import time
+import os
+
+def check_host_alive(hostname):
+	status = os.system('/usr/bin/fping -q -c 1 -t 200 %s >/dev/null 2>&1' % (hostname))
+	return (status == 0)
+
+def configure(host, ip_address, mac_address, interface, username, password, enable):
+	attempts, alive, real_ip = 120, False,  host['attrs']['IPADDR']
+	for i in range(attempts):
+		time.sleep(1)
+		alive = check_host_alive(real_ip)
+		if alive: break
+	if not alive:
+		print "Unable to contact the Cisco. Giving up."
+		return False
+	print "Switch is up on %s. Starting config of switch via telnet." % (real_ip)
+	tn = telnetlib.Telnet(real_ip)
+	print tn.read_until("Username:")
+	tn.write(username + "\n")
+	print tn.read_until("Password:")
+	tn.write(password + "\n")
+	print tn.read_until(">")
+	tn.write("enable\n")
+	print tn.read_until("Password:")
+	tn.write(enable + "\n")
+	print tn.read_until("#")
+	tn.write("writ mem\n")
+	print tn.read_until("OK")
+	tn.write("logout\n")
+	print tn.read_all()
+	print "** DONE **"
+
+
+