36 |
|
|
37 |
def ShowDefaultPage (): |
def ShowDefaultPage (): |
38 |
print "<p>Select a switch to get started!</p>" |
print "<p>Select a switch to get started!</p>" |
39 |
print "<form action='index.html' method='get'>" |
print "<form action='index.py' method='get'>" |
40 |
print "<select name='switch'>" |
print "<select name='switch'>" |
41 |
switches = pycisco.GetSwitches () |
for switch in switchList: |
|
for switch in switches: |
|
42 |
print "<option value='" + switch + "'>" + switch + "</option>" |
print "<option value='" + switch + "'>" + switch + "</option>" |
43 |
print "</select>" |
print "</select>" |
44 |
print "<input type='hidden' name='action' value='status' />" |
print "<input type='hidden' name='action' value='status' />" |
121 |
print "</script>" |
print "</script>" |
122 |
|
|
123 |
try: |
try: |
124 |
ports = pycisco.GetPortSummary (switchName) |
switch = pyaaa.SafeObject (pycisco.NetworkDevice (), switchName) |
125 |
|
switch._username = "me" |
126 |
|
switch._Remap ("Connect", {"hostname" : "hostname", "username" : "usern", "password" : "passw", "enable" : "enablepw"}) |
127 |
|
switch.Connect () |
128 |
|
ports = switch.GetPortSummary () |
129 |
except pexpect.TIMEOUT: |
except pexpect.TIMEOUT: |
130 |
print "<h3 style='color:rgb(255,0,0)'>Switch appears to be down.</h3>" |
print "<h3 style='color:rgb(255,0,0)'>Switch appears to be down.</h3>" |
131 |
return |
return |
159 |
|
|
160 |
|
|
161 |
if not form.has_key ("action"): |
if not form.has_key ("action"): |
162 |
|
swInfo = pyaaa.SafeBase () |
163 |
|
swInfo._username = "me" |
164 |
|
switchList = swInfo._GetRecords ("NetworkDevice") |
165 |
ShowDefaultPage () |
ShowDefaultPage () |
166 |
elif form["action"].value == "status": |
elif form["action"].value == "status": |
167 |
if not form.has_key ("switch"): |
if not form.has_key ("switch"): |