Class: Chef::Provisioning::ChefProviderActionHandler

Inherits:
ActionHandler
  • Object
show all
Defined in:
lib/chef/provisioning/chef_provider_action_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(provider) ⇒ ChefProviderActionHandler

Returns a new instance of ChefProviderActionHandler


26
27
28
# File 'lib/chef/provisioning/chef_provider_action_handler.rb', line 26

def initialize(provider)
  @provider = provider
end

Instance Attribute Details

#providerObject (readonly)

Returns the value of attribute provider


30
31
32
# File 'lib/chef/provisioning/chef_provider_action_handler.rb', line 30

def provider
  @provider
end

Instance Method Details

#host_nodeObject


69
70
71
# File 'lib/chef/provisioning/chef_provider_action_handler.rb', line 69

def host_node
  "#{provider.run_context.config[:chef_server_url]}/nodes/#{provider.run_context.node['name']}"
end

#open_stream(name, &block) ⇒ Object


57
58
59
60
61
62
63
64
65
66
67
# File 'lib/chef/provisioning/chef_provider_action_handler.rb', line 57

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


53
54
55
# File 'lib/chef/provisioning/chef_provider_action_handler.rb', line 53

def perform_action(description, &block)
  provider.converge_by(description, &block)
end

#performed_action(description) ⇒ Object


47
48
49
50
51
# File 'lib/chef/provisioning/chef_provider_action_handler.rb', line 47

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


40
41
42
43
44
45
# File 'lib/chef/provisioning/chef_provider_action_handler.rb', line 40

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_actionsObject


36
37
38
# File 'lib/chef/provisioning/chef_provider_action_handler.rb', line 36

def should_perform_actions
  !provider.run_context.config.why_run
end

#updated!Object


32
33
34
# File 'lib/chef/provisioning/chef_provider_action_handler.rb', line 32

def updated!
  provider.new_resource.updated_by_last_action(true)
end