Class: KuberKit::ImageCompiler::BuildServerPool

Inherits:
Object
  • Object
show all
Defined in:
lib/kuber_kit/image_compiler/build_server_pool.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(local_shell:, build_servers:, ssh_shell_class:) ⇒ BuildServerPool

Returns a new instance of BuildServerPool.



4
5
6
7
8
9
# File 'lib/kuber_kit/image_compiler/build_server_pool.rb', line 4

def initialize(local_shell:, build_servers:, ssh_shell_class:)
  @local_shell     = local_shell
  @ssh_shell_class = ssh_shell_class
  @build_servers   = build_servers
  @ssh_shells      = []
end

Instance Attribute Details

#local_shellObject (readonly)

Returns the value of attribute local_shell.



2
3
4
# File 'lib/kuber_kit/image_compiler/build_server_pool.rb', line 2

def local_shell
  @local_shell
end

#ssh_shellsObject (readonly)

Returns the value of attribute ssh_shells.



2
3
4
# File 'lib/kuber_kit/image_compiler/build_server_pool.rb', line 2

def ssh_shells
  @ssh_shells
end

Instance Method Details

#disconnect_allObject



21
22
23
# File 'lib/kuber_kit/image_compiler/build_server_pool.rb', line 21

def disconnect_all
  @ssh_shells.each(&:disconnect)
end

#get_shellObject



11
12
13
14
15
16
17
18
19
# File 'lib/kuber_kit/image_compiler/build_server_pool.rb', line 11

def get_shell
  if @build_servers.any?
    shell = connect_to_ssh_shell(@build_servers.sample)
    @ssh_shells << shell
    shell
  else
    @local_shell
  end
end