mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Adding bootstrap and setup for RackspaceV2 servers
This commit is contained in:
parent
58ba3fdb3a
commit
01241dca93
2 changed files with 22 additions and 0 deletions
|
@ -145,6 +145,20 @@ module Fog
|
|||
@password = password
|
||||
true
|
||||
end
|
||||
|
||||
def setup(credentials = {})
|
||||
requires :public_ip_address, :identity, :public_key, :username
|
||||
Fog::SSH.new(public_ip_address, username, credentials).run([
|
||||
%{mkdir .ssh},
|
||||
%{echo "#{public_key}" >> ~/.ssh/authorized_keys},
|
||||
%{passwd -l #{username}},
|
||||
%{echo "#{Fog::JSON.encode(attributes)}" >> ~/attributes.json},
|
||||
%{echo "#{Fog::JSON.encode(metadata)}" >> ~/metadata.json}
|
||||
])
|
||||
rescue Errno::ECONNREFUSED
|
||||
sleep(1)
|
||||
retry
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ require 'fog/rackspace/models/compute_v2/server'
|
|||
module Fog
|
||||
module Compute
|
||||
class RackspaceV2
|
||||
|
||||
class Servers < Fog::Collection
|
||||
|
||||
model Fog::Compute::RackspaceV2::Server
|
||||
|
@ -13,6 +14,13 @@ module Fog
|
|||
load(data)
|
||||
end
|
||||
|
||||
def bootstrap(new_attributes = {})
|
||||
server = create(new_attributes)
|
||||
server.wait_for { ready? }
|
||||
server.setup(:password => server.password)
|
||||
server
|
||||
end
|
||||
|
||||
def get(server_id)
|
||||
data = connection.get_server(server_id).body['server']
|
||||
new(data)
|
||||
|
|
Loading…
Reference in a new issue