microwave 0.1004.5 → 0.1004.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -23,6 +23,7 @@ class Chef
23
23
  module ShellOut
24
24
 
25
25
  def shell_out(*command_args)
26
+ Chef::Log.debug "Shelling out: #{command_args.join(" ")}"
26
27
  cmd = Chef::ShellOut.new(*command_args)
27
28
  if STDOUT.tty? && Chef::Log.debug?
28
29
  cmd.live_stream = STDOUT
@@ -398,35 +398,6 @@ class Chef
398
398
  self
399
399
  end
400
400
 
401
- # Create a Chef::Node from JSON
402
- def self.json_create(o)
403
- node = new
404
- node.name(o["name"])
405
- node.chef_environment(o["chef_environment"])
406
- if o.has_key?("attributes")
407
- node.normal_attrs = o["attributes"]
408
- end
409
- node.automatic_attrs = Mash.new(o["automatic"]) if o.has_key?("automatic")
410
- node.normal_attrs = Mash.new(o["normal"]) if o.has_key?("normal")
411
- node.default_attrs = Mash.new(o["default"]) if o.has_key?("default")
412
- node.override_attrs = Mash.new(o["override"]) if o.has_key?("override")
413
-
414
- if o.has_key?("run_list")
415
- node.run_list.reset!(o["run_list"])
416
- else
417
- o["recipes"].each { |r| node.recipes << r }
418
- end
419
- node
420
- end
421
-
422
- def self.find_or_create(node_name)
423
- load(node_name)
424
- rescue Net::HTTPServerException => e
425
- raise unless e.response.code == '404'
426
- node = build(node_name)
427
- node.create
428
- end
429
-
430
401
  def self.build(node_name)
431
402
  node = new
432
403
  node.name(node_name)
@@ -55,6 +55,7 @@ class Chef
55
55
  opts[:live_stream] = STDOUT
56
56
  end
57
57
 
58
+ Chef::Log.debug "Executing: #{@new_resource.command} #{$testrun}"
58
59
  result = $testrun || shell_out!(@new_resource.command, opts)
59
60
  @new_resource.updated_by_last_action(true)
60
61
  Chef::Log.info("#{@new_resource} ran successfully")
@@ -179,9 +179,7 @@ class Chef
179
179
  file ||= @new_resource.path
180
180
  if @new_resource.backup != false && @new_resource.backup > 0 && ::File.exist?(file)
181
181
  time = Time.now
182
- savetime = time.strftime("%Y%m%d%H%M%S")
183
- backup_filename = "#{@new_resource.path}.chef-#{savetime}"
184
- backup_filename = backup_filename.sub(/^([A-Za-z]:)/, "") #strip drive letter on Windows
182
+ backup_filename = @new_resource.path
185
183
  # if :file_backup_path is nil, we fallback to the old behavior of
186
184
  # keeping the backup in the same directory. We also need to to_s it
187
185
  # so we don't get a type error around implicit to_str conversions.
@@ -190,17 +188,6 @@ class Chef
190
188
  FileUtils.mkdir_p(::File.dirname(backup_path)) if Chef::Config[:file_backup_path]
191
189
  FileUtils.cp(file, backup_path, :preserve => true)
192
190
  Chef::Log.info("#{@new_resource} backed up to #{backup_path}")
193
-
194
- # Clean up after the number of backups
195
- slice_number = @new_resource.backup
196
- backup_files = Dir[::File.join(prefix, ".#{@new_resource.path}.chef-*")].sort { |a,b| b <=> a }
197
- if backup_files.length >= @new_resource.backup
198
- remainder = backup_files.slice(slice_number..-1)
199
- remainder.each do |backup_to_delete|
200
- FileUtils.rm(backup_to_delete)
201
- Chef::Log.info("#{@new_resource} removed backup at #{backup_to_delete}")
202
- end
203
- end
204
191
  end
205
192
  end
206
193
 
@@ -405,7 +405,7 @@ F
405
405
  end
406
406
 
407
407
  def run_action(action)
408
- Chef::Log.info("Processing #{self} action #{action} (#{defined_at})")
408
+ Chef::Log.debug("Processing #{self} action #{action} (#{defined_at})")
409
409
 
410
410
  # ensure that we don't leave @updated_by_last_action set to true
411
411
  # on accident
@@ -140,63 +140,6 @@ class Chef
140
140
  self
141
141
  end
142
142
 
