chef_knives 0.6 → 0.7
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +4 -0
- data/Manifest.txt +1 -0
- data/Rakefile +2 -0
- data/bin/chef_node_revisions +80 -0
- data/chef_knives.gemspec +10 -4
- data/lib/chef/knives.rb +1 -1
- metadata +24 -2
data/History.txt
CHANGED
data/Manifest.txt
CHANGED
data/Rakefile
CHANGED
@@ -13,7 +13,9 @@ Hoe.new('chef_knives', Chef::Knives::VERSION) do |p|
|
|
13
13
|
p.extra_deps << [ 'choice' ]
|
14
14
|
p.extra_deps << [ 'chef', '>= 0.7' ]
|
15
15
|
p.extra_deps << [ 'json' ]
|
16
|
+
p.extra_deps << [ 'json_pure' ]
|
16
17
|
p.extra_deps << [ 'couchrest' ]
|
18
|
+
p.extra_deps << [ 'rest-client' ]
|
17
19
|
end
|
18
20
|
|
19
21
|
# vim: syntax=Ruby
|
@@ -0,0 +1,80 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'rest_client'
|
4
|
+
require 'choice'
|
5
|
+
require 'pp'
|
6
|
+
require 'json/pure'
|
7
|
+
|
8
|
+
CHEF_DB_URL = 'http://localhost:5984/chef'
|
9
|
+
|
10
|
+
def main
|
11
|
+
Choice.options do
|
12
|
+
header ''
|
13
|
+
header 'Available options:'
|
14
|
+
|
15
|
+
option :help do
|
16
|
+
long '--help'
|
17
|
+
short '-h'
|
18
|
+
desc 'Show this message'
|
19
|
+
action do
|
20
|
+
Choice.help
|
21
|
+
exit
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
option :name do
|
26
|
+
default '.*'
|
27
|
+
long '--name=REGEXP'
|
28
|
+
short '-n'
|
29
|
+
desc 'Match only the nodes with an FQDN matching this value'
|
30
|
+
end
|
31
|
+
|
32
|
+
option :revision do
|
33
|
+
long '--revisions=REV'
|
34
|
+
short '-r'
|
35
|
+
desc 'Match only the nodes with an FQDN matching this value'
|
36
|
+
end
|
37
|
+
|
38
|
+
option :no_ifaces do
|
39
|
+
long '--no-ifaces'
|
40
|
+
desc 'Do not print network interfaces'
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
output = RestClient.get('http://localhost:5984/chef/_all_docs') || []
|
45
|
+
nodes = JSON::Pure::Parser.new(output, :create_additions => false).parse['rows']
|
46
|
+
match = nil
|
47
|
+
nodes.each do |n|
|
48
|
+
match = n if n['id'] =~ /node_.*#{Choice.choices[:name]}.*/
|
49
|
+
end
|
50
|
+
|
51
|
+
json = RestClient.get "http://localhost:5984/chef/#{match['id']}?revs_info=true"
|
52
|
+
#{Choice.choices[:revision]}"
|
53
|
+
node = JSON::Pure::Parser.new(json, :create_additions => false).parse
|
54
|
+
puts "[ #{node['name']} ]"
|
55
|
+
if Choice.choices[:revision]
|
56
|
+
begin
|
57
|
+
node = parse_json "http://localhost:5984/chef/#{match['id']}?rev=#{Choice.choices[:revision]}"
|
58
|
+
pp node
|
59
|
+
rescue RestClient::RequestFailed
|
60
|
+
$stderr.puts "Revision '#{Choice.choices[:revision]}' not found for node #{match['id']}"
|
61
|
+
end
|
62
|
+
else
|
63
|
+
puts "REVISION".ljust(30) + "DATE"
|
64
|
+
node['_revs_info'].each do |ri|
|
65
|
+
if ri['status'] == 'available'
|
66
|
+
print "#{ri['rev']}".ljust(20)
|
67
|
+
node = parse_json "http://localhost:5984/chef/#{match['id']}?rev=#{ri['rev']}"
|
68
|
+
puts " #{Time.at(node['attributes']['ohai_time']).strftime('%Y%M%D-%H:%M:%S')}"
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
74
|
+
|
75
|
+
def parse_json(url)
|
76
|
+
json = RestClient.get url
|
77
|
+
JSON::Pure::Parser.new(json, :create_additions => false).parse
|
78
|
+
end
|
79
|
+
|
80
|
+
main
|
data/chef_knives.gemspec
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = %q{chef_knives}
|
3
|
-
s.version = "0.
|
3
|
+
s.version = "0.7"
|
4
4
|
|
5
5
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
6
6
|
s.authors = ["Sergio Rubio"]
|
7
|
-
s.date = %q{2009-
|
7
|
+
s.date = %q{2009-10-08}
|
8
8
|
s.description = %q{Unofficial Chef Server scripts and related stuff. http://wiki.opscode.com/display/chef}
|
9
9
|
s.email = ["sergio@rubio.name"]
|
10
|
-
s.executables = ["chef_node_find", "chef_node_find_domu", "chef_node_fs_usage", "chef_node_last_checkin", "chef_node_mem_usage", "chef_node_stats", "chef_vlan_stats"]
|
10
|
+
s.executables = ["chef_node_find", "chef_node_find_domu", "chef_node_fs_usage", "chef_node_last_checkin", "chef_node_mem_usage", "chef_node_revisions", "chef_node_stats", "chef_vlan_stats"]
|
11
11
|
s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt"]
|
12
|
-
s.files = ["AUTHORS", "History.txt", "Manifest.txt", "README.txt", "Rakefile", "bin/chef_node_find", "bin/chef_node_find_domu", "bin/chef_node_fs_usage", "bin/chef_node_last_checkin", "bin/chef_node_mem_usage", "bin/chef_node_stats", "bin/chef_vlan_stats", "chef_knives.gemspec", "lib/chef/knives.rb"]
|
12
|
+
s.files = ["AUTHORS", "History.txt", "Manifest.txt", "README.txt", "Rakefile", "bin/chef_node_find", "bin/chef_node_find_domu", "bin/chef_node_fs_usage", "bin/chef_node_last_checkin", "bin/chef_node_mem_usage", "bin/chef_node_revisions", "bin/chef_node_stats", "bin/chef_vlan_stats", "chef_knives.gemspec", "lib/chef/knives.rb"]
|
13
13
|
s.homepage = %q{http://github.com/rubiojr/chef-knives}
|
14
14
|
s.rdoc_options = ["--main", "README.txt"]
|
15
15
|
s.require_paths = ["lib"]
|
@@ -26,14 +26,18 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.add_runtime_dependency(%q<choice>, [">= 0"])
|
27
27
|
s.add_runtime_dependency(%q<chef>, [">= 0.7"])
|
28
28
|
s.add_runtime_dependency(%q<json>, [">= 0"])
|
29
|
+
s.add_runtime_dependency(%q<json_pure>, [">= 0"])
|
29
30
|
s.add_runtime_dependency(%q<couchrest>, [">= 0"])
|
31
|
+
s.add_runtime_dependency(%q<rest-client>, [">= 0"])
|
30
32
|
s.add_development_dependency(%q<hoe>, [">= 2.3.3"])
|
31
33
|
else
|
32
34
|
s.add_dependency(%q<ip>, [">= 0"])
|
33
35
|
s.add_dependency(%q<choice>, [">= 0"])
|
34
36
|
s.add_dependency(%q<chef>, [">= 0.7"])
|
35
37
|
s.add_dependency(%q<json>, [">= 0"])
|
38
|
+
s.add_dependency(%q<json_pure>, [">= 0"])
|
36
39
|
s.add_dependency(%q<couchrest>, [">= 0"])
|
40
|
+
s.add_dependency(%q<rest-client>, [">= 0"])
|
37
41
|
s.add_dependency(%q<hoe>, [">= 2.3.3"])
|
38
42
|
end
|
39
43
|
else
|
@@ -41,7 +45,9 @@ Gem::Specification.new do |s|
|
|
41
45
|
s.add_dependency(%q<choice>, [">= 0"])
|
42
46
|
s.add_dependency(%q<chef>, [">= 0.7"])
|
43
47
|
s.add_dependency(%q<json>, [">= 0"])
|
48
|
+
s.add_dependency(%q<json_pure>, [">= 0"])
|
44
49
|
s.add_dependency(%q<couchrest>, [">= 0"])
|
50
|
+
s.add_dependency(%q<rest-client>, [">= 0"])
|
45
51
|
s.add_dependency(%q<hoe>, [">= 2.3.3"])
|
46
52
|
end
|
47
53
|
end
|
data/lib/chef/knives.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef_knives
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "0.
|
4
|
+
version: "0.7"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sergio Rubio
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-10-08 00:00:00 +02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -52,6 +52,16 @@ dependencies:
|
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: "0"
|
54
54
|
version:
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: json_pure
|
57
|
+
type: :runtime
|
58
|
+
version_requirement:
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
61
|
+
- - ">="
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: "0"
|
64
|
+
version:
|
55
65
|
- !ruby/object:Gem::Dependency
|
56
66
|
name: couchrest
|
57
67
|
type: :runtime
|
@@ -62,6 +72,16 @@ dependencies:
|
|
62
72
|
- !ruby/object:Gem::Version
|
63
73
|
version: "0"
|
64
74
|
version:
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: rest-client
|
77
|
+
type: :runtime
|
78
|
+
version_requirement:
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - ">="
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: "0"
|
84
|
+
version:
|
65
85
|
- !ruby/object:Gem::Dependency
|
66
86
|
name: hoe
|
67
87
|
type: :development
|
@@ -81,6 +101,7 @@ executables:
|
|
81
101
|
- chef_node_fs_usage
|
82
102
|
- chef_node_last_checkin
|
83
103
|
- chef_node_mem_usage
|
104
|
+
- chef_node_revisions
|
84
105
|
- chef_node_stats
|
85
106
|
- chef_vlan_stats
|
86
107
|
extensions: []
|
@@ -100,6 +121,7 @@ files:
|
|
100
121
|
- bin/chef_node_fs_usage
|
101
122
|
- bin/chef_node_last_checkin
|
102
123
|
- bin/chef_node_mem_usage
|
124
|
+
- bin/chef_node_revisions
|
103
125
|
- bin/chef_node_stats
|
104
126
|
- bin/chef_vlan_stats
|
105
127
|
- chef_knives.gemspec
|