Class: Vx::ContainerConnector::Docker

Inherits:
Object
  • Object
show all
Includes:
Vx::Common::Spawn, Instrument, Retriable
Defined in:
lib/vx/container_connector/docker.rb,
lib/vx/container_connector/docker/default.rb,
lib/vx/container_connector/docker/spawner.rb

Defined Under Namespace

Classes: Default, Spawner

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Instrument

#instrument

Methods included from Retriable

#with_retries

Constructor Details

#initialize(options = {}) ⇒ Docker

Returns a new instance of Docker.


20
21
22
23
24
25
26
27
28
# File 'lib/vx/container_connector/docker.rb', line 20

def initialize(options = {})
  @user        = options[:user]        || "vexor"
  @password    = options[:password]    || "vexor"
  @init        = options[:init]        || %w{ /sbin/my_init }
  @image       = options[:image]       || "ubuntu"
  @remote_dir  = options[:remote_dir]  || "/home/#{user}"
  @memory      = options[:memory].to_i
  @memory_swap = options[:memory_swap].to_i
end

Instance Attribute Details

#imageObject (readonly)

Returns the value of attribute image


18
19
20
# File 'lib/vx/container_connector/docker.rb', line 18

def image
  @image
end

#initObject (readonly)

Returns the value of attribute init


18
19
20
# File 'lib/vx/container_connector/docker.rb', line 18

def init
  @init
end

#memoryObject (readonly)

Returns the value of attribute memory


18
19
20
# File 'lib/vx/container_connector/docker.rb', line 18

def memory
  @memory
end

#memory_swapObject (readonly)

Returns the value of attribute memory_swap


18
19
20
# File 'lib/vx/container_connector/docker.rb', line 18

def memory_swap
  @memory_swap
end

#passwordObject (readonly)

Returns the value of attribute password


18
19
20
# File 'lib/vx/container_connector/docker.rb', line 18

def password
  @password
end

#remote_dirObject (readonly)

Returns the value of attribute remote_dir


18
19
20
# File 'lib/vx/container_connector/docker.rb', line 18

def remote_dir
  @remote_dir
end

#userObject (readonly)

Returns the value of attribute user


18
19
20
# File 'lib/vx/container_connector/docker.rb', line 18

def user
  @user
end

Instance Method Details

#create_container_optionsObject


36
37
38
39
40
41
42
43
# File 'lib/vx/container_connector/docker.rb', line 36

def create_container_options
  Default.create_container_options.merge(
    'Cmd'        => init,
    'Image'      => image,
    'Memory'     => memory,
    'MemorySwap' => memory_swap
  )
end

#start(&block) ⇒ Object


30
31
32
33
34
# File 'lib/vx/container_connector/docker.rb', line 30

def start(&block)
  start_container do |container|
    open_ssh_session(container, &block)
  end
end

#start_container_optionsObject


45
46
47
# File 'lib/vx/container_connector/docker.rb', line 45

def start_container_options
  Default.start_container_options
end