143
- # Create a Chef::Role from JSON
144
- def self.json_create(o)
145
- role = new
146
- role.name(o["name"])
147
- role.description(o["description"])
148
- role.default_attributes(o["default_attributes"])
149
- role.override_attributes(o["override_attributes"])
150
-
151
- # _default run_list is in 'run_list' for newer clients, and
152
- # 'recipes' for older clients.
153
- env_run_list_hash = {"_default" => (o.has_key?("run_list") ? o["run_list"] : o["recipes"])}
154
-
155
- # Clients before 0.10 do not include env_run_lists, so only
156
- # merge if it's there.
157
- if o["env_run_lists"]
158
- env_run_list_hash.merge!(o["env_run_lists"])
159
- end
160
- role.env_run_lists(env_run_list_hash)
161
-
162
- role
163
- end
164
-
165
- # Load a role by name from the API
166
- def self.load(name)
167
- chef_server_rest.get_rest("roles/#{name}")
168
- end
169
-
170
- def environment(env_name)
171
- chef_server_rest.get_rest("roles/#{@name}/environments/#{env_name}")
172
- end
173
-
174
- def environments
175
- chef_server_rest.get_rest("roles/#{@name}/environments")
176
- end
177
-
178
- # Remove this role via the REST API
179
- def destroy
180
- chef_server_rest.delete_rest("roles/#{@name}")
181
- end
182
-
183
- # Save this role via the REST API
184
- def save
185
- begin
186
- chef_server_rest.put_rest("roles/#{@name}", self)
187
- rescue Net::HTTPServerException => e
188
- raise e unless e.response.code == "404"
189
- chef_server_rest.post_rest("roles", self)
190
- end
191
- self
192
- end
193
-
194
- # Create the role via the REST API
195
- def create
196
- chef_server_rest.post_rest("roles", self)
197
- self
198
- end
199
-
200
143
  # As a string
201
144
  def to_s
202
145
  "role[#{@name}]"
@@ -204,17 +147,19 @@ class Chef
204
147
 
205
148
  # Load a role from disk - prefers to load the JSON, but will happily load
206
149
  # the raw rb files as well.
207
- def self.from_disk(name, force=nil)
208
- js_file = File.join(Chef::Config[:role_path], "#{name}.json")
209
- rb_file = File.join(Chef::Config[:role_path], "#{name}.rb")
210
-
211
- if File.exists?(js_file) || force == "json"
212
- # from_json returns object.class => json_class in the JSON.
213
- Chef::JSONCompat.from_json(IO.read(js_file))
214
- elsif File.exists?(rb_file) || force == "ruby"
215
- role = Chef::Role.new
216
- role.name(name)
217
- role.from_file(rb_file)
150
+ def self.from_disk(name)
151
+ role = nil
152
+ Chef::Config[:role_path].each do |rp|
153
+ rb_file = File.join(rp, "#{name}.rb")
154
+
155
+ if File.exists?(rb_file) && role.nil?
156
+ role = Chef::Role.new
157
+ role.name(name)
158
+ role.from_file(rb_file)
159
+ end
160
+ end
161
+
162
+ if role
218
163
  role
219
164
  else
220
165
  raise Chef::Exceptions::RoleNotFound, "Role '#{name}' could not be loaded from disk"
@@ -31,7 +31,7 @@ class Chef
31
31
  # Used to load the node's recipes after expanding its run list
32
32
  include Chef::Mixin::LanguageIncludeRecipe
33
33
 
34
- attr_reader :node, :cookbook_collection, :definitions
34
+ attr_reader :node, :cookbook_collection
35
35
 
36
36
  # Needs to be settable so deploy can run a resource_collection independent
37
37
  # of any cookbooks.
@@ -46,7 +46,6 @@ class Chef
46
46
  @node = node
47
47
  @cookbook_collection = cookbook_collection
48
48
  @resource_collection = Chef::ResourceCollection.new
49
- @definitions = Hash.new
50
49
 
51
50
  # TODO: 5/18/2010 cw/timh - See note on Chef::Node's
52
51
  # cookbook_collection attr_accessor
@@ -58,7 +57,6 @@ class Chef
58
57
  load_lwrp_providers
59
58
  load_lwrp_resources
60
59
  load_attributes
61
- load_resource_definitions
62
60
 
63
61
  # Precendence rules state that roles' attributes come after
64
62
  # cookbooks. Now we've loaded attributes from cookbooks with
@@ -101,18 +99,6 @@ class Chef
101
99
  node.load_attributes
102
100
  end
103
101
 
