Class: ChefMetalDocker::DockerContainerMachine
- Inherits:
-
ChefMetal::Machine::UnixMachine
- Object
- ChefMetal::Machine::UnixMachine
- ChefMetalDocker::DockerContainerMachine
- Defined in:
- lib/chef_metal_docker/docker_container_machine.rb
Instance Method Summary collapse
- #converge(action_handler) ⇒ Object
- #execute_always(command, options = {}) ⇒ Object
-
#initialize(machine_spec, transport, convergence_strategy, opts = {}) ⇒ DockerContainerMachine
constructor
Expects a machine specification, a usable transport and convergence strategy Options is expected to contain the optional keys :command => the final command to execute :ports => a list of port numbers to listen on.
Constructor Details
#initialize(machine_spec, transport, convergence_strategy, opts = {}) ⇒ DockerContainerMachine
Expects a machine specification, a usable transport and convergence strategy Options is expected to contain the optional keys
:command => the final command to execute
:ports => a list of port numbers to listen on
10 11 12 13 14 15 16 17 |
# File 'lib/chef_metal_docker/docker_container_machine.rb', line 10 def initialize(machine_spec, transport, convergence_strategy, opts = {}) super(machine_spec, transport, convergence_strategy) @command = opts[:command] @ports = opts[:ports] @keep_stdin_open = opts[:keep_stdin_open] @container_name = machine_spec.location['container_name'] @transport = transport end |
Instance Method Details
#converge(action_handler) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/chef_metal_docker/docker_container_machine.rb', line 23 def converge(action_handler) super action_handler if @command Chef::Log.debug("DockerContainerMachine converge complete, executing #{@command} in #{@container_name}") @transport.execute(@command, :detached => true, :read_only => true, :ports => @ports, :keep_stdin_open => @keep_stdin_open) end end |
#execute_always(command, options = {}) ⇒ Object
19 20 21 |
# File 'lib/chef_metal_docker/docker_container_machine.rb', line 19 def execute_always(command, = {}) transport.execute(command, { :read_only => true }.merge()) end |