mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge remote-tracking branch 'sashap/master'
Conflicts: lib/fog/rackspace/models/compute_v2/servers.rb
This commit is contained in:
commit
62a111f73d
2 changed files with 24 additions and 0 deletions
|
@ -97,6 +97,14 @@ module Fog
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def private_ip_address
|
||||||
|
addresses['private'].select{|a| a["version"] == 4}[0]["addr"]
|
||||||
|
end
|
||||||
|
|
||||||
|
def public_ip_address
|
||||||
|
ipv4_address
|
||||||
|
end
|
||||||
|
|
||||||
def ready?
|
def ready?
|
||||||
state == ACTIVE
|
state == ACTIVE
|
||||||
|
@ -142,6 +150,20 @@ module Fog
|
||||||
@password = password
|
@password = password
|
||||||
true
|
true
|
||||||
end
|
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
|
private
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,7 @@ require 'fog/rackspace/models/compute_v2/server'
|
||||||
module Fog
|
module Fog
|
||||||
module Compute
|
module Compute
|
||||||
class RackspaceV2
|
class RackspaceV2
|
||||||
|
|
||||||
class Servers < Fog::Collection
|
class Servers < Fog::Collection
|
||||||
|
|
||||||
model Fog::Compute::RackspaceV2::Server
|
model Fog::Compute::RackspaceV2::Server
|
||||||
|
@ -16,6 +17,7 @@ module Fog
|
||||||
def bootstrap(new_attributes = {})
|
def bootstrap(new_attributes = {})
|
||||||
server = create(new_attributes)
|
server = create(new_attributes)
|
||||||
server.wait_for { ready? }
|
server.wait_for { ready? }
|
||||||
|
server.setup(:password => server.password)
|
||||||
server
|
server
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue