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(machine_spec) ⇒ Machine

Returns a new instance of Machine.



3
4
5
# File 'lib/chef_metal/machine.rb', line 3

def initialize(machine_spec)
  @machine_spec = machine_spec
end

Instance Attribute Details

#machine_specObject (readonly)

Returns the value of attribute machine_spec.



7
8
9
# File 'lib/chef_metal/machine.rb', line 7

def machine_spec
  @machine_spec
end

Instance Method Details

#cleanup_convergence(action_handler) ⇒ Object



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

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

#converge(action_handler) ⇒ Object



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

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

#create_dir(action_handler, path) ⇒ Object



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

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

#delete_file(action_handler, path) ⇒ Object

Delete file



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

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



106
107
108
# File 'lib/chef_metal/machine.rb', line 106

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

#disconnectObject



96
97
98
# File 'lib/chef_metal/machine.rb', line 96

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

#download_file(action_handler, path, local_path) ⇒ Object



44
45
46
# File 'lib/chef_metal/machine.rb', line 44

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

#execute(action_handler, command, options = {}) ⇒ Object



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

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

#execute_always(command, options = {}) ⇒ Object



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

def execute_always(command, options = {})
  raise "execute_always not overridden on #{self.class}"
end

#file_exists?(path) ⇒ Boolean

Return true or false depending on whether file exists

Returns:

  • (Boolean)


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

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)


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

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 }



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

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

Returns:

  • (Boolean)


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

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



92
93
94
# File 'lib/chef_metal/machine.rb', line 92

def make_url_available_to_remote(local_url)
  raise "make_url_available_to_remote not overridden on #{self.class}"
end

#nameObject



9
10
11
# File 'lib/chef_metal/machine.rb', line 9

def name
  machine_spec.name
end

#nodeObject



13
14
15
# File 'lib/chef_metal/machine.rb', line 13

def node
  machine_spec.node
end

#read_file(path) ⇒ Object



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

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 }



81
82
83
# File 'lib/chef_metal/machine.rb', line 81

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.



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

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

#upload_file(action_handler, local_path, path) ⇒ Object



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

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

#write_file(action_handler, path, content) ⇒ Object



48
49
50
# File 'lib/chef_metal/machine.rb', line 48

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