chef-expander 0.10.0.beta.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,58 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Author:: Daniel DeLeo (<dan@opscode.com>)
4
+ # Author:: Seth Falcon (<seth@opscode.com>)
5
+ # Author:: Chris Walters (<cw@opscode.com>)
6
+ # Copyright:: Copyright (c) 2010-2011 Opscode, Inc.
7
+ # License:: Apache License, Version 2.0
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+ #
21
+
22
+ require "rubygems"
23
+ $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
24
+
25
+ require 'yajl'
26
+ require 'chef/expander/solrizer'
27
+
28
+ USAGE = <<-EOH
29
+ #{$0} [file ...]
30
+
31
+ Convert Chef object JSON files into XML documents of the same name but
32
+ with a ".xml" extension containing the XML used for Solr indexing.
33
+ EOH
34
+
35
+ if ARGV.size == 0
36
+ abort USAGE
37
+ end
38
+
39
+ ARGV.each do |obj_file|
40
+ raw_json = open(obj_file, "r").read
41
+ item_json = Yajl::Parser.parse(raw_json)
42
+ payload = {
43
+ :item => item_json,
44
+ :type => item_json["chef_type"].to_s,
45
+ :database => "riak_search_test",
46
+ :id => item_json["name"],
47
+ :enqueued_at => Time.now.to_i
48
+ }
49
+ update_obj = {:action => "add", :payload => payload}
50
+ update_json = Yajl::Encoder.encode(update_obj)
51
+ solrizer = Chef::Expander::Solrizer.new(update_json) { :no_op }
52
+ solrizer.log.init(StringIO.new)
53
+
54
+ out = File.basename(obj_file).sub(/\.json$/, "") + ".xml"
55
+ open(out, "w") do |f|
56
+ f.write(solrizer.pointyize_add)
57
+ end
58
+ end
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Author:: Daniel DeLeo (<dan@opscode.com>)
4
+ # Author:: Seth Falcon (<seth@opscode.com>)
5
+ # Author:: Chris Walters (<cw@opscode.com>)
6
+ # Copyright:: Copyright (c) 2010-2011 Opscode, Inc.
7
+ # License:: Apache License, Version 2.0
8
+ #
9
+ # Licensed under the Apache License, Version 2.0 (the "License");
10
+ # you may not use this file except in compliance with the License.
11
+ # You may obtain a copy of the License at
12
+ #
13
+ # http://www.apache.org/licenses/LICENSE-2.0
14
+ #
15
+ # Unless required by applicable law or agreed to in writing, software
16
+ # distributed under the License is distributed on an "AS IS" BASIS,
17
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
+ # See the License for the specific language governing permissions and
19
+ # limitations under the License.
20
+ #
21
+
22
+ require "rubygems"
23
+
24
+ $:.unshift(File.expand_path(File.dirname(__FILE__) + '/../lib'))
25
+
26
+ require 'pp'
27
+ require 'bunny'
28
+ require 'yajl'
29
+ require 'uuidtools'
30
+ require 'word_salad'
31
+
32
+ require 'chef_search/expander/configuration'
33
+
34
+ Chef::Expander.init_config(ARGV)
35
+
36
+ MESSAGES_TO_SEND = 10_000
37
+
38
+ NUM_RAND_KEY_PAIRS = 50
39
+ NUM_RAND_VALUE_PAIRS = 50
40
+
41
+ PERSISTENT_MESSAGES = true
42
+
43
+ KEYS = NUM_RAND_VALUE_PAIRS.words
44
+
45
+ SAMPLE_NODES = []
46
+ Dir.glob(File.expand_path(File.dirname(__FILE__)) + '/../data/*_node.json') do |node_file|
47
+ SAMPLE_NODES << Yajl::Parser.parse(IO.read(node_file))
48
+ end
49
+
50
+ NUM_NODES = SAMPLE_NODES.size
51
+ puts "Read #{NUM_NODES} sample nodes"
52
+
53
+ puts "Using rabbitmq config #{Chef::Expander.config.amqp_config.inspect}"
54
+
55
+ puts "connecting to rabbitmq"
56
+ amqp_client = Bunny.new(Chef::Expander.config.amqp_config)
57
+ amqp_client.start
58
+
59
+ puts 'declaring queues'
60
+ queues = {}
61
+ 0.upto(1023) do |vnode|
62
+ queues[vnode] = amqp_client.queue("vnode-#{vnode}", :durable => true)
63
+ end
64
+
65
+ def add_rand_keys(node)
66
+ rand_key_vals = Hash[*((2 * NUM_RAND_KEY_PAIRS).words)]
67
+ rand_vals = Hash[*(KEYS.zip(NUM_RAND_VALUE_PAIRS.words)).flatten]
68
+ node.merge(rand_key_vals.merge(rand_vals))
69
+ end
70
+
71
+ puts "sending #{MESSAGES_TO_SEND} messages"
72
+ start_time = Time.now
73
+ sent_messages = 0
74
+ 1.upto(MESSAGES_TO_SEND) do
75
+ node = SAMPLE_NODES[rand(NUM_NODES)]
76
+ node = add_rand_keys(node)
77
+ index_data = {:action => :add}
78
+ index_data[:payload] = {:item => node}
79
+ index_data[:payload][:type] = :node
80
+ index_data[:payload][:database] = :testdb
81
+ index_data[:payload][:enqueued_at] = Time.now.utc.to_i
82
+
83
+ id = node["name"]
84
+ vnode = rand(1024)
85
+ index_data[:payload][:id] = id
86
+
87
+ puts "queue: vnode-#{vnode} (#{sent_messages} / #{MESSAGES_TO_SEND})"
88
+ amqp_client.tx_select if PERSISTENT_MESSAGES
89
+ queues[vnode].publish(Yajl::Encoder.encode(index_data), :persistent => PERSISTENT_MESSAGES)
90
+ amqp_client.tx_commit if PERSISTENT_MESSAGES
91
+ sent_messages += 1
92
+ end
93
+ end_time = Time.now
94
+
95
+ total_time = end_time - start_time
96
+ rate = MESSAGES_TO_SEND.to_f / total_time
97
+ puts "done (#{total_time}s, #{rate} msg/s)"
metadata ADDED
@@ -0,0 +1,202 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chef-expander
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: 7
5
+ version: 0.10.0.beta.0
6
+ platform: ruby
7
+ authors:
8
+ - Adam Jacob
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2011-03-28 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: mixlib-log
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 1.2.0
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: amqp
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ~>
34
+ - !ruby/object:Gem::Version
35
+ version: 0.6.7
36
+ type: :runtime
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: eventmachine
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ~>
45
+ - !ruby/object:Gem::Version
46
+ version: 0.12.10
47
+ type: :runtime
48
+ version_requirements: *id003
49
+ - !ruby/object:Gem::Dependency
50
+ name: em-http-request
51
+ prerelease: false
52
+ requirement: &id004 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ~>
56
+ - !ruby/object:Gem::Version
57
+ version: 0.2.11
58
+ type: :runtime
59
+ version_requirements: *id004
60
+ - !ruby/object:Gem::Dependency
61
+ name: yajl-ruby
62
+ prerelease: false
63
+ requirement: &id005 !ruby/object:Gem::Requirement
64
+ none: false
65
+ requirements:
66
+ - - ~>
67
+ - !ruby/object:Gem::Version
68
+ version: 0.7.7
69
+ type: :runtime
70
+ version_requirements: *id005
71
+ - !ruby/object:Gem::Dependency
72
+ name: uuidtools
73
+ prerelease: false
74
+ requirement: &id006 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - ~>
78
+ - !ruby/object:Gem::Version
79
+ version: 2.1.1
80
+ type: :runtime
81
+ version_requirements: *id006
82
+ - !ruby/object:Gem::Dependency
83
+ name: bunny
84
+ prerelease: false
85
+ requirement: &id007 !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ~>
89
+ - !ruby/object:Gem::Version
90
+ version: 0.6.0
91
+ type: :runtime
92
+ version_requirements: *id007
93
+ - !ruby/object:Gem::Dependency
94
+ name: fast_xs
95
+ prerelease: false
96
+ requirement: &id008 !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ~>
100
+ - !ruby/object:Gem::Version
101
+ version: 0.7.3
102
+ type: :runtime
103
+ version_requirements: *id008
104
+ - !ruby/object:Gem::Dependency
105
+ name: highline
106
+ prerelease: false
107
+ requirement: &id009 !ruby/object:Gem::Requirement
108
+ none: false
109
+ requirements:
110
+ - - ~>
111
+ - !ruby/object:Gem::Version
112
+ version: 1.6.1
113
+ type: :runtime
114
+ version_requirements: *id009
115
+ - !ruby/object:Gem::Dependency
116
+ name: rake
117
+ prerelease: false
118
+ requirement: &id010 !ruby/object:Gem::Requirement
119
+ none: false
120
+ requirements:
121
+ - - ~>
122
+ - !ruby/object:Gem::Version
123
+ version: 0.8.7
124
+ type: :runtime
125
+ version_requirements: *id010
126
+ - !ruby/object:Gem::Dependency
127
+ name: bunny
128
+ prerelease: false
129
+ requirement: &id011 !ruby/object:Gem::Requirement
130
+ none: false
131
+ requirements:
132
+ - - ">="
133
+ - !ruby/object:Gem::Version
134
+ version: 0.6.0
135
+ type: :runtime
136
+ version_requirements: *id011
137
+ description: A systems integration framework, built to bring the benefits of configuration management to your entire infrastructure.
138
+ email: adam@opscode.com
139
+ executables:
140
+ - chef-expander
141
+ - chef-expander-cluster
142
+ - chef-expanderctl
143
+ extensions: []
144
+
145
+ extra_rdoc_files:
146
+ - README.rdoc
147
+ - LICENSE
148
+ files:
149
+ - LICENSE
150
+ - README.rdoc
151
+ - scripts/check_queue_size
152
+ - scripts/check_queue_size_munin
153
+ - scripts/make_solr_xml
154
+ - scripts/traffic-creator
155
+ - conf/chef-expander.rb.example
156
+ - lib/chef/expander/cluster_supervisor.rb
157
+ - lib/chef/expander/configuration.rb
158
+ - lib/chef/expander/control.rb
159
+ - lib/chef/expander/daemonizable.rb
160
+ - lib/chef/expander/flattener.rb
161
+ - lib/chef/expander/loggable.rb
162
+ - lib/chef/expander/logger.rb
163
+ - lib/chef/expander/node.rb
164
+ - lib/chef/expander/solrizer.rb
165
+ - lib/chef/expander/version.rb
166
+ - lib/chef/expander/vnode.rb
167
+ - lib/chef/expander/vnode_supervisor.rb
168
+ - lib/chef/expander/vnode_table.rb
169
+ - lib/chef/expander.rb
170
+ - bin/chef-expander
171
+ - bin/chef-expander-cluster
172
+ - bin/chef-expanderctl
173
+ has_rdoc: true
174
+ homepage: http://wiki.opscode.com/display/chef
175
+ licenses: []
176
+
177
+ post_install_message:
178
+ rdoc_options: []
179
+
180
+ require_paths:
181
+ - lib
182
+ required_ruby_version: !ruby/object:Gem::Requirement
183
+ none: false
184
+ requirements:
185
+ - - ">="
186
+ - !ruby/object:Gem::Version
187
+ version: "0"
188
+ required_rubygems_version: !ruby/object:Gem::Requirement
189
+ none: false
190
+ requirements:
191
+ - - ">"
192
+ - !ruby/object:Gem::Version
193
+ version: 1.3.1
194
+ requirements: []
195
+
196
+ rubyforge_project:
197
+ rubygems_version: 1.6.2
198
+ signing_key:
199
+ specification_version: 3
200
+ summary: A systems integration framework, built to bring the benefits of configuration management to your entire infrastructure.
201
+ test_files: []
202
+