estool 0.0.6.pre.alpha → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 734b762b75084c2f6aabe764e0366c823ab12c30
4
- data.tar.gz: 9d0b92d3c3fcf0c001241240f4d76e0d21fc1692
3
+ metadata.gz: 764824d476cbad5de5c72e93ddc216bc324e3ad6
4
+ data.tar.gz: 100c7e0d05de50f740e34d0f0cb79efa334213a1
5
5
  SHA512:
6
- metadata.gz: 955f2a559a3ce1d249f16b702642ec228522ecfbab4c4bf279c60b17b80fe1e52817dd0fa667fb4b1ebb07e66671a4eff780c41c05108452e0c32d1162ead312
7
- data.tar.gz: 9610236bc16ad7038df4dec8341efd458e3d7e5113a2a4811eaa5d15cc14b3b519a700cfe3722de11163e69162b4fa857c838ca89106e2aa1f4da7ff521685ac
6
+ metadata.gz: cacab163c5fcf0b083da8d08960f846dec60aa5cb15b75c0f316ad4116d763117ed01d237b0fba0990d77076b16a478eecd5396bc01fb8befac74dea165571b8
7
+ data.tar.gz: daa86ea9eaec1063339b7c41cd2775b8a2df16327356f188653a87d407a85e34a9b6de1b34db9778ea0e358aa3d628efc956f3ce0391e6390665a2ea99de86de
@@ -1,13 +1,44 @@
1
+ require 'active_support'
1
2
  require 'elasticsearch-api'
2
3
  require 'estool/connections'
3
4
 
4
5
  module Estool::Actions
5
6
  class Cat
6
- def self.run(action, data, options)
7
- client = Estool::Connections.start_conn(options[:host], options[:port])
7
+
8
+ def initialize(command,options)
9
+ @cmd = command
10
+ @data = options.except(:host, :port)
11
+ @server = options.slice(:host, :port)
12
+ end
13
+
14
+ def format_options(data)
15
+ params = {}
16
+ data.each do |k, v|
17
+ case k
18
+ when 'verbose'
19
+ params.merge!(v: v)
20
+ when 'output'
21
+ params.merge!(format: v)
22
+ when 'timeout'
23
+ params.merge!(master_timeout: v)
24
+ when 'name'
25
+ params.merge!(name: v)
26
+ when 'node'
27
+ params.merge!(node_id: v)
28
+ when 'primary'
29
+ params.merge!(pri: v)
30
+ else
31
+ puts 'does not exist'
32
+ end
33
+ end
34
+ return params
35
+ end
36
+
37
+ def cat(action, options, server)
38
+ client = Estool::Connections.start_conn(server[:host], server[:port])
8
39
  Estool::Connections.test_conn(client)
9
40
  begin
10
- puts client.cat.send(action, data)
41
+ puts client.cat.send(action, options)
11
42
  rescue ArgumentError => args
12
43
  puts "
13
44
  #{args}
@@ -16,5 +47,10 @@ module Estool::Actions
16
47
  exit 1
17
48
  end
18
49
  end
50
+
51
+ def run
52
+ params = format_options(@data)
53
+ cat(@cmd, params, @server)
54
+ end
19
55
  end
20
56
  end
data/lib/estool/cat.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'thor'
2
+ require 'estool/actions/cat'
2
3
 
3
4
  module Estool
4
5
  class Cat < Thor
@@ -18,18 +19,17 @@ module Estool
18
19
  :banner => 'Display output as json or text',
19
20
  :default => 'text',
20
21
  :aliases => '-o'
21
- class_option 'timeout', :type => :numeric,
22
- :banner => 'Set Master Timeout in seconds',
23
- :default => 30,
24
- :aliases => '-t'
22
+ # class_option 'timeout', :type => :numeric,
23
+ # :banner => 'Set Master Timeout in seconds',
24
+ # :default => 30,
25
+ # :aliases => '-t'
25
26
 
26
27
  desc 'aliases [OPTIONS]', 'Display information about aliases'
27
28
  method_option 'name', :type => :string,
28
29
  :banner => 'Name of alias(es) to display information about',
29
30
  :aliases => '-n'
30
31
  def aliases
31
- require 'estool/cat/aliases'
32
- Aliases.new(options).run
32
+ Estool::Actions::Cat.new(:aliases, options).run
33
33
  end
34
34
 
35
35
  desc 'allocation [OPTIONS]', 'Display shard allocation information'
@@ -42,8 +42,7 @@ module Estool
42
42
  :enum => %w{b k m g},
43
43
  :aliases => '-b'
44
44
  def allocation
45
- require 'estool/cat/allocation'
46
- Allocation.new(options).run
45
+ Estool::Actions::Cat.new(:allocation, options).run
47
46
  end