104
- def load_resource_definitions
105
- foreach_cookbook_load_segment(:definitions) do |cookbook_name, filename|
106
- Chef::Log.debug("Loading cookbook #{cookbook_name}'s definitions from #{filename}")
107
- resourcelist = Chef::ResourceDefinitionList.new
108
- resourcelist.from_file(filename)
109
- definitions.merge!(resourcelist.defines) do |key, oldval, newval|
110
- Chef::Log.info("Overriding duplicate definition #{key}, new definition found in #{filename}")
111
- newval
112
- end
113
- end
114
- end
115
-
116
102
  def foreach_cookbook_load_segment(segment, &block)
117
103
  cookbook_collection.each do |cookbook_name, cookbook|
118
104
  segment_filenames = cookbook.segment_filenames(segment)
@@ -88,7 +88,6 @@ def create_cookbook(dir)
88
88
  puts "** Creating cookbook #{ENV["COOKBOOK"]}"
89
89
  sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "attributes")}"
90
90
  sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "recipes")}"
91
- sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "definitions")}"
92
91
  sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "libraries")}"
93
92
  sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "resources")}"
94
93
  sh "mkdir -p #{File.join(dir, ENV["COOKBOOK"], "providers")}"
@@ -17,7 +17,7 @@
17
17
 
18
18
  class Chef
19
19
  CHEF_ROOT = File.dirname(File.expand_path(File.dirname(__FILE__)))
20
- VERSION = '0.1004.5'
20
+ VERSION = '0.1004.6'
21
21
  end
22
22
 
23
23
  # NOTE: the Chef::Version class is defined in version_class.rb
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: microwave
3
3
  version: !ruby/object:Gem::Version
4
- hash: 4005
4
+ hash: 4003
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 1004
9
- - 5
10
- version: 0.1004.5
9
+ - 6
10
+ version: 0.1004.6
11
11
  platform: ruby
12
12
  authors:
13
13
  - Tom Bombadil
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-11-24 00:00:00 Z
18
+ date: 2011-11-30 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: mixlib-config
@@ -90,7 +90,7 @@ dependencies:
90
90
  type: :runtime
91
91
  version_requirements: *id004
92
92
  - !ruby/object:Gem::Dependency
93
- name: erubis
93
+ name: hike
94
94
  prerelease: false
95
95
  requirement: &id005 !ruby/object:Gem::Requirement
96
96
  none: false
@@ -104,7 +104,7 @@ dependencies:
104
104
  type: :runtime
105
105
  version_requirements: *id005
106
106
  - !ruby/object:Gem::Dependency
107
- name: moneta
107
+ name: erubis
108
108
  prerelease: false
109
109
  requirement: &id006 !ruby/object:Gem::Requirement
110
110
  none: false
@@ -118,7 +118,7 @@ dependencies:
118
118
  type: :runtime
119
119
  version_requirements: *id006
120
120
  - !ruby/object:Gem::Dependency
121
- name: uuidtools
121
+ name: moneta
122
122
  prerelease: false
123
123
  requirement: &id007 !ruby/object:Gem::Requirement
124
124
  none: false
@@ -132,7 +132,7 @@ dependencies:
132
132
  type: :runtime
133
133
  version_requirements: *id007
134
134
  - !ruby/object:Gem::Dependency
135
- name: sdoc
135
+ name: uuidtools
136
136
  prerelease: false
137
137
  requirement: &id008 !ruby/object:Gem::Requirement
138
138
  none: false
@@ -146,7 +146,7 @@ dependencies:
146
146
  type: :runtime
147
147
  version_requirements: *id008
148
148
  - !ruby/object:Gem::Dependency
149
- name: fast_xs
149
+ name: sdoc
150
150
  prerelease: false
151
151
  requirement: &id009 !ruby/object:Gem::Requirement
152
152
  none: false
@@ -160,7 +160,7 @@ dependencies:
160
160
  type: :runtime
161
161
  version_requirements: *id009
162
162
  - !ruby/object:Gem::Dependency
163
- name: dep_selector
163
+ name: fast_xs
164
164
  prerelease: false
165
165
  requirement: &id010 !ruby/object:Gem::Requirement
166
166
  none: false
@@ -173,6 +173,20 @@ dependencies:
173
173
  version: "0"
174
174
  type: :runtime
175
175
  version_requirements: *id010
176
+ - !ruby/object:Gem::Dependency
177
+ name: dep_selector
178
+ prerelease: false
179
+ requirement: &id011 !ruby/object:Gem::Requirement
180
+ none: false
181
+ requirements:
182
+ - - ">="
183
+ - !ruby/object:Gem::Version
184
+ hash: 3
185
+ segments:
186
+ - 0
187
+ version: "0"
188
+ type: :runtime
189
+ version_requirements: *id011
176
190
  description: A systems integration framework, built to bring the benefits of configuration management to your entire infrastructure, forked from Opscode Chef
