Class: Knife::Clc::Bootstrap::Methods::SyncLinuxSsh

Inherits:
Object
  • Object
show all
Defined in:
lib/knife-clc/bootstrap/methods/sync_linux_ssh.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params) ⇒ SyncLinuxSsh

Returns a new instance of SyncLinuxSsh.



8
9
10
11
12
13
# File 'lib/knife-clc/bootstrap/methods/sync_linux_ssh.rb', line 8

def initialize(params)
  @cloud_adapter = params.fetch(:cloud_adapter)
  @config = params.fetch(:config)
  @connectivity_helper = params.fetch(:connectivity_helper)
  @subcommand_loader = params.fetch(:subcommand_loader)
end

Instance Attribute Details

#cloud_adapterObject (readonly)

Returns the value of attribute cloud_adapter.



6
7
8
# File 'lib/knife-clc/bootstrap/methods/sync_linux_ssh.rb', line 6

def cloud_adapter
  @cloud_adapter
end

#configObject (readonly)

Returns the value of attribute config.



6
7
8
# File 'lib/knife-clc/bootstrap/methods/sync_linux_ssh.rb', line 6

def config
  @config
end

#connectivity_helperObject (readonly)

Returns the value of attribute connectivity_helper.



6
7
8
# File 'lib/knife-clc/bootstrap/methods/sync_linux_ssh.rb', line 6

def connectivity_helper
  @connectivity_helper
end

#subcommand_loaderObject (readonly)

Returns the value of attribute subcommand_loader.



6
7
8
# File 'lib/knife-clc/bootstrap/methods/sync_linux_ssh.rb', line 6

def subcommand_loader
  @subcommand_loader
end

Instance Method Details

#execute(server) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/knife-clc/bootstrap/methods/sync_linux_ssh.rb', line 15

def execute(server)
  cloud_adapter.ensure_server_powered_on(server)

  fqdn = get_server_fqdn(server)
  wait_for_sshd(fqdn)

  command = subcommand_loader.load(:class => Chef::Knife::Bootstrap, :config => config)

  username, password = config.values_at(:ssh_user, :ssh_password)
  unless username && password
    creds = cloud_adapter.get_server_credentials(server)
    command.config.merge!(:ssh_user => creds['userName'], :ssh_password => creds['password'])
  end

  command.name_args = [fqdn]
  command.config[:chef_node_name] ||= server['name']

  command.run
end