Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge heads

  • Loading branch information...
commit f871577dd1a390c197e8a55e5cf88a50895173b2 2 parents 1050fd4 + 11536dd
@simonmacmullen simonmacmullen authored
View
33 bin/rabbitmqadmin
@@ -15,10 +15,14 @@
# The Initial Developer of the Original Code is VMware, Inc.
# Copyright (c) 2010-2012 VMware, Inc. All rights reserved.
+import sys
+if sys.version_info[0] < 2 or sys.version_info[1] < 6:
+ print "Sorry, rabbitmqadmin requires at least Python 2.6."
+ sys.exit(1)
+
from ConfigParser import ConfigParser
from ConfigParser import Error as ConfigParserError
from optparse import OptionParser, TitledHelpFormatter
-import sys
import httplib
import urllib
import base64
@@ -289,7 +293,7 @@ def make_configuration():
try:
config.read(options.config)
new_conf = dict(config.items(options.node))
- except ConfigParserError as error:
+ except ConfigParserError, error:
assert_usage(False, ("Could not read section '%s' in config file" +
" '%s':\n %s") %
(options.node, options.config, error))
@@ -378,7 +382,7 @@ class Management:
headers["Content-Type"] = "application/json"
try:
conn.request(method, "/api%s" % path, body, headers)
- except socket.error as e:
+ except socket.error, e:
die("Could not connect: {0}".format(e))
resp = conn.getresponse()
if resp.status == 400:
@@ -443,15 +447,17 @@ class Management:
def invoke_export(self):
path = self.get_arg()
definitions = self.get("/definitions")
- with open(path, 'w') as f:
- f.write(definitions)
+ f = open(path, 'w')
+ f.write(definitions)
+ f.close()
self.verbose("Exported definitions for %s to \"%s\""
% (self.options.hostname, path))
def invoke_import(self):
path = self.get_arg()
- with open(path, 'r') as f:
- definitions = f.read()
+ f = open(path, 'r')
+ definitions = f.read()
+ f.close()
self.post("/definitions", definitions)
self.verbose("Imported definitions for %s from \"%s\""
% (self.options.hostname, path))
@@ -735,12 +741,13 @@ def write_payload_file(payload_file, json_list):
result = json.loads(json_list)[0]
payload = result['payload']
payload_encoding = result['payload_encoding']
- with open(payload_file, 'w') as f:
- if payload_encoding == 'base64':
- data = base64.b64decode(payload)
- else:
- data = payload
- f.write(data)
+ f = open(payload_file, 'w')
+ if payload_encoding == 'base64':
+ data = base64.b64decode(payload)
+ else:
+ data = payload
+ f.write(data)
+ f.close()
def print_bash_completion():
script = """# This is a bash completion script for rabbitmqadmin.
View
3  priv/www/css/main.css
@@ -115,6 +115,7 @@ table.form select { width: 200px; }
table.form select.narrow { width: 110px; }
table.form .multifield { margin: 0; padding: 0; }
table.form .multifield p { margin: 0; padding: 0; }
+table.form .multifield p select { width: 70px; }
table.form label { margin-top: 5px; display: block; }
table.two-col-layout { width: 100%; }
@@ -148,6 +149,8 @@ acronym.warning { background: #daa; }
.status acronym, small acronym { background: none; color: inherit; padding: 0; border-bottom: 1px dotted; cursor: default; }
+acronym.type { background: none; color: inherit; padding: 0; border-bottom: 1px dotted #ddd; cursor: default; }
+
table.bindings { margin-bottom: 1em; }
td.binding-endpoint span.object { border: 1px solid #bbb; padding: 10px; border-radius: 10px; -moz-border-radius: 10px; }
td.binding-endpoint span.arrow { font-size: 200%; }
View
2  priv/www/index.html
@@ -52,7 +52,7 @@
<option value="300000">every 5 minutes</option>
<option value="">never</option>
</select>
- </p>
+ </div>
</div>
<div id="status"></div>
<div id="debug"></div>
View
26 priv/www/js/formatters.js
@@ -42,6 +42,11 @@ function fmt_date(d) {
":" + f(d.getSeconds());
}
+function fmt_time(t, suffix) {
+ if (t == undefined || t == 0) return '';
+ return t + suffix;
+}
+
function fmt_parameters(obj) {
return fmt_table_short(args_to_params(obj));
}
@@ -256,10 +261,14 @@ function fmt_amqp_value(val) {
return val2.join("<br/>");
} else if (val instanceof Object) {
return fmt_table_short(val);
- } else if (typeof(val) == 'string') {
- return fmt_escape_html(val);
} else {
- return val;
+ var t = typeof(val);
+ if (t == 'string') {
+ return '<acronym class="type" title="string">' +
+ fmt_escape_html(val) + '</acronym>';
+ } else {
+ return '<acronym class="type" title="' + t + '">' + val + '</acronym>';
+ }
}
}
@@ -403,6 +412,17 @@ function fmt_connection_state(conn) {
}
}
+function fmt_shortened_uri(uri0) {
+ var uri = fmt_escape_html(uri0);
+ if (uri.indexOf('?') == -1) {
+ return uri;
+ }
+ else {
+ return '<acronym title="' + uri + '">' +
+ uri.substr(0, uri.indexOf('?')) + '?...</acronym>';
+ }
+}
+
function alt_rows(i) {
return (i % 2 == 0) ? ' class="alt1"' : ' class="alt2"';
}
View
40 priv/www/js/main.js
@@ -331,12 +331,23 @@ function update_multifields() {
}
});
if (!empty_found) {
- $(this).append('<p><input type="text" name="' + name + '_' +
- (largest_id + 1) +
+ var prefix = name + '_' + (largest_id + 1);
+ var type_part;
+ if ($(this).hasClass('string-only')) {
+ type_part = '<input type="hidden" name="' + prefix +
+ '_mftype" value="string"/>';
+ } else {
+ type_part = '<select name="' + prefix +
+ '_mftype">' +
+ '<option value="string">String</option>' +
+ '<option value="number">Number</option>' +
+ '<option value="boolean">Boolean</option>' +
+ '</select>';
+ }
+ $(this).append('<p><input type="text" name="' + prefix +
'_mfkey" value=""/> = ' +
- '<input type="text" name="' + name + '_' +
- (largest_id + 1) +
- '_mfvalue" value=""/></p>');
+ '<input type="text" name="' + prefix +
+ '_mfvalue" value=""/> ' + type_part + '</p>');
}
});
}
@@ -598,7 +609,8 @@ function collapse_multifields(params0) {
for (key in params0) {
var match = key.match(/([a-z]*)_([0-9]*)_mfkey/);
var match2 = key.match(/[a-z]*_[0-9]*_mfvalue/);
- if (match == null && match2 == null) {
+ var match3 = key.match(/[a-z]*_[0-9]*_mftype/);
+ if (match == null && match2 == null && match3 == null) {
params[key] = params0[key];
}
else if (match == null) {
@@ -613,7 +625,21 @@ function collapse_multifields(params0) {
if (params0[key] != "") {
var k = params0[key];
var v = params0[name + '_' + id + '_mfvalue'];
- params[name][k] = v;
+ var t = params0[name + '_' + id + '_mftype'];
+ if (t == 'boolean') {
+ if (v != 'true' && v != 'false')
+ throw(k + ' must be "true" or "false"; got ' + v);
+ params[name][k] = (v == 'true');
+ }
+ else if (t == 'number') {
+ var n = parseFloat(v);
+ if (isNaN(n))
+ throw(k + ' must be a number; got ' + v);
+ params[name][k] = n;
+ }
+ else {
+ params[name][k] = v;
+ }
}
}
}
View
2  priv/www/js/tmpl/connection.ejs
@@ -70,7 +70,7 @@
</tr>
<tr>
<th>Timeout</th>
- <td><% if (connection.timeout != 0) { %><%= connection.timeout %>s<% } %></td>
+ <td><%= fmt_time(connection.timeout, 's') %></td>
</tr>
<tr>
<th>Frame max</th>
View
2  priv/www/js/tmpl/connections.ejs
@@ -43,7 +43,7 @@
<% } %>
<td><%= fmt_rate_bytes(connection, 'recv_oct') %></td>
<td><%= fmt_rate_bytes(connection, 'send_oct') %></td>
- <td><% if (connection.timeout != undefined) { %><%= connection.timeout %>s<% } %></td>
+ <td><%= fmt_time(connection.timeout, 's') %></td>
<td><%= connection.channels %></td>
<% if (vhosts_interesting) { %>
<td><%= fmt_string(connection.vhost) %></td>
View
2  priv/www/js/tmpl/publish.ejs
@@ -49,7 +49,7 @@
</label>
</th>
<td>
- <span class="multifield" id="props"></span>
+ <span class="multifield string-only" id="props"></span>
</td>
</tr>
<tr>
View
15 src/rabbit_mgmt_format.erl
@@ -240,12 +240,15 @@ to_amqp_table_row(K, V) ->
to_amqp_array(L) ->
[type_val(I) || I <- L].
-type_val({struct, M}) -> {table, to_amqp_table(M)};
-type_val(L) when is_list(L) -> {array, to_amqp_array(L)};
-type_val(X) when is_binary(X) -> {longstr, X};
-type_val(X) when is_number(X) -> {long, X};
-type_val(null) -> throw({error, null_not_allowed});
-type_val(X) -> throw({error, {unhandled_type, X}}).
+type_val({struct, M}) -> {table, to_amqp_table(M)};
+type_val(L) when is_list(L) -> {array, to_amqp_array(L)};
+type_val(X) when is_binary(X) -> {longstr, X};
+type_val(X) when is_integer(X) -> {long, X};
+type_val(X) when is_number(X) -> {double, X};
+type_val(true) -> {bool, true};
+type_val(false) -> {bool, false};
+type_val(null) -> throw({error, null_not_allowed});
+type_val(X) -> throw({error, {unhandled_type, X}}).
url(Fmt, Vals) ->
print(Fmt, [mochiweb_util:quote_plus(V) || V <- Vals]).
View
8 src/rabbit_mgmt_wm_nodes.erl
@@ -44,9 +44,5 @@ all_nodes() ->
Types = proplists:get_keys(Nodes),
Running = proplists:get_value(running_nodes, S),
rabbit_mgmt_db:augment_nodes(
- lists:append(
- [[make_entry(Node, Type, lists:member(Node, Running))
- || Node <- proplists:get_value(Type, Nodes)] || Type <- Types])).
-
-make_entry(Node, Type, Running) ->
- [{name, Node}, {type, Type}, {running, Running}].
+ [[{name, Node}, {type, Type}, {running, lists:member(Node, Running)}] ||
+ Type <- Types, Node <- proplists:get_value(Type, Nodes)]).
View
9 test/src/rabbit_mgmt_test_all.erl
@@ -20,7 +20,7 @@
all_tests() ->
ok = eunit:test(rabbit_mgmt_test_unit,[verbose]),
- ok = eunit:test(rabbit_mgmt_test_http,[verbose]),
+ ok = eunit:test(tests(rabbit_mgmt_test_http, 60), [verbose]),
io:format("Starting second node...~n"),
ok = rabbit_mgmt_test_clustering:start_second_node(),
io:format("...done.~n"),
@@ -30,3 +30,10 @@ all_tests() ->
ok = rabbit_mgmt_test_clustering:stop_second_node()
end,
ok = rabbit_mgmt_test_db:test().
+
+
+tests(Module, Timeout) ->
+ {foreach, fun() -> ok end,
+ [{timeout, Timeout, fun Module:F/0} ||
+ {F, _Arity} <- proplists:get_value(exports, Module:module_info()),
+ string:right(atom_to_list(F), 5) =:= "_test"]}.
Please sign in to comment.
Something went wrong with that request. Please try again.