177
191
  email: amanibhavam@destructuring.org
178
192
  executables:
@@ -236,7 +250,6 @@ files:
236
250
  - lib/chef/monkey_patches/numeric.rb
237
251
  - lib/chef/monkey_patches/object.rb
238
252
  - lib/chef/monkey_patches/regexp.rb
239
- - lib/chef/monkey_patches/string.rb
240
253
  - lib/chef/monkey_patches/tempfile.rb
241
254
  - lib/chef/nil_argument.rb
242
255
  - lib/chef/node/attribute.rb
@@ -264,8 +277,6 @@ files:
264
277
  - lib/chef/resource.rb
265
278
  - lib/chef/resource_collection/stepable_iterator.rb
266
279
  - lib/chef/resource_collection.rb
267
- - lib/chef/resource_definition.rb
268
- - lib/chef/resource_definition_list.rb
269
280
  - lib/chef/resources.rb
270
281
  - lib/chef/role.rb
271
282
  - lib/chef/run_context.rb
@@ -280,10 +291,6 @@ files:
280
291
  - lib/chef/shell_out.rb
281
292
  - lib/chef/tasks/chef_repo.rake
282
293
  - lib/chef/util/file_edit.rb
283
- - lib/chef/util/windows/net_group.rb
284
- - lib/chef/util/windows/net_use.rb
285
- - lib/chef/util/windows/net_user.rb
286
- - lib/chef/util/windows/volume.rb
287
294
  - lib/chef/util/windows.rb
288
295
  - lib/chef/version.rb
289
296
  - lib/chef/version_class.rb
@@ -1,49 +0,0 @@
1
- #
2
- # Author:: Adam Jacob (<adam@opscode.com>)
3
- # Copyright:: Copyright (c) 2008 Opscode, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- # == String (Patch)
20
- # On ruby 1.9, Strings are aware of multibyte characters, so +size+ and +length+
21
- # give the actual number of characters. In Chef::REST, we need the bytesize
22
- # so we can correctly set the Content-Length headers, but ruby 1.8.6 and lower
23
- # don't define String#bytesize. Monkey patching time!
24
-
25
- begin
26
- require 'enumerator'
27
- rescue LoadError
28
- end
29
-
30
- class String
31
- unless method_defined?(:bytesize)
32
- alias :bytesize :size
33
- end
34
-
35
- unless method_defined?(:lines)
36
- def lines
37
- enum_for(:each)
38
- end
39
- end
40
- end
41
-
42
- # <= 1.8.6 needs some ord!
43
- class String
44
- unless method_defined?(:ord)
45
- def ord
46
- self.unpack('c').first
47
- end
48
- end
49
- end
@@ -1,67 +0,0 @@
1
- #
2
- # Author:: Adam Jacob (<adam@opscode.com>)
3
- # Copyright:: Copyright (c) 2008 Opscode, Inc.
4
- # License:: Apache License, Version 2.0
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
- #
18
-
19
- require 'chef/mixin/from_file'
20
- require 'chef/mixin/params_validate'
21
-
22
- class Chef
23
- class ResourceDefinition
24
-
25
- include Chef::Mixin::FromFile
26
- include Chef::Mixin::ParamsValidate
27
-
28
- attr_accessor :name, :params, :recipe, :node
29
-
30
- def initialize(node=nil)
31
- @name = nil
32
- @params = Hash.new
33
- @recipe = nil
34
- @node = node
35
- end
36
-
37
- def define(resource_name, prototype_params=nil, &block)
38
- unless resource_name.kind_of?(Symbol)
39
- raise ArgumentError, "You must use a symbol when defining a new resource!"
40
- end
41
- @name = resource_name
42
- if prototype_params
43
- unless prototype_params.kind_of?(Hash)
44
- raise ArgumentError, "You must pass a hash as the prototype parameters for a definition."
45
- end
46
- @params = prototype_params
47
- end
48
- if Kernel.block_given?
49
- @recipe = block
50
- else
51
- raise ArgumentError, "You must pass a block to a definition."
52
- end
53
- true
54
- end
55
-
56
- # When we do the resource definition, we're really just setting new values for
57
- # the paramaters we prototyped at the top. This method missing is as simple as
58
- # it gets.
59
- def method_missing(symbol, *args)
60
- @params[symbol] = args.length == 1 ? args[0] : args
61
- end
62
-
63
- def to_s
64
- "#{name.to_s}"
65
- end
66
- end
67
- end