Class: ChefMetal::Machine
- Inherits:
-
Object
- Object
- ChefMetal::Machine
- Defined in:
- lib/chef_metal/machine.rb,
lib/chef_metal/machine/unix_machine.rb,
lib/chef_metal/machine/basic_machine.rb,
lib/chef_metal/machine/windows_machine.rb
Direct Known Subclasses
Defined Under Namespace
Classes: BasicMachine, UnixMachine, WindowsMachine
Instance Attribute Summary collapse
-
#node ⇒ Object
readonly
Returns the value of attribute node.
Instance Method Summary collapse
- #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.opscode.com/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(node) ⇒ Machine
constructor
A new instance of Machine.
-
#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.
- #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(node) ⇒ Machine
Returns a new instance of Machine.
3 4 5 |
# File 'lib/chef_metal/machine.rb', line 3 def initialize(node) @node = node end |
Instance Attribute Details
#node ⇒ Object (readonly)
Returns the value of attribute node.
7 8 9 |
# File 'lib/chef_metal/machine.rb', line 7 def node @node end |
Instance Method Details
#converge(action_handler) ⇒ Object
16 17 18 |
# File 'lib/chef_metal/machine.rb', line 16 def converge(action_handler) raise "converge not overridden on #{self.class}" end |
#create_dir(action_handler, path) ⇒ Object
44 45 46 |
# File 'lib/chef_metal/machine.rb', line 44 def create_dir(action_handler, path) raise "create_dir not overridden on #{self.class}" end |
#delete_file(action_handler, path) ⇒ Object
Delete file
49 50 51 |
# File 'lib/chef_metal/machine.rb', line 49 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.opscode.com/chef/metadata?p=#platform&pv=#platform_version&m=#machine_architecture
89 90 91 |
# File 'lib/chef_metal/machine.rb', line 89 def detect_os(action_handler) raise "detect_os not overridden on #{self.class}" end |
#disconnect ⇒ Object
79 80 81 |
# File 'lib/chef_metal/machine.rb', line 79 def disconnect raise "disconnect not overridden on #{self.class}" end |
#download_file(action_handler, path, local_path) ⇒ Object
32 33 34 |
# File 'lib/chef_metal/machine.rb', line 32 def download_file(action_handler, path, local_path) raise "read_file not overridden on #{self.class}" end |
#execute(action_handler, command, options = {}) ⇒ Object
20 21 22 |
# File 'lib/chef_metal/machine.rb', line 20 def execute(action_handler, command, = {}) raise "execute not overridden on #{self.class}" end |
#execute_always(command, options = {}) ⇒ Object
24 25 26 |
# File 'lib/chef_metal/machine.rb', line 24 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
54 55 56 |
# File 'lib/chef_metal/machine.rb', line 54 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
59 60 61 |
# File 'lib/chef_metal/machine.rb', line 59 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 }
69 70 71 |
# File 'lib/chef_metal/machine.rb', line 69 def get_attributes(path) raise "get_attributes 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
75 76 77 |
# File 'lib/chef_metal/machine.rb', line 75 def make_url_available_to_remote(local_url) raise "make_url_available_to_remote not overridden on #{self.class}" end |
#read_file(path) ⇒ Object
28 29 30 |
# File 'lib/chef_metal/machine.rb', line 28 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 }
64 65 66 |
# File 'lib/chef_metal/machine.rb', line 64 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.
12 13 14 |
# File 'lib/chef_metal/machine.rb', line 12 def setup_convergence(action_handler) raise "setup_convergence not overridden on #{self.class}" end |
#upload_file(action_handler, local_path, path) ⇒ Object
40 41 42 |
# File 'lib/chef_metal/machine.rb', line 40 def upload_file(action_handler, local_path, path) raise "write_file not overridden on #{self.class}" end |
#write_file(action_handler, path, content) ⇒ Object
36 37 38 |
# File 'lib/chef_metal/machine.rb', line 36 def write_file(action_handler, path, content) raise "write_file not overridden on #{self.class}" end |