/[shmookey]/portconf/index.py


UCC Code Repository

Diff of /portconf/index.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 108 by shmookey, Wed May 7 09:59:20 2008 UTC revision 109 by shmookey, Sun May 18 07:37:33 2008 UTC
# Line 36  form = cgi.FieldStorage () Line 36  form = cgi.FieldStorage ()
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' />"
# Line 122  def ShowSwitchStatus (switchName): Line 121  def ShowSwitchStatus (switchName):
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
# Line 156  def ShowSwitchStatus (switchName): Line 159  def ShowSwitchStatus (switchName):
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"):

Legend:
Removed from v.108  
changed lines
  Added in v.109

Managed by UCC Webmasters ViewVC Help
Powered by ViewVC 1.1.26