Class: ChefMetal::Machine

Inherits:
Object
  • Object
show all
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

BasicMachine

Defined Under Namespace

Classes: BasicMachine, UnixMachine, WindowsMachine

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nodeObject (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



41
42
43
# File 'lib/chef_metal/machine.rb', line 41

def create_dir(action_handler, path)
  raise "create_dir not overridden on #{self.class}"
end

#delete_file(action_handler, path) ⇒ Object

Delete file



46
47
48
# File 'lib/chef_metal/machine.rb', line 46

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



85
86
87
# File 'lib/chef_metal/machine.rb', line 85

def detect_os(action_handler)
  raise "detect_os not overridden on #{self.class}"
end

#disconnectObject



75
76
77
# File 'lib/chef_metal/machine.rb', line 75

def disconnect
  raise "disconnect not overridden on #{self.class}"
end

#download_file(action_handler, path, local_path) ⇒ Object



29
30
31
# File 'lib/chef_metal/machine.rb', line 29

def download_file(action_handler, path, local_path)
  raise "read_file not overridden on #{self.class}"
end

#execute(action_handler, command) ⇒ Object



21
22
23
# File 'lib/chef_metal/machine.rb', line 21

def execute(action_handler, command)
  raise "execute not overridden on #{self.class}"
end

#file_exists?(path) ⇒ Boolean

Return true or false depending on whether file exists

Returns:

  • (Boolean)


51
52
53
# File 'lib/chef_metal/machine.rb', line 51

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

Returns:

  • (Boolean)


56
57
58
# File 'lib/chef_metal/machine.rb', line 56

def files_different?(path, local_path, content=nil)
  raise "file_different? not overridden on #{self.class}"
end

#forward_remote_port_to_local(remote_port, local_port) ⇒ Object

Forward a remote port to local for the duration of the current connection



71
72
73
# File 'lib/chef_metal/machine.rb', line 71

def forward_remote_port_to_local(remote_port, local_port)
  raise "forward_remote_port_to_local not overridden on #{self.class}"
end

#get_attributes(path) ⇒ Object

Get file attributes { :mode, :owner, :group }



66
67
68
# File 'lib/chef_metal/machine.rb', line 66

def get_attributes(path)
  raise "get_attributes not overridden on #{self.class}"
end

#read_file(path) ⇒ Object



25
26
27
# File 'lib/chef_metal/machine.rb', line 25

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 }



61
62
63
# File 'lib/chef_metal/machine.rb', line 61

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



37
38
39
# File 'lib/chef_metal/machine.rb', line 37

def upload_file(action_handler, local_path, path)
  raise "write_file not overridden on #{self.class}"
end

#write_file(action_handler, path, content) ⇒ Object



33
34
35
# File 'lib/chef_metal/machine.rb', line 33

def write_file(action_handler, path, content)
  raise "write_file not overridden on #{self.class}"
end