Class: ChefMetal::Machine::BasicMachine
Instance Attribute Summary collapse
#machine_spec
Instance Method Summary
collapse
-
#cleanup_convergence(action_handler) ⇒ Object
-
#converge(action_handler) ⇒ Object
-
#disconnect ⇒ Object
-
#download_file(action_handler, path, local_path) ⇒ Object
-
#execute(action_handler, command, options = {}) ⇒ Object
-
#execute_always(command, options = {}) ⇒ Object
-
#initialize(machine_spec, transport, convergence_strategy) ⇒ BasicMachine
constructor
A new instance of BasicMachine.
-
#make_url_available_to_remote(local_url) ⇒ Object
-
#read_file(path) ⇒ Object
-
#setup_convergence(action_handler) ⇒ Object
-
#upload_file(action_handler, local_path, path, options = {}) ⇒ Object
-
#write_file(action_handler, path, content, options = {}) ⇒ Object
#create_dir, #delete_file, #detect_os, #file_exists?, #files_different?, #get_attributes, #is_directory?, #name, #node, #set_attributes
Constructor Details
#initialize(machine_spec, transport, convergence_strategy) ⇒ BasicMachine
Returns a new instance of BasicMachine.
6
7
8
9
10
|
# File 'lib/chef_metal/machine/basic_machine.rb', line 6
def initialize(machine_spec, transport, convergence_strategy)
super(machine_spec)
@transport = transport
@convergence_strategy = convergence_strategy
end
|
Instance Attribute Details
#convergence_strategy ⇒ Object
Returns the value of attribute convergence_strategy.
13
14
15
|
# File 'lib/chef_metal/machine/basic_machine.rb', line 13
def convergence_strategy
@convergence_strategy
end
|
#transport ⇒ Object
Returns the value of attribute transport.
12
13
14
|
# File 'lib/chef_metal/machine/basic_machine.rb', line 12
def transport
@transport
end
|
Instance Method Details
#cleanup_convergence(action_handler) ⇒ Object
23
24
25
|
# File 'lib/chef_metal/machine/basic_machine.rb', line 23
def cleanup_convergence(action_handler)
convergence_strategy.cleanup_convergence(action_handler, machine_spec)
end
|
#converge(action_handler) ⇒ Object
19
20
21
|
# File 'lib/chef_metal/machine/basic_machine.rb', line 19
def converge(action_handler)
convergence_strategy.converge(action_handler, self)
end
|
#disconnect ⇒ Object
77
78
79
|
# File 'lib/chef_metal/machine/basic_machine.rb', line 77
def disconnect
transport.disconnect
end
|
#download_file(action_handler, path, local_path) ⇒ Object
43
44
45
46
47
48
49
|
# File 'lib/chef_metal/machine/basic_machine.rb', line 43
def download_file(action_handler, path, local_path)
if files_different?(path, local_path)
action_handler.perform_action "download file #{path} on #{machine_spec.name} to #{local_path}" do
transport.download_file(path, local_path)
end
end
end
|
#execute(action_handler, command, options = {}) ⇒ Object
27
28
29
30
31
32
33
|
# File 'lib/chef_metal/machine/basic_machine.rb', line 27
def execute(action_handler, command, options = {})
action_handler.perform_action "run '#{command}' on #{machine_spec.name}" do
result = transport.execute(command, options)
result.error!
result
end
end
|
#execute_always(command, options = {}) ⇒ Object
35
36
37
|
# File 'lib/chef_metal/machine/basic_machine.rb', line 35
def execute_always(command, options = {})
transport.execute(command, options)
end
|
#make_url_available_to_remote(local_url) ⇒ Object
73
74
75
|
# File 'lib/chef_metal/machine/basic_machine.rb', line 73
def make_url_available_to_remote(local_url)
transport.make_url_available_to_remote(local_url)
end
|
#read_file(path) ⇒ Object
39
40
41
|
# File 'lib/chef_metal/machine/basic_machine.rb', line 39
def read_file(path)
transport.read_file(path)
end
|
#setup_convergence(action_handler) ⇒ Object
15
16
17
|
# File 'lib/chef_metal/machine/basic_machine.rb', line 15
def setup_convergence(action_handler)
convergence_strategy.setup_convergence(action_handler, self)
end
|
#upload_file(action_handler, local_path, path, options = {}) ⇒ Object
62
63
64
65
66
67
68
69
70
71
|
# File 'lib/chef_metal/machine/basic_machine.rb', line 62
def upload_file(action_handler, local_path, path, options = {})
if files_different?(path, local_path)
if options[:ensure_dir]
create_dir(action_handler, dirname_on_machine(path))
end
action_handler.perform_action "upload file #{local_path} to #{path} on #{machine_spec.name}" do
transport.upload_file(local_path, path)
end
end
end
|
#write_file(action_handler, path, content, options = {}) ⇒ Object
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/chef_metal/machine/basic_machine.rb', line 51
def write_file(action_handler, path, content, options = {})
if files_different?(path, nil, content)
if options[:ensure_dir]
create_dir(action_handler, dirname_on_machine(path))
end
action_handler.perform_action "write file #{path} on #{machine_spec.name}" do
transport.write_file(path, content)
end
end
end
|