[rhmessaging-commits] rhmessaging commits: r976 - mgmt/cumin/python/cumin.

rhmessaging-commits at lists.jboss.org rhmessaging-commits at lists.jboss.org
Tue Oct 9 11:36:05 EDT 2007


Author: justi9
Date: 2007-10-09 11:36:05 -0400 (Tue, 09 Oct 2007)
New Revision: 976

Modified:
   mgmt/cumin/python/cumin/cluster.py
   mgmt/cumin/python/cumin/cluster.strings
   mgmt/cumin/python/cumin/demo.py
   mgmt/cumin/python/cumin/model.py
   mgmt/cumin/python/cumin/page.py
   mgmt/cumin/python/cumin/virtualhost.py
   mgmt/cumin/python/cumin/virtualhost.strings
Log:
Makes virtual hosts independent.  Updates the model and demo data to
reflect this.  Adds a virtual host tab to the cluster view.



Modified: mgmt/cumin/python/cumin/cluster.py
===================================================================
--- mgmt/cumin/python/cumin/cluster.py	2007-10-09 14:20:22 UTC (rev 975)
+++ mgmt/cumin/python/cumin/cluster.py	2007-10-09 15:36:05 UTC (rev 976)
@@ -1,10 +1,8 @@
 from wooly import *
 from wooly.widgets import *
 
+from virtualhost import *
 from server import *
-from queue import *
-from realm import *
-from exchange import *
 from widgets import *
 
 strings = StringCatalog(__file__)
@@ -60,6 +58,7 @@
         self.tabs = TabSet(app, "tabs")
         self.add_child(self.tabs)
 
+        self.tabs.add_child(self.ClusterVirtualHosts(app, "vhosts"))
         self.tabs.add_child(self.ClusterServers(app, "servers"))
 
     def render_title(self, session, cluster):
@@ -68,6 +67,13 @@
     def render_name(self, session, cluster):
         return cluster.name
 
+    class ClusterVirtualHosts(VirtualHostSet):
+        def render_title(self, session, cluster):
+            return "Virtual Hosts (%i)" % len(cluster.virtual_host_items())
+
+        def get_items(self, session, cluster):
+            return sorted(cluster.virtual_host_items(), cmp, lambda x: x.name)
+
     class ClusterServers(ServerSet):
         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-09 14:20:22 UTC (rev 975)
+++ mgmt/cumin/python/cumin/cluster.strings	2007-10-09 15:36:05 UTC (rev 976)
@@ -26,6 +26,7 @@
   </dl>
 
   <ul class="actions">
+    <li><a href="">Add Virtual Host</a></li>
     <li><a href="">Add Server</a></li>
     <li><a href="">Shutdown Servers in Cluster</a></li>
   </ul>

Modified: mgmt/cumin/python/cumin/demo.py
===================================================================
--- mgmt/cumin/python/cumin/demo.py	2007-10-09 14:20:22 UTC (rev 975)
+++ mgmt/cumin/python/cumin/demo.py	2007-10-09 15:36:05 UTC (rev 976)
@@ -40,10 +40,21 @@
             cluster.name = fmt("cluster", cluster_count)
             clusters.append(cluster)
 
+            vhost = VirtualHost(self.model)
+            vhost.name = cluster.name + ".default"
+            vhost.set_cluster(cluster)
+
+            for name in ("test", "devel"):
+                vhost = VirtualHost(self.model)
+                vhost.name = cluster.name + "." + name
+                vhost.set_cluster(cluster)
+
         for server_count in range(12):
+            cluster = clusters[server_count % 3]
+            
             server = Server(self.model)
             server.name = fmt("server", server_count)
-            server.set_cluster(clusters[server_count % 3])
+            server.set_cluster(cluster)
 
             if server_count % 2:
                 sgroups["East Coast"].add_server(server)
@@ -51,14 +62,14 @@
                 sgroups["West Coast"].add_server(server)
 
             vhost = VirtualHost(self.model)
-            vhost.name = "default"
-            server.add_virtual_host(vhost)
+            vhost.name = server.name + ".default"
+            vhost.set_server(server)
             server.default_virtual_host = vhost
 
             for name in ("test", "devel"):
                 vhost = VirtualHost(self.model)
