aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteve McIntyre <steve.mcintyre@linaro.org>2015-10-08 15:33:28 +0100
committerSteve McIntyre <steve.mcintyre@linaro.org>2015-10-08 15:33:28 +0100
commitb0aa46001c604882511f5c68e42ba25aa1caf231 (patch)
tree33b61a30030c75c1e1f06dfc75828f17c60bd539
parent7f359dd362d38db69e9a2177d5830a54d6c94f51 (diff)
Add an option for the visualisation web interface to auto-refresh
Change-Id: Iee39e5c221a57d7e418a236b546cd790cd3902b3
-rw-r--r--config/config.py10
-rw-r--r--visualisation/visualisation.py3
2 files changed, 13 insertions, 0 deletions
diff --git a/config/config.py b/config/config.py
index 9b5fc57..3694196 100644
--- a/config/config.py
+++ b/config/config.py
@@ -79,6 +79,7 @@ class VlanConfig:
'name': None,
'password': None,
'port': None,
+ 'refresh': None,
'server': None,
'username': None,
})
@@ -207,6 +208,15 @@ class VlanConfig:
except:
raise ConfigError('Invalid visualisation configuration (enabled)')
+ try:
+ self.visualisation.refresh = config.get(section, 'refresh')
+ if self.visualisation.refresh is not None:
+ self.visualisation.refresh = int(self.visualisation.refresh)
+ except ConfigParser.NoOptionError:
+ pass
+ except:
+ raise ConfigError('Invalid visualisation configuration (refresh)')
+
else:
match = sw_regex.match(section)
if match:
diff --git a/visualisation/visualisation.py b/visualisation/visualisation.py
index 72c5ee7..164db5f 100644
--- a/visualisation/visualisation.py
+++ b/visualisation/visualisation.py
@@ -94,11 +94,14 @@ class GetHandler(BaseHTTPRequestHandler):
self.send_response(200)
self.wfile.write('Content-type: text/html\r\n')
self.end_headers()
+ config = self.server.state.config.visualisation
page = []
page.append('<html>')
page.append('<head>')
page.append('<TITLE>VLANd visualisation</TITLE>')
page.append('<link rel="stylesheet" type="text/css" href="style.css">')
+ if config.refresh and config.refresh > 0:
+ page.append('<meta http-equiv="refresh" content="%d">' % config.refresh)
page.append('</HEAD>')
page.append('<body>')
switches = self.server.state.db.all_switches()