estool 0.1.1 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/estool +32 -2
- data/lib/estool.rb +2 -11
- data/lib/estool/actions/cat.rb +7 -9
- data/lib/estool/actions/index.rb +4 -4
- data/lib/estool/cli.rb +5 -0
- data/lib/estool/cli/aliases.rb +33 -0
- data/lib/estool/cli/health.rb +24 -0
- data/lib/estool/cli/index.rb +92 -0
- data/lib/estool/version.rb +1 -1
- metadata +11 -7
- data/lib/estool/cat.rb +0 -134
- data/lib/estool/index.rb +0 -37
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3770df1f149ae9be6d2638a703144645c1fd2ef
|
4
|
+
data.tar.gz: de5b0a2dacadfb14b308a35e2ed0f90179f1e4ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4b21640caf7ca35ef97093afcd2c7a54c5de6b314912ffe99a95429bba797b55a3cab49b0f093cb928ed23453711176b59eec171e454cce7f467579fa89c636
|
7
|
+
data.tar.gz: 0f9e53f32d55b39ca70f02423ec26e13b8f67d79d9f490a6a38d8155621d789ce03aa2ae27755013dbd1bdb89b0745aa3a075a12dc581c4259ef9e1eeba72dbc
|
data/bin/estool
CHANGED
@@ -1,5 +1,35 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
require 'gli'
|
2
3
|
require 'estool'
|
3
4
|
|
4
|
-
|
5
|
-
|
5
|
+
module Estool
|
6
|
+
module Cli
|
7
|
+
include GLI::App
|
8
|
+
extend self
|
9
|
+
|
10
|
+
program_desc 'Command line tool for interacting with Elasticsearch'
|
11
|
+
|
12
|
+
version Estool::VERSION
|
13
|
+
|
14
|
+
subcommand_option_handling :normal
|
15
|
+
arguments :strict
|
16
|
+
|
17
|
+
# global Options
|
18
|
+
desc 'Elasticsearch Host'
|
19
|
+
arg_name 'HOST'
|
20
|
+
default_value '127.0.0.1'
|
21
|
+
flag [:h, :host]
|
22
|
+
|
23
|
+
desc 'Elasticsearch REST Port'
|
24
|
+
arg_name 'PORT'
|
25
|
+
default_value '9200'
|
26
|
+
flag [:p, :port]
|
27
|
+
|
28
|
+
desc 'Show verbose output'
|
29
|
+
switch [:v, :verbose], negatable: false
|
30
|
+
|
31
|
+
require 'estool/cli'
|
32
|
+
|
33
|
+
exit run(ARGV)
|
34
|
+
end
|
35
|
+
end
|
data/lib/estool.rb
CHANGED
@@ -1,11 +1,2 @@
|
|
1
|
-
|
2
|
-
require 'estool/
|
3
|
-
require 'estool/index'
|
4
|
-
require 'thor'
|
5
|
-
|
6
|
-
module Estool
|
7
|
-
class Cli < Thor
|
8
|
-
register(Estool::Cat, 'cat', 'cat [SUBCOMMAND] [OPTIONS]', 'Display health and status information about the cluster', )
|
9
|
-
register(Estool::Index, 'index', 'index [SUBCOMMAND] [OPTIONS]', 'Manage cluster indices', )
|
10
|
-
end
|
11
|
-
end
|
1
|
+
require 'estool/version'
|
2
|
+
#require 'estool/cli'
|
data/lib/estool/actions/cat.rb
CHANGED
@@ -15,17 +15,15 @@ module Estool::Actions
|
|
15
15
|
params = {}
|
16
16
|
data.each do |k, v|
|
17
17
|
case k
|
18
|
-
|
18
|
+
when :verbose
|
19
19
|
params.merge!(v: v)
|
20
|
-
when
|
20
|
+
when :output
|
21
21
|
params.merge!(format: v)
|
22
|
-
when
|
23
|
-
params.merge!(master_timeout: v)
|
24
|
-
when 'name'
|
22
|
+
when :name
|
25
23
|
params.merge!(name: v)
|
26
|
-
when
|
24
|
+
when :node
|
27
25
|
params.merge!(node_id: v)
|
28
|
-
when
|
26
|
+
when :primary
|
29
27
|
params.merge!(pri: v)
|
30
28
|
else
|
31
29
|
params.merge!("#{k}": v)
|
@@ -42,7 +40,7 @@ module Estool::Actions
|
|
42
40
|
rescue ArgumentError => args
|
43
41
|
puts "
|
44
42
|
#{args}
|
45
|
-
Usage: 'estool
|
43
|
+
Usage: 'estool help #{action}' for more information
|
46
44
|
"
|
47
45
|
exit 1
|
48
46
|
end
|
@@ -53,4 +51,4 @@ module Estool::Actions
|
|
53
51
|
cat(@cmd, params, @server)
|
54
52
|
end
|
55
53
|
end
|
56
|
-
end
|
54
|
+
end
|
data/lib/estool/actions/index.rb
CHANGED
@@ -15,11 +15,11 @@ module Estool::Actions
|
|
15
15
|
params = {}
|
16
16
|
data.each do |k, v|
|
17
17
|
case k
|
18
|
-
|
18
|
+
when :name
|
19
19
|
params.merge!(index: v)
|
20
|
-
when
|
20
|
+
when :update
|
21
21
|
params.merge!(update_all_types: v)
|
22
|
-
when
|
22
|
+
when :wait
|
23
23
|
params.merge!(wait_for_active_shards: v)
|
24
24
|
else
|
25
25
|
params.merge!("#{k}": v)
|
@@ -47,4 +47,4 @@ module Estool::Actions
|
|
47
47
|
index(@cmd, params, @server)
|
48
48
|
end
|
49
49
|
end
|
50
|
-
end
|
50
|
+
end
|
data/lib/estool/cli.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'estool/actions/index'
|
2
|
+
|
3
|
+
module Estool
|
4
|
+
module Cli
|
5
|
+
desc 'Interact with Elasticsearch Index Aliases'
|
6
|
+
command :aliases do |c|
|
7
|
+
|
8
|
+
c.desc 'Get a list of aliases'
|
9
|
+
c.long_desc %{
|
10
|
+
Get a list of all aliases or a list of aliases for a specific index.
|
11
|
+
}
|
12
|
+
c.command [:list, :ls] do |ls|
|
13
|
+
|
14
|
+
ls.flag 'name', :arg_name => 'alias name(s)',
|
15
|
+
:desc => 'Comma separated list of aliases to get information about'
|
16
|
+
|
17
|
+
ls.flag [:index, :i], :arg_name => 'index name(s)',
|
18
|
+
:desc => 'Comma separated list of index names'
|
19
|
+
|
20
|
+
ls.action do |global_options,options,args|
|
21
|
+
options = {
|
22
|
+
host: global_options[:host],
|
23
|
+
port: global_options[:port],
|
24
|
+
name: options[:name],
|
25
|
+
index: options[:index]
|
26
|
+
}
|
27
|
+
ls_alias = Estool::Actions::Index.new('get_aliases', options)
|
28
|
+
ls_alias.run
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'estool/actions/cat'
|
2
|
+
|
3
|
+
module Estool
|
4
|
+
module Cli
|
5
|
+
desc 'Get Cluster Health'
|
6
|
+
command :health do |c|
|
7
|
+
|
8
|
+
c.flag 'output', :default_value => 'text',
|
9
|
+
:arg_name => 'output_type',
|
10
|
+
:desc => 'Output Health status as text or json'
|
11
|
+
|
12
|
+
c.action do |global_options,options,args|
|
13
|
+
options = {
|
14
|
+
host: global_options[:host],
|
15
|
+
port: global_options[:port],
|
16
|
+
verbose: global_options[:verbose],
|
17
|
+
output: options[:output]
|
18
|
+
}
|
19
|
+
health = Estool::Actions::Cat.new('health', options)
|
20
|
+
health.run
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'estool/actions/cat'
|
2
|
+
require 'estool/actions/index'
|
3
|
+
|
4
|
+
module Estool
|
5
|
+
module Cli
|
6
|
+
desc 'Interact with Cluster Indices'
|
7
|
+
arg_name 'subcommand'
|
8
|
+
command :index do |c|
|
9
|
+
|
10
|
+
c.desc 'Create a new index'
|
11
|
+
c.command :create do |create|
|
12
|
+
create.flag 'name', :required => true,
|
13
|
+
:arg_name => 'index_name',
|
14
|
+
:desc => 'Name of the index to create'
|
15
|
+
|
16
|
+
create.flag 'update', :default_value => false,
|
17
|
+
:desc => 'Update the mapping for all fields with
|
18
|
+
same name across all types.'
|
19
|
+
|
20
|
+
create.flag 'wait', :default_value => 0,
|
21
|
+
:desc => 'Wait until specified number of shards is active'
|
22
|
+
|
23
|
+
create.action do |global_options,options,args|
|
24
|
+
options = {
|
25
|
+
host: global_options[:host],
|
26
|
+
port: global_options[:port],
|
27
|
+
name: options[:name],
|
28
|
+
update: options[:update],
|
29
|
+
wait: options[:wait]
|
30
|
+
}
|
31
|
+
create = Estool::Actions::Index.new('create', options)
|
32
|
+
create.run
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
c.desc 'Delete Index or Indices'
|
37
|
+
c.command :delete do |delete|
|
38
|
+
delete.flag 'name', :required => true,
|
39
|
+
:arg_name => 'index_name',
|
40
|
+
:desc => 'Name of the index to delete'
|
41
|
+
|
42
|
+
|
43
|
+
delete.action do |global_options,options,args|
|
44
|
+
options = {
|
45
|
+
host: global_options[:host],
|
46
|
+
port: global_options[:port],
|
47
|
+
name: options[:name]
|
48
|
+
}
|
49
|
+
delete = Estool::Actions::Index.new('delete', options)
|
50
|
+
delete.run
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
c.desc 'List indices'
|
55
|
+
c.command :show do |show|
|
56
|
+
show.action do |global_options,options,args|
|
57
|
+
options = {
|
58
|
+
host: global_options[:host],
|
59
|
+
port: global_options[:port],
|
60
|
+
verbose: global_options[:verbose]
|
61
|
+
}
|
62
|
+
show = Estool::Actions::Cat.new('indices', options)
|
63
|
+
show.run
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
c.desc 'Close index'
|
68
|
+
c.command :close do |close|
|
69
|
+
close.switch 'ignore_unavailable', :default_value => false,
|
70
|
+
:desc => 'Ignore indices if unavailable.',
|
71
|
+
:negatable => false
|
72
|
+
|
73
|
+
close.flag 'name', :required => true,
|
74
|
+
:arg_name => 'index_name',
|
75
|
+
:desc => 'name of index to close'
|
76
|
+
|
77
|
+
close.action do |global_options,options,args|
|
78
|
+
options = {
|
79
|
+
host: global_options[:host],
|
80
|
+
port: global_options[:port],
|
81
|
+
ignore_unavailable: options[:ignore_unavailable],
|
82
|
+
name: options[:name]
|
83
|
+
}
|
84
|
+
close = Estool::Actions::Index.new('close', options)
|
85
|
+
close.run
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
c.default_command :show
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
data/lib/estool/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: estool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Hollinger III
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: elasticsearch
|
@@ -78,9 +78,11 @@ files:
|
|
78
78
|
- lib/estool.rb
|
79
79
|
- lib/estool/actions/cat.rb
|
80
80
|
- lib/estool/actions/index.rb
|
81
|
-
- lib/estool/
|
81
|
+
- lib/estool/cli.rb
|
82
|
+
- lib/estool/cli/aliases.rb
|
83
|
+
- lib/estool/cli/health.rb
|
84
|
+
- lib/estool/cli/index.rb
|
82
85
|
- lib/estool/connections.rb
|
83
|
-
- lib/estool/index.rb
|
84
86
|
- lib/estool/version.rb
|
85
87
|
homepage: https://github.com/dhollinger/estool
|
86
88
|
licenses:
|
@@ -102,9 +104,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
104
|
version: '0'
|
103
105
|
requirements: []
|
104
106
|
rubyforge_project:
|
105
|
-
rubygems_version: 2.4.5.
|
107
|
+
rubygems_version: 2.4.5.2
|
106
108
|
signing_key:
|
107
109
|
specification_version: 4
|
108
|
-
summary: Command Line tool for interacting with Elasticsearch. Still in Development,
|
109
|
-
expect bugs and fast releases until 1.0.0
|
110
|
+
summary: 'Command Line tool for interacting with Elasticsearch. Still in Development,
|
111
|
+
expect bugs and fast releases until 1.0.0. NOTE: version 0.2.0 involves a complete
|
112
|
+
CLI rewrite. Some options have not been reimplemented, others have changed, and
|
113
|
+
a new command implemented'
|
110
114
|
test_files: []
|
data/lib/estool/cat.rb
DELETED
@@ -1,134 +0,0 @@
|
|
1
|
-
require 'thor'
|
2
|
-
require 'estool/actions/cat'
|
3
|
-
|
4
|
-
module Estool
|
5
|
-
class Cat < Thor
|
6
|
-
class_option 'host', :type => :string,
|
7
|
-
:banner => 'Elasticsearch host to connect to',
|
8
|
-
:default => 'localhost',
|
9
|
-
:aliases => '-H'
|
10
|
-
class_option 'port', :type => :string,
|
11
|
-
:banner => 'Port to use when connecting to Elasticsearch',
|
12
|
-
:default => '9200',
|
13
|
-
:aliases => '-p'
|
14
|
-
class_option 'verbose', :type => :boolean,
|
15
|
-
:banner => 'Verbose option. Not all subcommands support it',
|
16
|
-
:default => false,
|
17
|
-
:aliases => '-v'
|
18
|
-
class_option 'output', :type => :string,
|
19
|
-
:banner => 'Display output as json or text',
|
20
|
-
:default => 'text',
|
21
|
-
:aliases => '-o'
|
22
|
-
# class_option 'timeout', :type => :numeric,
|
23
|
-
# :banner => 'Set Master Timeout in seconds',
|
24
|
-
# :default => 30,
|
25
|
-
# :aliases => '-t'
|
26
|
-
|
27
|
-
desc 'aliases [OPTIONS]', 'Display information about aliases'
|
28
|
-
method_option 'name', :type => :string,
|
29
|
-
:banner => 'Name of alias(es) to display information about',
|
30
|
-
:aliases => '-n'
|
31
|
-
def aliases
|
32
|
-
Estool::Actions::Cat.new(:aliases, options).run
|
33
|
-
end
|
34
|
-
|
35
|
-
desc 'allocation [OPTIONS]', 'Display shard allocation information'
|
36
|
-
method_option 'node', :type => :array,
|
37
|
-
:banner => 'Comma separated list of nodes',
|
38
|
-
:aliases => '-n'
|
39
|
-
method_option 'bytes', :type => :string,
|
40
|
-
:banner => 'Unit to display byte values in.',
|
41
|
-
:default => 'b',
|
42
|
-
:enum => %w{b k m g},
|
43
|
-
:aliases => '-b'
|
44
|
-
def allocation
|
45
|
-
Estool::Actions::Cat.new(:allocation, options).run
|
46
|
-
end
|
47
|
-
|
48
|
-
desc 'count [OPTIONS]', 'Return Document count for cluster or indices'
|
49
|
-
method_option 'index', :type => :string,
|
50
|
-
:banner => 'Index to count documents',
|
51
|
-
:aliases => '-i'
|
52
|
-
def count
|
53
|
-
Estool::Actions::Cat.new(:count, options).run
|
54
|
-
end
|
55
|
-
|
56
|
-
desc 'fielddata [OPTIONS]', 'Return field data usage data'
|
57
|
-
method_option 'fields', :type => :string,
|
58
|
-
:banner => 'Comma separated list of fields',
|
59
|
-
:aliases => '-f'
|
60
|
-
method_option 'bytes', :type => :string,
|
61
|
-
:banner => 'Unit to display byte values in.',
|
62
|
-
:default => 'b',
|
63
|
-
:enum => %w{b k m g},
|
64
|
-
:aliases => '-b'
|
65
|
-
def fielddata
|
66
|
-
Estool::Actions::Cat.new(:fielddata, options).run
|
67
|
-
end
|
68
|
-
|
69
|
-
desc 'health [OPTIONS]', 'Display Elasticsearch Cluster health'
|
70
|
-
def health
|
71
|
-
Estool::Actions::Cat.new(:health, options).run
|
72
|
-
end
|
73
|
-
|
74
|
-
desc 'indices [OPTIONS]', 'Display indices statistics across the cluster'
|
75
|
-
method_option 'index', :type => :string,
|
76
|
-
:banner => 'Comma separated list of index names to display',
|
77
|
-
:aliases => '-i'
|
78
|
-
method_option 'primary', :type => :boolean,
|
79
|
-
:banner => 'Limit returned information to primary shards only',
|
80
|
-
:aliases => '-P',
|
81
|
-
:default => false
|
82
|
-
method_option 'bytes', :type => :string,
|
83
|
-
:banner => 'Unit to display byte values in.',
|
84
|
-
:default => 'b',
|
85
|
-
:enum => %w{b k m g},
|
86
|
-
:aliases => '-b'
|
87
|
-
def indices
|
88
|
-
Estool::Actions::Cat.new(:indices, options).run
|
89
|
-
end
|
90
|
-
|
91
|
-
desc 'master [OPTIONS]', 'Display current master node'
|
92
|
-
def master
|
93
|
-
Estool::Actions::Cat.new(:master, options).run
|
94
|
-
end
|
95
|
-
|
96
|
-
desc 'nodeattrs [OPTIONS]', 'Display custom node attributes'
|
97
|
-
def nodeattrs
|
98
|
-
Estool::Actions::Cat.new(:nodeattrs, options).run
|
99
|
-
end
|
100
|
-
|
101
|
-
desc 'nodes [OPTIONS]', 'Display Elasticsearch Nodes'
|
102
|
-
def nodes
|
103
|
-
Estool::Actions::Cat.new(:nodes, options).run
|
104
|
-
end
|
105
|
-
|
106
|
-
desc 'ptasks [OPTIONS]', 'Display Elasticsearch Pending Task in tabular format'
|
107
|
-
def ptasks
|
108
|
-
Estool::Actions::Cat.new(:pending_tasks, options).run
|
109
|
-
end
|
110
|
-
|
111
|
-
desc 'plugins [OPTIONS]', 'Display Elasticsearch Plugins'
|
112
|
-
def plugins
|
113
|
-
Estool::Actions::Cat.new(:plugins, options).run
|
114
|
-
end
|
115
|
-
|
116
|
-
desc 'recovery [OPTIONS]', 'Display shard recovery status'
|
117
|
-
method_option 'index', :type => :string,
|
118
|
-
:banner => 'List of indexes to return information about. Comma-separated',
|
119
|
-
:aliases => '-i'
|
120
|
-
method_option 'bytes', :type => :string,
|
121
|
-
:banner => 'Unit to display byte values in.',
|
122
|
-
:default => 'b',
|
123
|
-
:enum => %w{b k m g},
|
124
|
-
:aliases => '-b'
|
125
|
-
def recovery
|
126
|
-
Estool::Actions::Cat.new(:recovery, options).run
|
127
|
-
end
|
128
|
-
|
129
|
-
desc 'repositories [OPTIONS]', 'Display registered repositories'
|
130
|
-
def repositories
|
131
|
-
Estool::Actions::Cat.new(:repositories, options).run
|
132
|
-
end
|
133
|
-
end
|
134
|
-
end
|
data/lib/estool/index.rb
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'thor'
|
2
|
-
require 'estool/actions/index'
|
3
|
-
|
4
|
-
module Estool
|
5
|
-
class Index < Thor
|
6
|
-
class_option 'host', :type => :string,
|
7
|
-
:banner => 'Elasticsearch host to connect to',
|
8
|
-
:default => 'localhost',
|
9
|
-
:aliases => '-H'
|
10
|
-
class_option 'port', :type => :string,
|
11
|
-
:banner => 'Port to use when connecting to Elasticsearch',
|
12
|
-
:default => '9200',
|
13
|
-
:aliases => '-p'
|
14
|
-
class_option 'name', :type => :string,
|
15
|
-
:banner => 'Index name',
|
16
|
-
:aliases => '-n',
|
17
|
-
:required => true
|
18
|
-
|
19
|
-
desc 'create [OPTIONS]', 'Create new index'
|
20
|
-
method_option 'update', :type => :boolean,
|
21
|
-
:banner => 'Update the mapping for all fields with the same name across all types.',
|
22
|
-
:default => false,
|
23
|
-
:aliases => '-u'
|
24
|
-
method_option 'wait', :type => :numeric,
|
25
|
-
:banner => 'Wait until specified number of shards is active.',
|
26
|
-
:default => 0,
|
27
|
-
:aliases => '-w'
|
28
|
-
def create
|
29
|
-
Estool::Actions::Index.new(:create, options).run
|
30
|
-
end
|
31
|
-
|
32
|
-
desc 'delete [OPTIONS]', 'Delete index'
|
33
|
-
def delete
|
34
|
-
Estool::Actions::Index.new(:delete, options).run
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|