Class: Fog::Compute::RackspaceV2::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/core/mod/fog_rackspace_server.rb

Instance Method Summary collapse

Instance Method Details

#setup(credentials = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/core/mod/fog_rackspace_server.rb', line 6

def setup(credentials = {})
  requires :ssh_ip_address, :identity, :public_key, :username

  commands = [
    %{mkdir .ssh},
    %{echo "#{public_key}" >> ~/.ssh/authorized_keys},
    password_lock,
    %{echo "#{Fog::JSON.encode(attributes)}" >> ~/attributes.json},
    %{echo "#{Fog::JSON.encode()}" >> ~/metadata.json}
  ]
  commands.compact

  @password = nil if password_lock

  Fog::SSH.new(ssh_ip_address, username, credentials).run(commands)

rescue Errno::ECONNREFUSED, Net::SSH::Disconnect
  sleep(1)
  retry
end