knife-stalenodes 1.1.0 → 1.2.0
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 +7 -0
- data/README.rdoc +7 -0
- data/lib/chef/knife/stalenodes.rb +56 -2
- data/lib/knife-stalenodes/version.rb +1 -1
- metadata +9 -14
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 70da763f3e79df1b293b4ac9415bd467098d9998
|
4
|
+
data.tar.gz: 31fdb8d4a3f3ea93c5f9a1b63d68d7eaeecafe01
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 00d8f9b75eaa191d072917cc50a55e264c94f580f5ef55e76138c5fb7fb975a85906ca09056e6dd87c9390bce8b8f1d741da1ff9e5b8ad39d949ceb04625989f
|
7
|
+
data.tar.gz: c625bfb3505d68f4adc6c1a981fb9face81f036dabe8812826005d8a0a13830032c1cb40ddcc78e4d61040f979d4868ba15ac52001e53e97629ffd79279fa401
|
data/README.rdoc
CHANGED
@@ -20,6 +20,7 @@ Available options are:
|
|
20
20
|
* -H, --hours HOURS
|
21
21
|
* -m, --minutes MINUTES
|
22
22
|
* -r, --reverse
|
23
|
+
* -e, --use-ec2
|
23
24
|
|
24
25
|
These options can be used together so:
|
25
26
|
|
@@ -27,6 +28,12 @@ These options can be used together so:
|
|
27
28
|
|
28
29
|
Will show all the nodes that have checked in within the last 4.5 hours
|
29
30
|
|
31
|
+
Add the following to your knife.rb to permanently enable --use-ec2:
|
32
|
+
|
33
|
+
knife[:stalenodes] = {
|
34
|
+
:use_ec2 => true
|
35
|
+
}
|
36
|
+
|
30
37
|
= WARNING:
|
31
38
|
|
32
39
|
This plugin is not officially supported by Opscode.
|
@@ -63,6 +63,16 @@ module KnifeStalenodes
|
|
63
63
|
:description => "Max number of hosts to search",
|
64
64
|
:default => 2500
|
65
65
|
|
66
|
+
option :use_ec2,
|
67
|
+
:short => "-e",
|
68
|
+
:long => "--use-ec2",
|
69
|
+
:description => "Indicate whether or not stale nodes are present in ec2",
|
70
|
+
:default => false,
|
71
|
+
:proc => Proc.new { |key|
|
72
|
+
Chef::Config[:knife][:stalenodes] ||= {}
|
73
|
+
Chef::Config[:knife][:stalenodes][:use_ec2] = key
|
74
|
+
}
|
75
|
+
|
66
76
|
|
67
77
|
def calculate_time
|
68
78
|
seconds = config[:days].to_i * 86400 + config[:hours].to_i * 3600 + config[:minutes].to_i * 60
|
@@ -70,6 +80,18 @@ module KnifeStalenodes
|
|
70
80
|
return Time.now.to_i - seconds
|
71
81
|
end
|
72
82
|
|
83
|
+
def connection
|
84
|
+
@connection ||= begin
|
85
|
+
require 'fog'
|
86
|
+
connection = Fog::Compute.new(
|
87
|
+
:provider => 'AWS',
|
88
|
+
:aws_access_key_id => Chef::Config[:knife][:aws_access_key_id],
|
89
|
+
:aws_secret_access_key => Chef::Config[:knife][:aws_secret_access_key],
|
90
|
+
:region => Chef::Config[:knife][:region]
|
91
|
+
)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
73
95
|
def get_query
|
74
96
|
if config[:reverse]
|
75
97
|
"ohai_time:[#{calculate_time} TO *]"
|
@@ -102,9 +124,26 @@ module KnifeStalenodes
|
|
102
124
|
end
|
103
125
|
end
|
104
126
|
|
127
|
+
def use_ec2?
|
128
|
+
if Chef::Config[:knife][:stalenodes] &&
|
129
|
+
Chef::Config[:knife][:stalenodes][:use_ec2]
|
130
|
+
return true
|
131
|
+
else
|
132
|
+
return false
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
105
136
|
def run
|
137
|
+
if use_ec2?
|
138
|
+
live_hosts = connection.servers.select{|s|
|
139
|
+
s.state == "running" && s.tags['Name']
|
140
|
+
}.map{|s|
|
141
|
+
s.tags["Name"]
|
142
|
+
}
|
143
|
+
end
|
144
|
+
|
106
145
|
query = Chef::PartialSearch.new
|
107
|
-
search_args = { :keys => {
|
146
|
+
search_args = { :keys => {
|
108
147
|
:ohai_time => ['ohai_time'],
|
109
148
|
:name => ['name']
|
110
149
|
},
|
@@ -113,7 +152,22 @@ module KnifeStalenodes
|
|
113
152
|
|
114
153
|
query.search(:node, get_query, search_args).first.each do |node|
|
115
154
|
msg = check_last_run_time(node['ohai_time'].to_i)
|
116
|
-
|
155
|
+
|
156
|
+
if use_ec2?
|
157
|
+
if live_hosts.include?(node['name'])
|
158
|
+
islive = ""
|
159
|
+
else
|
160
|
+
islive = " - NOT IN EC2"
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
output = "#{@ui.color(msg[:text], msg[:color])} ago: #{node['name']}"
|
165
|
+
|
166
|
+
if use_ec2?
|
167
|
+
HighLine.new.say output + islive
|
168
|
+
else
|
169
|
+
HighLine.new.say output
|
170
|
+
end
|
117
171
|
end
|
118
172
|
end
|
119
173
|
end
|
metadata
CHANGED
@@ -1,30 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: knife-stalenodes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.2.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Paul Mooring
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2014-02-25 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: chef
|
16
15
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :runtime
|
23
21
|
prerelease: false
|
24
22
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
23
|
requirements:
|
27
|
-
- -
|
24
|
+
- - '>='
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: '0'
|
30
27
|
description: Knife plugin for listing nodes that have not checked in
|
@@ -41,27 +38,25 @@ files:
|
|
41
38
|
- lib/knife-stalenodes/version.rb
|
42
39
|
homepage: https://github.com/paulmooring/knife-stalenodes
|
43
40
|
licenses: []
|
41
|
+
metadata: {}
|
44
42
|
post_install_message:
|
45
43
|
rdoc_options: []
|
46
44
|
require_paths:
|
47
45
|
- lib
|
48
46
|
required_ruby_version: !ruby/object:Gem::Requirement
|
49
|
-
none: false
|
50
47
|
requirements:
|
51
|
-
- -
|
48
|
+
- - '>='
|
52
49
|
- !ruby/object:Gem::Version
|
53
50
|
version: '0'
|
54
51
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
-
none: false
|
56
52
|
requirements:
|
57
|
-
- -
|
53
|
+
- - '>='
|
58
54
|
- !ruby/object:Gem::Version
|
59
55
|
version: '0'
|
60
56
|
requirements: []
|
61
57
|
rubyforge_project:
|
62
|
-
rubygems_version:
|
58
|
+
rubygems_version: 2.0.14
|
63
59
|
signing_key:
|
64
|
-
specification_version:
|
60
|
+
specification_version: 4
|
65
61
|
summary: Knife plugin for listing nodes that have not checked in
|
66
62
|
test_files: []
|
67
|
-
has_rdoc:
|