Class: Chef::Provisioning::Machine
- Inherits:
-
Object
- Object
- Chef::Provisioning::Machine
- Defined in:
- lib/chef/provisioning/machine.rb,
lib/chef/provisioning/machine/unix_machine.rb,
lib/chef/provisioning/machine/basic_machine.rb,
lib/chef/provisioning/machine/windows_machine.rb
Direct Known Subclasses
Defined Under Namespace
Classes: BasicMachine, UnixMachine, WindowsMachine
Instance Attribute Summary collapse
-
#machine_spec ⇒ Object
readonly
Returns the value of attribute machine_spec.
Instance Method Summary collapse
- #cleanup_convergence(action_handler) ⇒ Object
- #converge(action_handler) ⇒ Object
- #create_dir(action_handler, path) ⇒ Object
-
#delete_file(action_handler, path) ⇒ Object
Delete file.
-
#detect_os(action_handler) ⇒ Object
TODO get rid of the action_handler attribute, that is ridiculous Detect the OS on the machine (assumes the machine is up) Returns a triplet: platform, platform_version, machine_architecture = machine.detect_os(action_handler) This triplet is suitable for passing to the Chef metadata API: www.chef.io/chef/metadata?p=PLATFORM&pv=PLATFORM_VERSION&m=MACHINE_ARCHITECTURE.
- #disconnect ⇒ Object
- #download_file(action_handler, path, local_path) ⇒ Object
- #execute(action_handler, command, options = {}) ⇒ Object
- #execute_always(command, options = {}) ⇒ Object
-
#file_exists?(path) ⇒ Boolean
Return true or false depending on whether file exists.
-
#files_different?(path, local_path, content = nil) ⇒ Boolean
Return true or false depending on whether remote file differs from local path or content.
-
#get_attributes(path) ⇒ Object
Get file attributes { :mode, :owner, :group }.
-
#initialize(machine_spec) ⇒ Machine
constructor
A new instance of Machine.
-
#is_directory?(path) ⇒ Boolean
Return true if directory, false/nil if not.
-
#make_url_available_to_remote(local_url) ⇒ Object
Ensure the given URL can be reached by the remote side (possibly by port forwarding) Must return the URL that the remote side can use to reach the local_url.
- #name ⇒ Object
- #node ⇒ Object
- #read_file(path) ⇒ Object
-
#set_attributes(action_handler, path, attributes) ⇒ Object
Set file attributes { mode, :owner, :group }.
-
#setup_convergence(action_handler) ⇒ Object
Sets up everything necessary for convergence to happen on the machine.
- #upload_file(action_handler, local_path, path) ⇒ Object
- #write_file(action_handler, path, content) ⇒ Object
Constructor Details
#initialize(machine_spec) ⇒ Machine
Returns a new instance of Machine.
4 5 6 |
# File 'lib/chef/provisioning/machine.rb', line 4 def initialize(machine_spec) @machine_spec = machine_spec end |
Instance Attribute Details
#machine_spec ⇒ Object (readonly)
Returns the value of attribute machine_spec.
8 9 10 |
# File 'lib/chef/provisioning/machine.rb', line 8 def machine_spec @machine_spec end |
Instance Method Details
#cleanup_convergence(action_handler) ⇒ Object
29 30 31 |
# File 'lib/chef/provisioning/machine.rb', line 29 def cleanup_convergence(action_handler) raise "cleanup_convergence not overridden on #{self.class}" end |
#converge(action_handler) ⇒ Object
25 26 27 |
# File 'lib/chef/provisioning/machine.rb', line 25 def converge(action_handler) raise "converge not overridden on #{self.class}" end |
#create_dir(action_handler, path) ⇒ Object
57 58 59 |
# File 'lib/chef/provisioning/machine.rb', line 57 def create_dir(action_handler, path) raise "create_dir not overridden on #{self.class}" end |
#delete_file(action_handler, path) ⇒ Object
Delete file
62 63 64 |
# File 'lib/chef/provisioning/machine.rb', line 62 def delete_file(action_handler, path) raise "delete_file not overridden on #{self.class}" end |
#detect_os(action_handler) ⇒ Object
TODO get rid of the action_handler attribute, that is ridiculous Detect the OS on the machine (assumes the machine is up) Returns a triplet:
platform, platform_version, machine_architecture = machine.detect_os(action_handler)
This triplet is suitable for passing to the Chef metadata API: www.chef.io/chef/metadata?p=PLATFORM&pv=PLATFORM_VERSION&m=MACHINE_ARCHITECTURE
107 108 109 |
# File 'lib/chef/provisioning/machine.rb', line 107 def detect_os(action_handler) raise "detect_os not overridden on #{self.class}" end |
#disconnect ⇒ Object
97 98 99 |
# File 'lib/chef/provisioning/machine.rb', line 97 def disconnect raise "disconnect not overridden on #{self.class}" end |
#download_file(action_handler, path, local_path) ⇒ Object
45 46 47 |
# File 'lib/chef/provisioning/machine.rb', line 45 def download_file(action_handler, path, local_path) raise "read_file not overridden on #{self.class}" end |
#execute(action_handler, command, options = {}) ⇒ Object
33 34 35 |
# File 'lib/chef/provisioning/machine.rb', line 33 def execute(action_handler, command, = {}) raise "execute not overridden on #{self.class}" end |
#execute_always(command, options = {}) ⇒ Object
37 38 39 |
# File 'lib/chef/provisioning/machine.rb', line 37 def execute_always(command, = {}) raise "execute_always not overridden on #{self.class}" end |
#file_exists?(path) ⇒ Boolean
Return true or false depending on whether file exists
72 73 74 |
# File 'lib/chef/provisioning/machine.rb', line 72 def file_exists?(path) raise "file_exists? not overridden on #{self.class}" end |
#files_different?(path, local_path, content = nil) ⇒ Boolean
Return true or false depending on whether remote file differs from local path or content
77 78 79 |
# File 'lib/chef/provisioning/machine.rb', line 77 def files_different?(path, local_path, content=nil) raise "file_different? not overridden on #{self.class}" end |
#get_attributes(path) ⇒ Object
Get file attributes { :mode, :owner, :group }
87 88 89 |
# File 'lib/chef/provisioning/machine.rb', line 87 def get_attributes(path) raise "get_attributes not overridden on #{self.class}" end |
#is_directory?(path) ⇒ Boolean
Return true if directory, false/nil if not
67 68 69 |
# File 'lib/chef/provisioning/machine.rb', line 67 def is_directory?(path) raise "is_directory? not overridden on #{self.class}" end |
#make_url_available_to_remote(local_url) ⇒ Object
Ensure the given URL can be reached by the remote side (possibly by port forwarding) Must return the URL that the remote side can use to reach the local_url
93 94 95 |
# File 'lib/chef/provisioning/machine.rb', line 93 def make_url_available_to_remote(local_url) raise "make_url_available_to_remote not overridden on #{self.class}" end |
#name ⇒ Object
10 11 12 |
# File 'lib/chef/provisioning/machine.rb', line 10 def name machine_spec.name end |
#node ⇒ Object
14 15 16 |
# File 'lib/chef/provisioning/machine.rb', line 14 def node machine_spec.node end |
#read_file(path) ⇒ Object
41 42 43 |
# File 'lib/chef/provisioning/machine.rb', line 41 def read_file(path) raise "read_file not overridden on #{self.class}" end |
#set_attributes(action_handler, path, attributes) ⇒ Object
Set file attributes { mode, :owner, :group }
82 83 84 |
# File 'lib/chef/provisioning/machine.rb', line 82 def set_attributes(action_handler, path, attributes) raise "set_attributes not overridden on #{self.class}" end |
#setup_convergence(action_handler) ⇒ Object
Sets up everything necessary for convergence to happen on the machine. The node MUST be saved as part of this procedure. Other than that, nothing is guaranteed except that converge() will work when this is done.
21 22 23 |
# File 'lib/chef/provisioning/machine.rb', line 21 def setup_convergence(action_handler) raise "setup_convergence not overridden on #{self.class}" end |
#upload_file(action_handler, local_path, path) ⇒ Object
53 54 55 |
# File 'lib/chef/provisioning/machine.rb', line 53 def upload_file(action_handler, local_path, path) raise "write_file not overridden on #{self.class}" end |
#write_file(action_handler, path, content) ⇒ Object
49 50 51 |
# File 'lib/chef/provisioning/machine.rb', line 49 def write_file(action_handler, path, content) raise "write_file not overridden on #{self.class}" end |