Author: justi9
Date: 2007-10-16 11:34:43 -0400 (Tue, 16 Oct 2007)
New Revision: 1085
Modified:
mgmt/cumin/python/cumin/page.py
mgmt/cumin/python/cumin/server.py
mgmt/cumin/python/cumin/server.strings
Log:
Fills in the profile server and configuration tabs.
Modified: mgmt/cumin/python/cumin/page.py
===================================================================
--- mgmt/cumin/python/cumin/page.py 2007-10-16 15:03:48 UTC (rev 1084)
+++ mgmt/cumin/python/cumin/page.py 2007-10-16 15:34:43 UTC (rev 1085)
@@ -39,6 +39,9 @@
self.group_edit = ServerGroupEdit(app, "groupedit")
self.add_mode(self.group_edit)
+ self.profile = ServerProfileFrame(app, "profile")
+ self.add_mode(self.profile)
+
def save_session(self, session):
if self.app.debug:
self.app.debug.sessions.append(session)
@@ -92,6 +95,11 @@
frame.set_object(session, cluster)
return self.page().set_current_frame(session, frame)
+ def show_server_profile(self, session, profile):
+ frame = self.show_mode(session, self.profile)
+ frame.set_object(session, profile)
+ return self.page().set_current_frame(session, frame)
+
def show_virtual_host(self, session, vhost):
server = vhost.get_server()
cluster = vhost.get_cluster()
Modified: mgmt/cumin/python/cumin/server.py
===================================================================
--- mgmt/cumin/python/cumin/server.py 2007-10-16 15:03:48 UTC (rev 1084)
+++ mgmt/cumin/python/cumin/server.py 2007-10-16 15:34:43 UTC (rev 1085)
@@ -12,7 +12,7 @@
return "Servers (%i)" % len(model.get_servers())
def get_items(self, session, model):
- return sorted(model.get_servers(), cmp, lambda x: x.name)
+ return sortedby(model.get_servers())
def render_item_link(self, session, server):
branch = session.branch()
@@ -89,30 +89,16 @@
def render_none(self, session, group):
return none()
-class ServerProfileSet(ItemSet):
+class ConfigPropertySet(ItemSet):
def get_items(self, session, model):
- return sorted_by(model.get_server_profiles())
+ return sorted_by(model.get_config_properties())
- def render_item_link(self, session, profile):
- branch = session.branch()
- return mlink(branch.marshal(), "ServerProfile", profile.name)
-
-class ServerConfigPropertySet(ItemSet):
- def get_items(self, session, server):
- return sorted_by(server.config_property_items())
-
def render_item_name(self, session, prop):
return prop.name
def render_item_value(self, session, prop):
return prop.value
- def render_item_edit_href(self, session, prop):
- branch = session.branch()
- frame = self.page().show_server(branch, prop.get_server())
- frame.show_config_property(branch, prop)
- return branch.marshal()
-
class ConfigPropertyParameter(Parameter):
def do_unmarshal(self, string):
return self.app.model.get_config_property(int(string))
@@ -191,10 +177,10 @@
self.tabs = TabSet(app, "tabs")
self.add_child(self.tabs)
- self.tabs.add_tab(self.VirtualHostTab(app, "vhosts"))
- self.tabs.add_tab(self.ConfigTab(app, "config"))
- self.tabs.add_tab(self.StatsTab(app, "stats"))
- self.tabs.add_tab(self.LogTab(app, "log"))
+ self.tabs.add_tab(self.ServerVirtualHostTab(app, "vhosts"))
+ self.tabs.add_tab(self.ServerConfigTab(app, "config"))
+ self.tabs.add_tab(self.ServerStatsTab(app, "stats"))
+ self.tabs.add_tab(self.ServerLogTab(app, "log"))
def render_title(self, session, server):
return "Server '%s'" % server.name
@@ -214,22 +200,31 @@
return html
- class VirtualHostTab(VirtualHostSet):
+ class ServerVirtualHostTab(VirtualHostSet):
def render_title(self, session, server):
return "Functional Hosts (%i)" % len(server.virtual_host_items())
def get_items(self, session, server):
- return sorted(server.virtual_host_items(), cmp, lambda x: x.name)
+ return sorted_by(server.virtual_host_items())
- class ConfigTab(ServerConfigPropertySet):
+ class ServerConfigTab(ConfigPropertySet):
def render_title(self, session, server):
return "Configuration"
- class StatsTab(Widget):
+ def get_items(self, session, server):
+ return sorted_by(server.config_property_items())
+
+ def render_item_edit_href(self, session, prop):
+ branch = session.branch()
+ frame = self.page().show_server(branch, prop.get_server())
+ frame.show_config_property(branch, prop)
+ return branch.marshal()
+
+ class ServerStatsTab(Widget):
def render_title(self, session, server):
return "Statistics"
- class LogTab(Widget):
+ class ServerLogTab(Widget):
def render_title(self, session, server):
return "Log Messages"
@@ -383,3 +378,70 @@
def render_title(self, session, group):
return "Edit Group '%s'" % group.name
+
+class ServerProfileSet(ItemSet):
+ def get_items(self, session, model):
+ return sorted_by(model.get_server_profiles())
+
+ def render_item_link(self, session, profile):
+ branch = session.branch()
+ frame = self.page().show_server_profile(branch, profile)
+ frame.show_view(branch)
+ return mlink(branch.marshal(), "ServerProfile", profile.name)
+
+class ServerProfileParameter(Parameter):
+ def do_unmarshal(self, string):
+ return self.app.model.get_server_profile(int(string))
+
+ def do_marshal(self, profile):
+ return str(profile.id)
+
+class ServerProfileFrame(CuminFrame):
+ def __init__(self, app, name):
+ super(ServerProfileFrame, self).__init__(app, name)
+
+ self.param = ServerProfileParameter(app, "id")
+ self.add_parameter(self.param)
+ self.set_object_parameter(self.param)
+
+ self.view = ServerProfileView(app, "view")
+ self.add_mode(self.view)
+
+ def show_view(self, session):
+ return self.show_mode(session, self.view)
+
+ def render_title(self, session, profile):
+ return "Server Profile '%s'" % profile.name
+
+class ServerProfileView(Widget):
+ def __init__(self, app, name):
+ super(ServerProfileView, self).__init__(app, name)
+
+ self.tabs = TabSet(app, "tabs")
+ self.add_child(self.tabs)
+
+ self.tabs.add_tab(self.ProfileServerTab(app, "servers"))
+ self.tabs.add_tab(self.ProfileConfigTab(app, "config"))
+
+ def render_title(self, session, profile):
+ return "Server Profile '%s'" % profile.name
+
+ def render_name(self, session, profile):
+ return profile.name
+
+ class ProfileServerTab(ServerSet):
+ def __init__(self, app, name):
+ super(ServerProfileView.ProfileServerTab, self).__init__(app, name)
+
+ def render_title(self, session, profile):
+ return "Servers (%i)" % len(profile.server_items())
+
+ def get_items(self, session, profile):
+ return sorted_by(profile.server_items())
+
+ class ProfileConfigTab(ConfigPropertySet):
+ def get_items(self, session, profile):
+ return sorted_by(profile.config_property_items())
+
+ def render_title(self, session, profile):
+ return "Configuration"
Modified: mgmt/cumin/python/cumin/server.strings
===================================================================
--- mgmt/cumin/python/cumin/server.strings 2007-10-16 15:03:48 UTC (rev 1084)
+++ mgmt/cumin/python/cumin/server.strings 2007-10-16 15:34:43 UTC (rev 1085)
@@ -1,5 +1,5 @@
[ServerSet.html]
-<table class="ServerSet mobjects">
+<table class="mobjects">
<tr>
<th>Server</th>
<th>Cluster</th>
@@ -30,9 +30,10 @@
<td>{item_link}</td>
</tr>
-[ServerConfigPropertySet.html]
+[ServerConfigTab.html]
<ul class="actions">
- <li><a href="">Apply Configuration to This
Server</a></li>
+ <li><a href="">Apply This Configuration to
Server</a></li>
+ <li><a href="">Add Property</a></li>
</ul>
<table class="mobjects">
@@ -47,7 +48,7 @@
{items}
</table>
-[ServerConfigPropertySet.item_html]
+[ServerConfigTab.item_html]
<tr>
<td>{item_name}</td>
<td>{item_value}</td>
@@ -208,3 +209,40 @@
elem.select();
}())
</script>
+
+[ServerProfileView.html]
+<div class="oblock">
+ <h1>{title}</h1>
+
+ <dl class="properties">
+ <dt>Name</dt><dd>{name}</dd>
+ </dl>
+
+ <ul class="actions">
+ <li><a href="">Edit This Profile</a></li>
+ </ul>
+
+ {tabs}
+</div>
+
+[ProfileConfigTab.html]
+<ul class="actions">
+ <li><a href="">Add Property</a></li>
+</ul>
+
+<table class="mobjects">
+ <tr>
+ <th>Property</th>
+ <th>Configured Value</th>
+ <th></th>
+ </tr>
+
+ {items}
+</table>
+
+[ProfileConfigTab.item_html]
+<tr>
+ <td>{item_name}</td>
+ <td>{item_value}</td>
+ <td><a class="action"
href="">Edit</a></td>
+</tr>