Author: justi9
Date: 2007-10-16 16:56:45 -0400 (Tue, 16 Oct 2007)
New Revision: 1098
Modified:
mgmt/cumin/python/cumin/cluster.py
mgmt/cumin/python/cumin/cluster.strings
Log:
Status lights for clusters.
Modified: mgmt/cumin/python/cumin/cluster.py
===================================================================
--- mgmt/cumin/python/cumin/cluster.py 2007-10-16 20:28:34 UTC (rev 1097)
+++ mgmt/cumin/python/cumin/cluster.py 2007-10-16 20:56:45 UTC (rev 1098)
@@ -1,5 +1,6 @@
from wooly import *
from wooly.widgets import *
+from random import random
from virtualhost import *
from server import *
@@ -9,6 +10,11 @@
strings = StringCatalog(__file__)
class ClusterSet(ItemSet):
+ def __init__(self, app, name):
+ super(ClusterSet, self).__init__(app, name)
+
+ self.server_tmpl = Template(self, "server_html")
+
def render_title(self, session, model):
return "Clusters (%i)" % len(model.get_clusters())
@@ -21,6 +27,17 @@
return mlink(branch.marshal(), "Cluster", cluster.name)
+ def render_item_server_lights(self, session, cluster):
+ writer = Writer()
+
+ for server in sorted_by(cluster.server_items()):
+ self.server_tmpl.render(session, server, writer)
+
+ return writer.to_string()
+
+ def render_server_status(self, session, server):
+ return random() < 0.25 and "red" or "green"
+
class ClusterServerSet(ItemSet):
def render_title(self, session, cluster):
return "Servers (%i)" % len(cluster.server_items())
Modified: mgmt/cumin/python/cumin/cluster.strings
===================================================================
--- mgmt/cumin/python/cumin/cluster.strings 2007-10-16 20:28:34 UTC (rev 1097)
+++ mgmt/cumin/python/cumin/cluster.strings 2007-10-16 20:56:45 UTC (rev 1098)
@@ -1,3 +1,17 @@
+[ClusterSet.css]
+div.serverlight {
+ float: left;
+ width: 1em;
+ height: 1em;
+ margin: 0.25em 1px 0 0;
+ padding: 0;
+ background-color: #6f6;
+}
+
+div.serverlight.red {
+ background-color: red;
+}
+
[ClusterSet.html]
<table class="ClusterSet mobjects">
<tr>
@@ -13,9 +27,15 @@
<tr>
<td>{item_link}</td>
<td>3 servers</td>
- <td>0 errors, 0 warnings</td>
+ <td>
+ <div>0 errors, 0 warnings</div>
+ <div>{item_server_lights}</div>
+ </td>
</tr>
+[ClusterSet.server_html]
+<div class="serverlight {server_status}"></div>
+
[ClusterView.html]
<div class="oblock">
<div class="mstatus green" id="{id}">