48
47
 
49
48
  desc 'count [OPTIONS]', 'Return Document count for cluster or indices'
@@ -51,8 +50,7 @@ module Estool
51
50
  :banner => 'Index to count documents',
52
51
  :aliases => '-i'
53
52
  def count
54
- require 'estool/cat/count'
55
- Count.new(options).run
53
+ Estool::Actions::Cat.new(:count, options).run
56
54
  end
57
55
 
58
56
  desc 'fielddata [OPTIONS]', 'Return field data usage data'
@@ -65,14 +63,12 @@ module Estool
65
63
  :enum => %w{b k m g},
66
64
  :aliases => '-b'
67
65
  def fielddata
68
- require 'estool/cat/fielddata'
69
- Fielddata.new(options).run
66
+ Estool::Actions::Cat.new(:fielddata, options).run
70
67
  end
71
68
 
72
69
  desc 'health [OPTIONS]', 'Display Elasticsearch Cluster health'
73
70
  def health
74
- require 'estool/cat/health'
75
- Health.new(options).run
71
+ Estool::Actions::Cat.new(:health, options).run
76
72
  end
77
73
 
78
74
  desc 'indices [OPTIONS]', 'Display indices statistics across the cluster'
@@ -89,38 +85,32 @@ module Estool
89
85
  :enum => %w{b k m g},
90
86
  :aliases => '-b'
91
87
  def indices
92
- require 'estool/cat/indices'
93
- Indices.new(options).run
88
+ Estool::Actions::Cat.new(:indices, options).run
94
89
  end
95
90
 
96
91
  desc 'master [OPTIONS]', 'Display current master node'
97
92
  def master
98
- require 'estool/cat/master'
99
- Master.new(options).run
93
+ Estool::Actions::Cat.new(:master, options).run
100
94
  end
101
95
 
102
96
  desc 'nodeattrs [OPTIONS]', 'Display custom node attributes'
103
97
  def nodeattrs
104
- require 'estool/cat/nodeattrs'
105
- Nodeattrs.new(options).run
98
+ Estool::Actions::Cat.new(:nodeattrs, options).run
106
99
  end
107
100
 
108
101
  desc 'nodes [OPTIONS]', 'Display Elasticsearch Nodes'
109
102
  def nodes
110
- require 'estool/cat/nodes'
111
- Nodes.new(options).run
103
+ Estool::Actions::Cat.new(:nodes, options).run
112
104
  end
113
105
 
114
106
  desc 'ptasks [OPTIONS]', 'Display Elasticsearch Pending Task in tabular format'
115
107
  def ptasks
116
- require 'estool/cat/ptasks'
117
- Ptasks.new(options).run
108
+ Estool::Actions::Cat.new(:pending_tasks, options).run
118
109
  end
119
110
 
120
111
  desc 'plugins [OPTIONS]', 'Display Elasticsearch Plugins'
121
112
  def plugins
122
- require 'estool/cat/plugin'
123
- Plugin.new(options).run
113
+ Estool::Actions::Cat.new(:plugins, options).run
124
114
  end
125
115
 
126
116
  desc 'recovery [OPTIONS]', 'Display shard recovery status'
@@ -133,14 +123,12 @@ module Estool
133
123
  :enum => %w{b k m g},
134
124
  :aliases => '-b'
135
125
  def recovery
136
- require 'estool/cat/recovery'
137
- Recovery.new(options).run
126
+ Estool::Actions::Cat.new(:recovery, options).run
138
127
  end
139
128
 
140
129
  desc 'repositories [OPTIONS]', 'Display registered repositories'
141
130
  def repositories
142
- require 'estool/cat/repositories'
143
- Repositories.new(options).run
131
+ Estool::Actions::Cat.new(:repositories, options).run
144
132
  end
145
133
  end
146
134
  end
@@ -1,4 +1,4 @@
1
1
  module Estool
2
2
  ESTOOL_ROOT = File.expand_path("../..", __FILE__)
3
- VERSION = "0.0.6-alpha"
3
+ VERSION = "0.0.7"
4
4
  end
data/lib/estool.rb CHANGED
@@ -1,9 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- require 'elasticsearch'
3
- require 'net/http'
4
- require 'optparse'
5
2
  require 'estool/cat'
6
- require 'estool/connections'
7
3
  require 'thor'
8
4
 
9
5
  module Estool
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.0.6.pre.alpha
4
+ version: 0.0.7
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-08-09 00:00:00.000000000 Z
11
+ date: 2016-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: elasticsearch-api
@@ -58,19 +58,6 @@ files:
58
58
  - lib/estool.rb
59
59
  - lib/estool/actions/cat.rb
60
60
  - lib/estool/cat.rb