-                vhost.name = name
-                server.add_virtual_host(vhost)
+                vhost.name = server.name + "." + name
+                vhost.set_server(server)
 
             for vhost in server.virtual_host_items():
                 for name in ("realm0", "realm1", "realm2"):

Modified: mgmt/cumin/python/cumin/model.py
===================================================================
--- mgmt/cumin/python/cumin/model.py	2007-10-09 14:20:22 UTC (rev 975)
+++ mgmt/cumin/python/cumin/model.py	2007-10-09 15:36:05 UTC (rev 976)
@@ -19,9 +19,13 @@
         assoc.add_endpoint(self.server, "cluster", "0..1")
         assoc.add_endpoint(self.cluster, "server", "0..n")
 
+        assoc = ModelAssociation(self, "cluster_to_virtual_hosts")
+        assoc.add_endpoint(self.virtual_host, "cluster", "0..1")
+        assoc.add_endpoint(self.cluster, "virtual_host", "0..n")
+
         assoc = ModelAssociation(self, "server_to_virtual_hosts")
+        assoc.add_endpoint(self.virtual_host, "server", "0..1")
         assoc.add_endpoint(self.server, "virtual_host", "0..n")
-        assoc.add_endpoint(self.virtual_host, "server", "0..1")
 
         assoc = ModelAssociation(self, "server_groups_to_servers")
         assoc.add_endpoint(self.server, "server_group", "0..n")

Modified: mgmt/cumin/python/cumin/page.py
===================================================================
--- mgmt/cumin/python/cumin/page.py	2007-10-09 14:20:22 UTC (rev 975)
+++ mgmt/cumin/python/cumin/page.py	2007-10-09 15:36:05 UTC (rev 976)
@@ -46,8 +46,7 @@
         return self.main.show_cluster(session, cluster)
 
     def show_virtual_host(self, session, vhost):
-        frame = self.show_server(session, vhost.server)
-        return frame.show_virtual_host(session, vhost)
+        return self.main.show_virtual_host(session, vhost)
 
     def show_queue(self, session, queue):
         frame = self.show_virtual_host(session, queue.virtual_host)

Modified: mgmt/cumin/python/cumin/virtualhost.py
===================================================================
--- mgmt/cumin/python/cumin/virtualhost.py	2007-10-09 14:20:22 UTC (rev 975)
+++ mgmt/cumin/python/cumin/virtualhost.py	2007-10-09 15:36:05 UTC (rev 976)
@@ -101,6 +101,31 @@
     def render_title(self, session, vhost):
         return "Virtual Host '%s'" % vhost.name
 
+    def render_name(self, session, vhost):
+        return vhost.name
+
+    def render_server(self, session, vhost):
+        server = vhost.get_server()
+
+        if server:
+            branch = session.branch()
+            self.page().show_server(branch, server).show_view(branch)
+            
+            return mlink(branch.marshal(), "Server", server.name)
+        else:
+            return none()
+
+    def render_cluster(self, session, vhost):
+        cluster = vhost.get_cluster()
+
+        if cluster:
+            branch = session.branch()
+            self.page().show_cluster(branch, cluster).show_view(branch)
+            
+            return mlink(branch.marshal(), "Cluster", cluster.name)
+        else:
+            return none()
+
     def render_add_queue_href(self, session, vhost):
         branch = session.branch()
         self.page().show_virtual_host(branch, vhost).show_queue_add(branch)

Modified: mgmt/cumin/python/cumin/virtualhost.strings
===================================================================
--- mgmt/cumin/python/cumin/virtualhost.strings	2007-10-09 14:20:22 UTC (rev 975)
+++ mgmt/cumin/python/cumin/virtualhost.strings	2007-10-09 15:36:05 UTC (rev 976)
@@ -18,6 +18,13 @@
 [VirtualHostView.html]
 <div class="oblock">
   <h1>{title}</h1>
+
+  <dl class="properties">
+    <dt>Name</dt><dd>{name}</dd>
+    <dt>Server</dt><dd>{server}</dd>
+    <dt>Cluster</dt><dd>{cluster}</dd>
+  </dl>
+
   <ul class="actions">
     <li><a href="{add_queue_href}">Add Queue</a></li>
     <li><a href="{add_exchange_href}">Add Exchange</a></li>




More information about the rhmessaging-commits mailing list