Sha256: 2fd3d12ebc53d1e2a22c9b36e4ccd42f345ade8431c3e7859c4961b019518e5b

Contents?: true

Size: 1.32 KB

Versions: 7

Compression:

Stored size: 1.32 KB

Contents

require 'chef/provider/lwrp_base'
require 'chef_metal/chef_provider_action_handler'
require 'chef_metal/machine'

class Chef
class Provider
class MachineFile < Chef::Provider::LWRPBase

  def action_handler
    @action_handler ||= ChefMetal::ChefProviderActionHandler.new(self)
  end

  use_inline_resources

  def whyrun_supported?
    true
  end

  def machine
    @machine ||= begin
      if new_resource.machine.kind_of?(ChefMetal::Machine)
        new_resource.machine
      else
        run_context.chef_metal.connect_to_machine(new_resource.machine, new_resource.chef_server)
      end
    end
  end

  action :upload do
    if new_resource.content
      machine.write_file(action_handler, new_resource.path, new_resource.content)
    else
      machine.upload_file(action_handler, new_resource.local_path, new_resource.path)
    end

    attributes = {}
    attributes[:group] = new_resource.group if new_resource.group
    attributes[:owner] = new_resource.owner if new_resource.owner
    attributes[:mode] = new_resource.mode if new_resource.mode

    machine.set_attributes(action_handler, new_resource.path, attributes)
  end

  action :download do
    machine.download_file(action_handler, new_resource.path, new_resource.local_path)
  end

  action :delete do
    machine.delete_file(action_handler, new_resource.path)
  end

end
end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
clc-fork-chef-metal-0.14.alpha.10 lib/chef/provider/machine_file.rb
clc-fork-chef-metal-0.14.alpha.9 lib/chef/provider/machine_file.rb
clc-fork-chef-metal-0.14.alpha.8 lib/chef/provider/machine_file.rb
clc-fork-chef-metal-0.14.alpha.7 lib/chef/provider/machine_file.rb
clc-fork-chef-metal-0.14.alpha.6 lib/chef/provider/machine_file.rb
clc-fork-chef-metal-0.14.alpha.5 lib/chef/provider/machine_file.rb
clc-fork-chef-metal-0.14.alpha.4 lib/chef/provider/machine_file.rb