consolr 1.1.4 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/README.md +20 -11
- data/consolr.gemspec +8 -8
- data/lib/consolr.rb +72 -70
- data/lib/consolr/version.rb +1 -1
- metadata +15 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 11a24c9b0561b89685d3adb05787b51e0005c7ec
|
4
|
+
data.tar.gz: a7e6fc27c2b7b13f2c0896e6c78eaad4535891a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: acbd07b961a90a56cf71181e11751c7447cda0af49ed2047a4fa7923dffd40f451e23e83e984786c95d3606b48fa69b0bec8c53c5aef83ac023e9be579a1761d
|
7
|
+
data.tar.gz: 2ad9199618d6c9f2be136c6fdf28650e97c717ff07a330090b99743f1d8837668873d71a8b925798805f6a3e69942da163b39c91e07d0bf24da6d7df21f4d0f6
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -43,27 +43,36 @@ Redhat Flavors
|
|
43
43
|
# gem install consolr
|
44
44
|
```
|
45
45
|
|
46
|
-
|
46
|
+
### Configuration
|
47
47
|
|
48
|
-
|
49
|
-
|
48
|
+
The configuration file is where consolr looks for what runners you have enabled
|
49
|
+
and what parameters should be passed for them. To configure your runners add
|
50
|
+
them to the `runners` array. For any runner you have, you can add another root
|
51
|
+
key to the config object with parameters for that runner.
|
52
|
+
|
53
|
+
If you have assets where you don't want users changing things, just add the
|
50
54
|
asset in the dangerous assets list. Consolr will safeguard it.
|
51
55
|
|
52
|
-
Consolr authenticates with Collins through [collins-auth](https://github.com/tumblr/collins/tree/master/support/ruby/collins-auth). So
|
56
|
+
Consolr authenticates with Collins through [collins-auth](https://github.com/tumblr/collins/tree/master/support/ruby/collins-auth). So
|
53
57
|
one would want collins.yml file to be set up as well.
|
54
58
|
|
55
|
-
Configuration params are searched in these locations
|
59
|
+
Configuration params are searched in these locations:
|
56
60
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
+
1. `ENV['CONSOLR_CONFIG']`
|
62
|
+
2. `$HOME/.consolr.yml`
|
63
|
+
3. `/etc/consolr.yml`
|
64
|
+
4. `/var/db/consolr.yml`
|
61
65
|
|
62
66
|
An example consolr.yml file
|
63
67
|
|
64
|
-
```
|
68
|
+
```
|
65
69
|
runners:
|
66
|
-
ipmitool
|
70
|
+
- ipmitool
|
71
|
+
- customrunner
|
72
|
+
ipmitool: /usr/bin/ipmitool
|
73
|
+
customrunner:
|
74
|
+
user: admin
|
75
|
+
password: s3cr3t
|
67
76
|
dangerous_assets:
|
68
77
|
- "007117"
|
69
78
|
dangerous_status:
|
data/consolr.gemspec
CHANGED
@@ -6,8 +6,8 @@ require 'consolr/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "consolr"
|
8
8
|
spec.version = Consolr::VERSION
|
9
|
-
spec.authors = ["Will Richard", "Sashidhar Guntury"]
|
10
|
-
spec.email = ["
|
9
|
+
spec.authors = ["Will Richard", "Sashidhar Guntury", "Felix Aronsson"]
|
10
|
+
spec.email = ["collins-sm@googlegroups.com"]
|
11
11
|
spec.summary = %q{consolr is a pure ruby wrapper over IPMI to allow Out of Band communiation with nodes.}
|
12
12
|
spec.description = %q{Consolr is a utility which speaks to Collins on our behalf and retrieves the address, username and password to connect to that node over IPMI. Passing different flags, we can performs a variety of taks on the node over IPMI. There are safeguards in place to prevent potentially catastrophic actions being performed on nodes.}
|
13
13
|
spec.homepage = "https://github.com/tumblr/collins/tree/master/support/ruby/consolr"
|
@@ -18,11 +18,11 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_runtime_dependency "collins_auth", "~> 0.1
|
22
|
-
spec.add_runtime_dependency "net-ping", "~> 1.7
|
21
|
+
spec.add_runtime_dependency "collins_auth", "~> 0.1"
|
22
|
+
spec.add_runtime_dependency "net-ping", "~> 1.7"
|
23
23
|
|
24
|
-
spec.add_development_dependency "rake", "~> 10.4
|
25
|
-
spec.add_development_dependency "rspec", "~> 3.3
|
26
|
-
spec.add_development_dependency "simplecov", "~> 0.10
|
27
|
-
spec.add_development_dependency "webmock", "~> 1.21
|
24
|
+
spec.add_development_dependency "rake", "~> 10.4"
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.3"
|
26
|
+
spec.add_development_dependency "simplecov", "~> 0.10"
|
27
|
+
spec.add_development_dependency "webmock", "~> 1.21"
|
28
28
|
end
|
data/lib/consolr.rb
CHANGED
@@ -97,37 +97,10 @@ module Consolr
|
|
97
97
|
abort("Please pass either the hostname OR the tag but not both.")
|
98
98
|
end
|
99
99
|
|
100
|
-
if options[:runner].nil?
|
101
|
-
runners = load_runners(@config_params.fetch('runners', []))
|
102
|
-
# Default to the ipmitool runner for backwards compatibility
|
103
|
-
if runners.empty?
|
104
|
-
require 'consolr/runners/ipmitool'
|
105
|
-
runners = [Consolr::Runners::Ipmitool.new(@config_params.fetch('ipmitool', {}))]
|
106
|
-
end
|
107
|
-
else
|
108
|
-
runners = load_runners([options[:runner]])
|
109
|
-
if runners.empty?
|
110
|
-
abort('Specified runner could not be loaded. Aborting.')
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
100
|
# match assets like vm-67f5eh, zt-*, etc.
|
115
101
|
nodes = options[:tag] ? (collins.find :tag => options[:tag]) : (collins.find :hostname => options[:hostname])
|
116
102
|
@node = nodes.length == 1 ? nodes.first : abort("Found #{nodes.length} assets, aborting.")
|
117
103
|
|
118
|
-
# select the first runner that support the node
|
119
|
-
runner = runners.select {|runner|
|
120
|
-
runner.can_run? @node
|
121
|
-
}.first
|
122
|
-
|
123
|
-
if runner.nil?
|
124
|
-
abort("No runners available for node #{@node.hostname} (#{@node.tag})")
|
125
|
-
end
|
126
|
-
|
127
|
-
if not runner.verify @node
|
128
|
-
abort("Cannot verify asset #{@node.hostname} (#{@node.tag})")
|
129
|
-
end
|
130
|
-
|
131
104
|
selected_dangerous_actions = dangerous_actions.select { |o| options[o] }
|
132
105
|
if dangerous_assets.include?(@node.tag) and selected_dangerous_actions.any?
|
133
106
|
abort "Asset #{@node.tag} is a crucial asset. Can't ever execute dangerous actions on this asset.\n#{dangerous_body}"
|
@@ -137,54 +110,83 @@ module Consolr
|
|
137
110
|
abort "Cannot run dangerous commands on #{@node.hostname} (#{@node.tag} - #{@node.status}) because it is in a protected status. This can be overridden with the --force flag\n#{dangerous_body}"
|
138
111
|
end
|
139
112
|
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
when options[:identify]
|
147
|
-
puts runner.identify @node
|
148
|
-
when options[:sdr]
|
149
|
-
puts runner.sdr @node
|
150
|
-
when options[:log] == 'list'
|
151
|
-
puts runner.log_list @node
|
152
|
-
when options[:log] == 'clear'
|
153
|
-
puts runner.log_clear @node
|
154
|
-
when options[:on]
|
155
|
-
puts runner.on @node
|
156
|
-
when options[:off]
|
157
|
-
puts runner.off @node
|
158
|
-
when options[:soft_off]
|
159
|
-
puts runner.soft_off @node
|
160
|
-
when options[:reboot]
|
161
|
-
puts runner.reboot @node
|
162
|
-
when options[:soft_reboot]
|
163
|
-
puts runner.soft_reboot @node
|
164
|
-
when options[:status]
|
165
|
-
puts runner.status @node
|
166
|
-
when options[:sensors]
|
167
|
-
puts runner.sensors @node
|
168
|
-
when options[:get_sol_info]
|
169
|
-
puts runner.sol_info @node
|
170
|
-
else
|
171
|
-
begin
|
172
|
-
puts "specify an action"
|
173
|
-
exit 1
|
174
|
-
end
|
113
|
+
# use the command line runner, if it was provided
|
114
|
+
runner_names = [options[:runner]].compact
|
115
|
+
|
116
|
+
# if no runner specified on command line, use the runners from the config
|
117
|
+
if runner_names.empty?
|
118
|
+
runner_names = @config_params.fetch('runners', []).compact
|
175
119
|
end
|
176
|
-
end
|
177
120
|
|
178
|
-
|
179
|
-
|
180
|
-
|
121
|
+
# if neither of the above is true, default to using ipmitool
|
122
|
+
if runner_names.empty?
|
123
|
+
runner_names = ['ipmitool']
|
124
|
+
end
|
125
|
+
|
126
|
+
# select the first runner that support the node
|
127
|
+
runner_names.each do |runner_name|
|
128
|
+
|
129
|
+
# load the runner
|
181
130
|
begin
|
182
|
-
require "consolr/runners/#{
|
183
|
-
Consolr::Runners.const_get(
|
131
|
+
require "consolr/runners/#{runner_name}"
|
132
|
+
runner = Consolr::Runners.const_get(runner_name.capitalize).new @config_params.fetch(runner_name, {})
|
184
133
|
rescue NameError, LoadError => e
|
185
|
-
puts "Could not load runner #{
|
134
|
+
puts "Could not load runner #{runner_name.capitalize}, skipping."
|
135
|
+
next
|
186
136
|
end
|
187
|
-
|
137
|
+
|
138
|
+
# if this runner can't work for this node, try the next runner
|
139
|
+
if not runner.can_run? @node
|
140
|
+
next
|
141
|
+
end
|
142
|
+
|
143
|
+
if not runner.verify @node
|
144
|
+
abort("Cannot verify asset #{@node.hostname} (#{@node.tag})")
|
145
|
+
end
|
146
|
+
|
147
|
+
# run the command!
|
148
|
+
case
|
149
|
+
when options[:console]
|
150
|
+
puts '--> Opening SOL session (type ~~. to quit)'
|
151
|
+
puts runner.console @node
|
152
|
+
when options[:kick]
|
153
|
+
puts runner.kick @node
|
154
|
+
when options[:identify]
|
155
|
+
puts runner.identify @node
|
156
|
+
when options[:sdr]
|
157
|
+
puts runner.sdr @node
|
158
|
+
when options[:log] == 'list'
|
159
|
+
puts runner.log_list @node
|
160
|
+
when options[:log] == 'clear'
|
161
|
+
puts runner.log_clear @node
|
162
|
+
when options[:on]
|
163
|
+
puts runner.on @node
|
164
|
+
when options[:off]
|
165
|
+
puts runner.off @node
|
166
|
+
when options[:soft_off]
|
167
|
+
puts runner.soft_off @node
|
168
|
+
when options[:reboot]
|
169
|
+
puts runner.reboot @node
|
170
|
+
when options[:soft_reboot]
|
171
|
+
puts runner.soft_reboot @node
|
172
|
+
when options[:status]
|
173
|
+
puts runner.status @node
|
174
|
+
when options[:sensors]
|
175
|
+
puts runner.sensors @node
|
176
|
+
when options[:get_sol_info]
|
177
|
+
puts runner.sol_info @node
|
178
|
+
else
|
179
|
+
begin
|
180
|
+
abort("specify an action")
|
181
|
+
end
|
182
|
+
end
|
183
|
+
# everything worked!
|
184
|
+
exit 0
|
185
|
+
end
|
186
|
+
|
187
|
+
# if we got here, all the runners did not work for this node
|
188
|
+
abort("No runners available for node #{@node.hostname} (#{@node.tag})")
|
188
189
|
end
|
190
|
+
|
189
191
|
end
|
190
192
|
end
|
data/lib/consolr/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: consolr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Will Richard
|
8
8
|
- Sashidhar Guntury
|
9
|
+
- Felix Aronsson
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2016-
|
13
|
+
date: 2016-07-19 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
16
|
name: collins_auth
|
@@ -17,91 +18,89 @@ dependencies:
|
|
17
18
|
requirements:
|
18
19
|
- - "~>"
|
19
20
|
- !ruby/object:Gem::Version
|
20
|
-
version: 0.1
|
21
|
+
version: '0.1'
|
21
22
|
type: :runtime
|
22
23
|
prerelease: false
|
23
24
|
version_requirements: !ruby/object:Gem::Requirement
|
24
25
|
requirements:
|
25
26
|
- - "~>"
|
26
27
|
- !ruby/object:Gem::Version
|
27
|
-
version: 0.1
|
28
|
+
version: '0.1'
|
28
29
|
- !ruby/object:Gem::Dependency
|
29
30
|
name: net-ping
|
30
31
|
requirement: !ruby/object:Gem::Requirement
|
31
32
|
requirements:
|
32
33
|
- - "~>"
|
33
34
|
- !ruby/object:Gem::Version
|
34
|
-
version: 1.7
|
35
|
+
version: '1.7'
|
35
36
|
type: :runtime
|
36
37
|
prerelease: false
|
37
38
|
version_requirements: !ruby/object:Gem::Requirement
|
38
39
|
requirements:
|
39
40
|
- - "~>"
|
40
41
|
- !ruby/object:Gem::Version
|
41
|
-
version: 1.7
|
42
|
+
version: '1.7'
|
42
43
|
- !ruby/object:Gem::Dependency
|
43
44
|
name: rake
|
44
45
|
requirement: !ruby/object:Gem::Requirement
|
45
46
|
requirements:
|
46
47
|
- - "~>"
|
47
48
|
- !ruby/object:Gem::Version
|
48
|
-
version: 10.4
|
49
|
+
version: '10.4'
|
49
50
|
type: :development
|
50
51
|
prerelease: false
|
51
52
|
version_requirements: !ruby/object:Gem::Requirement
|
52
53
|
requirements:
|
53
54
|
- - "~>"
|
54
55
|
- !ruby/object:Gem::Version
|
55
|
-
version: 10.4
|
56
|
+
version: '10.4'
|
56
57
|
- !ruby/object:Gem::Dependency
|
57
58
|
name: rspec
|
58
59
|
requirement: !ruby/object:Gem::Requirement
|
59
60
|
requirements:
|
60
61
|
- - "~>"
|
61
62
|
- !ruby/object:Gem::Version
|
62
|
-
version: 3.3
|
63
|
+
version: '3.3'
|
63
64
|
type: :development
|
64
65
|
prerelease: false
|
65
66
|
version_requirements: !ruby/object:Gem::Requirement
|
66
67
|
requirements:
|
67
68
|
- - "~>"
|
68
69
|
- !ruby/object:Gem::Version
|
69
|
-
version: 3.3
|
70
|
+
version: '3.3'
|
70
71
|
- !ruby/object:Gem::Dependency
|
71
72
|
name: simplecov
|
72
73
|
requirement: !ruby/object:Gem::Requirement
|
73
74
|
requirements:
|
74
75
|
- - "~>"
|
75
76
|
- !ruby/object:Gem::Version
|
76
|
-
version: 0.10
|
77
|
+
version: '0.10'
|
77
78
|
type: :development
|
78
79
|
prerelease: false
|
79
80
|
version_requirements: !ruby/object:Gem::Requirement
|
80
81
|
requirements:
|
81
82
|
- - "~>"
|
82
83
|
- !ruby/object:Gem::Version
|
83
|
-
version: 0.10
|
84
|
+
version: '0.10'
|
84
85
|
- !ruby/object:Gem::Dependency
|
85
86
|
name: webmock
|
86
87
|
requirement: !ruby/object:Gem::Requirement
|
87
88
|
requirements:
|
88
89
|
- - "~>"
|
89
90
|
- !ruby/object:Gem::Version
|
90
|
-
version: 1.21
|
91
|
+
version: '1.21'
|
91
92
|
type: :development
|
92
93
|
prerelease: false
|
93
94
|
version_requirements: !ruby/object:Gem::Requirement
|
94
95
|
requirements:
|
95
96
|
- - "~>"
|
96
97
|
- !ruby/object:Gem::Version
|
97
|
-
version: 1.21
|
98
|
+
version: '1.21'
|
98
99
|
description: Consolr is a utility which speaks to Collins on our behalf and retrieves
|
99
100
|
the address, username and password to connect to that node over IPMI. Passing different
|
100
101
|
flags, we can performs a variety of taks on the node over IPMI. There are safeguards
|
101
102
|
in place to prevent potentially catastrophic actions being performed on nodes.
|
102
103
|
email:
|
103
|
-
- will@tumblr.com
|
104
|
-
- sashi@tumblr.com
|
105
104
|
- collins-sm@googlegroups.com
|
106
105
|
executables:
|
107
106
|
- consolr
|