61
- - lib/estool/cat/aliases.rb
62
- - lib/estool/cat/allocation.rb
63
- - lib/estool/cat/count.rb
64
- - lib/estool/cat/fielddata.rb
65
- - lib/estool/cat/health.rb
66
- - lib/estool/cat/indices.rb
67
- - lib/estool/cat/master.rb
68
- - lib/estool/cat/nodeattrs.rb
69
- - lib/estool/cat/nodes.rb
70
- - lib/estool/cat/plugin.rb
71
- - lib/estool/cat/ptasks.rb
72
- - lib/estool/cat/recovery.rb
73
- - lib/estool/cat/repositories.rb
74
61
  - lib/estool/connections.rb
75
62
  - lib/estool/version.rb
76
63
  homepage: https://github.com/dhollinger/estool
@@ -88,9 +75,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
88
75
  version: '0'
89
76
  required_rubygems_version: !ruby/object:Gem::Requirement
90
77
  requirements:
91
- - - ">"
78
+ - - ">="
92
79
  - !ruby/object:Gem::Version
93
- version: 1.3.1
80
+ version: '0'
94
81
  requirements: []
95
82
  rubyforge_project:
96
83
  rubygems_version: 2.5.1
@@ -1,27 +0,0 @@
1
- require 'estool/actions/cat'
2
-
3
- module Estool
4
- class Cat::Aliases
5
-
6
- def initialize(options)
7
- @verbose = options[:verbose]
8
- @output = options[:output]
9
- @timeout = options[:timeout]
10
- @name = options[:name]
11
- @server = {
12
- host: options[:host],
13
- port: options[:port]
14
- }
15
- end
16
-
17
- def run
18
- data = {
19
- v: @verbose,
20
- format: @output,
21
- master_timeout: @timeout,
22
- name: @name
23
- }
24
- Estool::Actions::Cat.run(:aliases, data, @server)
25
- end
26
- end
27
- end
@@ -1,27 +0,0 @@
1
- require 'estool/actions/cat'
2
-
3
- module Estool
4
- class Cat::Allocation
5
-
6
- def initialize(options)
7
- @verbose = options[:verbose]
8
- @node = options[:node]
9
- @bytes = options[:bytes]
10
- @output = options[:output]
11
- @server = {
12
- host: options[:host],
13
- port: options[:port]
14
- }
15
- end
16
-
17
- def run
18
- data = {
19
- v: @verbose,
20
- node_id: @node,
21
- bytes: @bytes,
22
- format: @output
23
- }
24
- Estool::Actions::Cat.run(:allocation, data, @server)
25
- end
26
- end
27
- end
@@ -1,27 +0,0 @@
1
- require 'estool/actions/cat'
2
-
3
- module Estool
4
- class Cat::Count
5
-
6
- def initialize(options)
7
- @verbose = options[:verbose]
8
- @output = options[:output]
9
- @timeout = options[:timeout]
10
- @index = options[:index]
11
- @server = {
12
- host: options[:host],
13
- port: options[:port]
14
- }
15
- end
16
-
17
- def run
18
- data = {
19
- v: @verbose,
20
- format: @output,
21
- master_timeout: @timeout,
22
- index: @index
23
- }
24
- Estool::Actions::Cat.run(:count, data, @server)
25
- end
26
- end
27
- end
@@ -1,27 +0,0 @@
1
- require 'estool/actions/cat'
2
-
3
- module Estool
4
- class Cat::Fielddata
5
-
6
- def initialize(options)
7
- @verbose = options[:verbose]
8
- @timeout = options[:timeout]
9
- @bytes = options[:bytes]
10
- @fields = options[:fields]
11
- @server = {
12
- host: options[:host],
13
- port: options[:port]
14
- }
15
- end
16
-
17
- def run
18
- data = {
19
- v: @verbose,
20
- master_timeout: @timeout,
21
- bytes: @bytes
22
- }
23
- data[:fields] = @fields unless @fields.nil?
24
- Estool::Actions::Cat.run(:fielddata, data, @server)
25
- end
26
- end
27
- end
@@ -1,25 +0,0 @@
1
- require 'estool/actions/cat'
2
-
3
- module Estool
4
- class Cat::Health
5
-
6
- def initialize(options)
7
- @verbose = options[:verbose]
8
- @output = options[:output]
9
- @timeout = options[:timeout]
10
- @server = {
11
- host: options[:host],
12
- port: options[:port]
13
- }
14
- end
15
-
16
- def run
17
- data = {
18
- v: @verbose,
19
- format: @output,
20
- master_timeout: @timeout
21
- }
22
- Estool::Actions::Cat.run(:health, data, @server)
23
- end
24
- end
25
- end
@@ -1,29 +0,0 @@
1
- require 'estool/actions/cat'
2
-
3
- module Estool
4
- class Cat::Indices
5
-
6
- def initialize(options)
7
- @verbose = options[:verbose]
8
- @bytes = options[:bytes]
9
- @primary = options[:primary]
10
- @output = options[:output]
11
- @index = options[:index]
12
- @server = {
13
- host: options[:host],
14
- port: options[:port]
15
- }
16
- end
17
-
18
- def run
19
- data = {
20
- v: @verbose,
21
- bytes: @bytes,
22
- pri: @primary,
23
- format: @output
24
- }
25
- data[:index] = @index unless @index.nil?
26
- Estool::Actions::Cat.run(:indices, data, @server)
27
- end
28
- end
29
- end
@@ -1,24 +0,0 @@
1
- require 'estool/actions/cat'
2
-
3
- module Estool
4
- class Cat::Master
5
-
6
- def initialize(options)
7
- @verbose = options[:verbose]
8
- @output = options[:output]
9
- @server = {
10
- host: options[:host],
11
- port: options[:port]
12
- }
13
- end
14
-
15
- def run
16
- data = {
17
- v: @verbose,
18
- format: @output
19
- }
20
- Estool::Actions::Cat.run(:master, data, @server)
21
- end
22
-
23
- end
24
- end
@@ -1,24 +0,0 @@
1
- require 'estool/actions/cat'
2
-
3
- module Estool
4
- class Cat::Nodeattrs
5
-
6
- def initialize(options)
7
- @verbose = options[:verbose]
8
- @output = options[:output]
9
- @server = {
10
- host: options[:host],
11
- port: options[:port]
12
- }
13
- end
14
-
15
- def run
16
- data = {
17
- v: @verbose,
18
- format: @output
19
- }
20
- Estool::Actions::Cat.run(:nodeattrs, data, @server)
21
- end
22
-
23
- end
24
- end
@@ -1,23 +0,0 @@
1
- require 'estool/actions/cat'
2
-
3
- module Estool
4
- class Cat::Nodes
5
-
6
- def initialize(options)
7
- @verbose = options[:verbose]
8
- @output = options[:output]
9
- @server = {
10
- host: options[:host],
11
- port: options[:port]
12
- }
13
- end
14
-
15
- def run
16
- data = {
17
- v: @verbose,
18
- format: @output
19
- }
20
- Estool::Actions::Cat.run(:nodes, data, @server)
21
- end
22
- end
23
- end
@@ -1,21 +0,0 @@
1
- require 'estool/actions/cat'
2
-
3
- module Estool
4
- class Cat::Plugin
5
-
6
- def initialize(options)
7
- @verbose = options[:verbose]
8
- @server = {
9
- host: options[:host],
10
- port: options[:port]
11
- }
12
- end
13
-
14
- def run
15
- data = {
16
- v: @verbose
17
- }
18
- Estool::Actions::Cat.run(:plugins, data, @server)
19
- end
20
- end
21
- end
@@ -1,23 +0,0 @@
1
- require 'estool/actions/cat'
2
-
3
- module Estool
4
- class Cat::Ptasks
5
-
6
- def initialize(options)
7
- @verbose = options[:verbose]
8
- @output = options[:output]
9
- @server = {
10
- host: options[:host],
11
- port: options[:port]
12
- }
13
- end
14
-
15
- def run
16
- data = {
17
- v: @verbose,
18
- format: @output,
19
- }
20
- Estool::Actions::Cat.run(:pending_tasks, data, @server)
21
- end
22
- end
23
- end
@@ -1,27 +0,0 @@
1
- require 'estool/actions/cat'
2
-
3
- module Estool
4
- class Cat::Recovery
5
-
6
- def initialize(options)
7
- @verbose = options[:verbose]
8
- @bytes = options[:bytes]
9
- @index = options[:index]
10
- @output = options[:output]
11
- @server = {
12
- host: options[:host],
13
- port: options[:port]
14
- }
15
- end
16
-
17
- def run
18
- data = {
19
- v: @verbose,
20
- format: @output,
21
- }
22
- data[:index] = @index unless @index.nil?
23
- data[:bytes] = @bytes unless @bytes.nil?
24
- Estool::Actions::Cat.run(:recovery, data, @server)
25
- end
26
- end
27
- end
@@ -1,21 +0,0 @@
1
- require 'estool/actions/cat'
2
-
3
- module Estool
4
- class Cat::Repositories
5
-
6
- def initialize(options)
7
- @verbose = options[:verbose]
8
- @server = {
9
- host: options[:host],
10
- port: options[:port]
11
- }
12
- end
13
-
14
- def run
15
- data = {
16
- v: @verbose
17
- }
18
- Estool::Actions::Cat.run(:repositories, data, @server)
19
- end
20
- end
21
- end