浏览代码

[zookeeper] Allow multi custers

Romain Rigaux 12 年之前
父节点
当前提交
e390919

+ 3 - 3
apps/zookeeper/src/zookeeper/templates/index.mako

@@ -32,11 +32,11 @@ ${ commonheader(_('View'), app_name, user, '60px') | n,unicode }
 
 ${ shared.header(_breadcrumbs, clusters) }
 
-% for i, c in enumerate(clusters):
+% for c in clusters:
   <h3 class="card-heading simple simpler">${ _('Cluster') } ${ c }</h3>
   <p>
     </br>
-    &nbsp;&nbsp;<a href="${ url('zookeeper:view', id=i) }">${ _("Znode Hierarchy") }</a> 
+    &nbsp;&nbsp;<a href="${ url('zookeeper:view', id=c) }">${ _("Znode Hierarchy") }</a> 
   </p>
   <table class="table">
     <thead>
@@ -51,7 +51,7 @@ ${ shared.header(_breadcrumbs, clusters) }
     <tbody>
     % for host, stats in overview[c].items():
       <tr>
-        <td><a href="${ url('zookeeper:clients', id=i, host=host) }" data-row-selector="true">${ host }</a></td>
+        <td><a href="${ url('zookeeper:clients', id=c, host=host) }" data-row-selector="true">${ host }</a></td>
         <td>${stats.get('zk_server_state', '')}</td>
         <td>${stats.get('zk_avg_latency', '')}</td>
         <td>${stats.get('zk_watch_count', '')}</td>

+ 2 - 2
apps/zookeeper/src/zookeeper/templates/shared_components.mako

@@ -30,9 +30,9 @@
             <span class="caret"></span>
           </a>
           <ul class="dropdown-menu">
-            % for id, c in enumerate(clusters):
+            % for c in clusters:
               <li>
-                <a href="${ url('zookeeper:view', id=id) }">
+                <a href="${ url('zookeeper:view', id=c) }">
                   ${ c }
                 </a>
               </li>

+ 8 - 8
apps/zookeeper/src/zookeeper/templates/tree.mako

@@ -59,8 +59,8 @@ ${ shared.header(_breadcrumbs, clusters, False) }
   <div class="span9">
     <ul class="nav nav-tabs">
       %if znode.get('dataLength', 0) != 0:
-        <li class="active"><a href="#base64" data-toggle="tab">Base64 (${znode.get('dataLength', 0)})</a></li>
-        <li><a href="#text" data-toggle="tab">${ _('Text') }</a></li>
+        <li class="active"><a href="#text" data-toggle="tab">${ _('Text') }</a></li>
+        <li><a href="#base64" data-toggle="tab">${ _('Base64') } (${ znode.get('dataLength', 0) })</a></li>        
         <li><a href="#stats" data-toggle="tab">${ _('Stats') }</a></li>
       %else:
         <li><a href="#stats" data-toggle="tab">${ _('Stats') }</a></li>
@@ -68,13 +68,13 @@ ${ shared.header(_breadcrumbs, clusters, False) }
     </ul>
     <div class="tab-content">
       %if znode.get('dataLength', 0) != 0:
-      <div class="tab-pane active" id="base64">
-        <textarea id="textarea64" rows="14" readonly="readonly">${znode.get('data64', '')}</textarea>
-        <a href="${url('zookeeper:edit_as_base64', id=cluster['id'], path=path)}" class="btn"><i class="icon-pencil"></i> ${_('Edit as Base64')}</a>
-      </div>
-      <div class="tab-pane" id="text">
-        <textarea id="textareaText" rows="14" readonly="readonly"></textarea>
+      <div class="tab-pane active" id="text">
+        <textarea id="textareaText" rows="25" readonly="readonly"></textarea>
         <a href="${url('zookeeper:edit_as_text', id=cluster['id'], path=path)}" class="btn"><i class="icon-pencil"></i> ${_('Edit as Text')}</a>
+      </div>      
+      <div class="tab-pane" id="base64">
+        <textarea id="textarea64" rows="25" readonly="readonly">${znode.get('data64', '')}</textarea>
+        <a href="${url('zookeeper:edit_as_base64', id=cluster['id'], path=path)}" class="btn"><i class="icon-pencil"></i> ${_('Edit as Base64')}</a>
       </div>
       <div class="tab-pane" id="stats">
       %else:

+ 7 - 7
apps/zookeeper/src/zookeeper/urls.py

@@ -20,11 +20,11 @@ from django.conf.urls.defaults import patterns, url
 
 urlpatterns = patterns('zookeeper.views',
   url(r'^$', 'index', name='index'),
-  url(r'view/(?P<id>\d+)$', 'view', name='view'),
-  url(r'clients/(?P<id>\d+)/(?P<host>.+)$', 'clients', name='clients'),
-  url(r'tree/(?P<id>\d+)(?P<path>.+)$', 'tree', name='tree'),
-  url(r'create/(?P<id>\d+)(?P<path>.*)$', 'create', name='create'),
-  url(r'delete/(?P<id>\d+)(?P<path>.*)$', 'delete', name='delete'),
-  url(r'edit/base64/(?P<id>\d+)(?P<path>.*)$', 'edit_as_base64', name='edit_as_base64'),
-  url(r'edit/text/(?P<id>\d+)(?P<path>.*)$', 'edit_as_text', name='edit_as_text'),
+  url(r'view/(?P<id>\w+)$', 'view', name='view'),
+  url(r'clients/(?P<id>\w+)/(?P<host>.+)$', 'clients', name='clients'),
+  url(r'tree/(?P<id>\w+)/(?P<path>.+)$', 'tree', name='tree'),
+  url(r'create/(?P<id>\w+)/(?P<path>.*)$', 'create', name='create'),
+  url(r'delete/(?P<id>\w+)/(?P<path>.*)$', 'delete', name='delete'),
+  url(r'edit/base64/(?P<id>\w+)/(?P<path>.*)$', 'edit_as_base64', name='edit_as_base64'),
+  url(r'edit/text/(?P<id>\w+)/(?P<path>.*)$', 'edit_as_text', name='edit_as_text'),
 )

+ 3 - 8
apps/zookeeper/src/zookeeper/utils.py

@@ -22,19 +22,14 @@ from zookeeper.conf import CLUSTERS
 
 def get_cluster_or_404(id):
   try:
-    id = int(id)
-    if not (0 <= id < len(CLUSTERS.get())):
-      raise ValueError, 'Undefined cluster id.'
+    name = id
+    cluster = CLUSTERS.get()[name]
   except (TypeError, ValueError):
     raise Http404()
 
-  # Support only one cluster
-  name = [k for (k, v) in CLUSTERS.get().iteritems() if v == 0]
-  cluster = CLUSTERS.get()[k]
-
   cluster = {
     'id': id,
-    'nice_name': k,
+    'nice_name': id,
     'host_ports': cluster.HOST_PORTS.get(),
     'rest_url': cluster.REST_URL.get(),
   }

+ 0 - 0
apps/zookeeper/src/zookeeper/static/art/icon_24.png → apps/zookeeper/static/art/icon_24.png


+ 0 - 0
apps/zookeeper/src/zookeeper/static/art/line_icons.png → apps/zookeeper/static/art/line_icons.png


+ 0 - 0
apps/zookeeper/src/zookeeper/static/css/zookeeper.css → apps/zookeeper/static/css/zookeeper.css


+ 0 - 0
apps/zookeeper/src/zookeeper/static/help/index.html → apps/zookeeper/static/help/index.html


+ 0 - 0
apps/zookeeper/src/zookeeper/static/js/base64.js → apps/zookeeper/static/js/base64.js


+ 1 - 1
desktop/conf.dist/hue.ini

@@ -524,7 +524,7 @@
       # e.g. localhost:2181,localhost:2182,localhost:2183
       ## host_ports=localhost:2181
 
-      # The URL of the REST contrib service
+      # The URL of the REST contrib service (required for znode browsing)
       ## rest_url=http://localhost:9998
 
 

+ 1 - 1
desktop/conf/pseudo-distributed.ini.tmpl

@@ -528,7 +528,7 @@
       # e.g. localhost:2181,localhost:2182,localhost:2183
       ## host_ports=localhost:2181
 
-      # The URL of the REST contrib service
+      # The URL of the REST contrib service (required for znode browsing)
       ## rest_url=http://localhost:9998