rabbitmqadmin-cli 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/rabbitmqadmin-cli.rb +25 -17
- data/lib/rabbitmqadmin-cli/version.rb +1 -1
- data/rabbitmqadmin-cli.gemspec +1 -1
- metadata +4 -4
data/lib/rabbitmqadmin-cli.rb
CHANGED
@@ -4,58 +4,61 @@ class RabbitMqAdminCli
|
|
4
4
|
def initialize admin_user = 'guest', admin_password = 'guest'
|
5
5
|
@admin_user = admin_user
|
6
6
|
@admin_password = admin_password
|
7
|
+
@verbose = false
|
7
8
|
end
|
8
9
|
|
10
|
+
attr_accessor :verbose
|
11
|
+
|
9
12
|
def delete_exchanges
|
10
|
-
list_exchanges.each { |exchange|
|
13
|
+
list_exchanges.each { |exchange| execute "#{stub vhost} delete exchange name=#{exchange[:name]}" }
|
11
14
|
end
|
12
15
|
|
13
16
|
def delete_queues
|
14
|
-
list_queues.each { |queue|
|
17
|
+
list_queues.each { |queue| execute "#{stub vhost} delete queue name=#{queue[:name]}" }
|
15
18
|
end
|
16
19
|
|
17
20
|
def initialize_user vhost, user, password, tags = ''
|
18
21
|
raise "Can't initialize the admin user '#{user}' without crippling your access" if user == @admin_user
|
19
22
|
|
20
|
-
|
21
|
-
|
23
|
+
execute "#{stub} delete user name=#{user}" if user_exists? user
|
24
|
+
execute "#{stub} declare user name=#{user} password=#{password} tags=#{tags}"
|
22
25
|
add_user_to_vhost vhost, user
|
23
26
|
end
|
24
27
|
|
25
28
|
def initialize_vhost vhost
|
26
|
-
|
27
|
-
|
29
|
+
execute "#{stub} delete vhost name=#{vhost}" if vhost_exists? vhost
|
30
|
+
execute "#{stub} declare vhost name=#{vhost}"
|
28
31
|
add_user_to_vhost vhost, @admin_user
|
29
32
|
end
|
30
33
|
|
31
|
-
def
|
34
|
+
def stub vhost = nil
|
32
35
|
vhost_arg = vhost.nil? ? '' : "-V #{vhost}"
|
33
36
|
|
34
37
|
"rabbitmqadmin -u #{@admin_user} -p #{@admin_password} -f raw_json #{vhost_arg}"
|
35
38
|
end
|
36
39
|
|
37
40
|
def list_bindings vhost
|
38
|
-
parse
|
41
|
+
parse execute("#{stub vhost} list bindings")
|
39
42
|
end
|
40
43
|
|
41
44
|
def list_exchanges vhost
|
42
|
-
parse
|
45
|
+
parse execute("#{stub vhost} list exchanges")
|
43
46
|
end
|
44
47
|
|
45
48
|
def list_queues vhost
|
46
|
-
parse
|
49
|
+
parse execute("#{stub vhost} list queues")
|
47
50
|
end
|
48
51
|
|
49
52
|
def list_users
|
50
|
-
parse
|
53
|
+
parse execute("#{stub} list users")
|
51
54
|
end
|
52
55
|
|
53
56
|
def list_vhosts
|
54
|
-
parse
|
57
|
+
parse execute("#{stub} list vhosts")
|
55
58
|
end
|
56
59
|
|
57
60
|
def purge_queues
|
58
|
-
list_queues.each { |queue|
|
61
|
+
list_queues.each { |queue| execute "#{stub vhost} purge queue name=#{queue[:name]}" }
|
59
62
|
end
|
60
63
|
|
61
64
|
def user_exists? user
|
@@ -68,11 +71,16 @@ class RabbitMqAdminCli
|
|
68
71
|
|
69
72
|
private
|
70
73
|
|
71
|
-
def
|
72
|
-
|
74
|
+
def add_user_to_vhost vhost, user
|
75
|
+
execute "#{stub} -V #{vhost} declare permission vhost=#{vhost} user=#{user} configure=\"\.\*\" write=\"\.\*\" read=\"\.\*\""
|
73
76
|
end
|
74
77
|
|
75
|
-
def
|
76
|
-
|
78
|
+
def execute command
|
79
|
+
puts command if @verbose
|
80
|
+
`#{command}`
|
81
|
+
end
|
82
|
+
|
83
|
+
def parse json
|
84
|
+
JSON.parse json, :symbolize_names => true
|
77
85
|
end
|
78
86
|
end
|
data/rabbitmqadmin-cli.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'rabbitmqadmin-cli'
|
3
|
-
s.version = '1.0.
|
3
|
+
s.version = '1.0.2'
|
4
4
|
s.platform = RUBY_PLATFORM.to_s == 'java' ? 'java' : Gem::Platform::RUBY
|
5
5
|
s.authors = ['Lee Henson', 'Guy Boertje']
|
6
6
|
s.email = ['lee.m.henson@gmail.com', 'guyboertje@gmail.com']
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rabbitmqadmin-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-10-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: json
|
17
|
-
requirement: &
|
17
|
+
requirement: &70289769797740 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,7 +22,7 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements: *
|
25
|
+
version_requirements: *70289769797740
|
26
26
|
description: Requires rabbitmqadmin to be in your path
|
27
27
|
email:
|
28
28
|
- lee.m.henson@gmail.com
|