Class: ChefMetal::ChefProviderActionHandler
- Inherits:
-
ActionHandler
- Object
- ActionHandler
- ChefMetal::ChefProviderActionHandler
- Defined in:
- lib/chef_metal/chef_provider_action_handler.rb
Instance Attribute Summary collapse
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
Instance Method Summary collapse
- #host_node ⇒ Object
-
#initialize(provider) ⇒ ChefProviderActionHandler
constructor
A new instance of ChefProviderActionHandler.
- #open_stream(name, &block) ⇒ Object
- #perform_action(description, &block) ⇒ Object
- #performed_action(description) ⇒ Object
- #report_progress(description) ⇒ Object
- #should_perform_actions ⇒ Object
- #updated! ⇒ Object
Constructor Details
#initialize(provider) ⇒ ChefProviderActionHandler
Returns a new instance of ChefProviderActionHandler.
25 26 27 |
# File 'lib/chef_metal/chef_provider_action_handler.rb', line 25 def initialize(provider) @provider = provider end |
Instance Attribute Details
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
29 30 31 |
# File 'lib/chef_metal/chef_provider_action_handler.rb', line 29 def provider @provider end |
Instance Method Details
#host_node ⇒ Object
68 69 70 |
# File 'lib/chef_metal/chef_provider_action_handler.rb', line 68 def host_node "#{provider.run_context.config[:chef_server_url]}/nodes/#{provider.run_context.node['name']}" end |
#open_stream(name, &block) ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/chef_metal/chef_provider_action_handler.rb', line 56 def open_stream(name, &block) if provider.run_context.respond_to?(:open_stream) provider.run_context.open_stream({ :name => name }, &block) else if block_given? yield STDOUT else STDOUT end end end |
#perform_action(description, &block) ⇒ Object
52 53 54 |
# File 'lib/chef_metal/chef_provider_action_handler.rb', line 52 def perform_action(description, &block) provider.converge_by(description, &block) end |
#performed_action(description) ⇒ Object
46 47 48 49 50 |
# File 'lib/chef_metal/chef_provider_action_handler.rb', line 46 def performed_action(description) provider.converge_by description do # We already did the action, but we trust whoever told us that they did it. end end |
#report_progress(description) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/chef_metal/chef_provider_action_handler.rb', line 39 def report_progress(description) # TODO this seems wrong but Chef doesn't have another thing provider.converge_by description do # We already did the action, but we trust whoever told us that they did it. end end |
#should_perform_actions ⇒ Object
35 36 37 |
# File 'lib/chef_metal/chef_provider_action_handler.rb', line 35 def should_perform_actions !provider.run_context.config.why_run end |
#updated! ⇒ Object
31 32 33 |
# File 'lib/chef_metal/chef_provider_action_handler.rb', line 31 def updated! provider.new_resource.updated_by_last_action(true) end |