lib/chef/provider/machine_execute.rb in chef-metal-0.10.2 vs lib/chef/provider/machine_execute.rb in chef-metal-0.11.beta
- old
+ new
@@ -1,12 +1,14 @@
require 'chef/provider/lwrp_base'
-require 'cheffish/cheffish_server_api'
-require 'chef_metal/provider_action_handler'
+require 'chef_metal/chef_provider_action_handler'
+require 'chef_metal/machine'
class Chef::Provider::MachineExecute < Chef::Provider::LWRPBase
- include ChefMetal::ProviderActionHandler
+ def action_handler
+ @action_handler ||= ChefMetal::ChefProviderActionHandler.new(self)
+ end
use_inline_resources
def whyrun_supported?
true
@@ -15,16 +17,14 @@
def machine
@machine ||= begin
if new_resource.machine.kind_of?(ChefMetal::Machine)
new_resource.machine
else
- # TODO this is inefficient, can we cache or something?
- node = Cheffish::CheffishServerAPI.new(new_resource.chef_server).get("/nodes/#{new_resource.machine}")
- new_resource.provisioner.connect_to_machine(node)
+ run_context.chef_metal.connect_to_machine(new_resource.machine, new_resource.chef_server)
end
end
end
action :run do
- machine.execute(self, new_resource.command)
+ machine.execute(action_handler, new_resource.command)
end
end