mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Be sure to reload when checking for a started spot instance, also add private/public key options into spot_requests, then set those on the server when loaded
This commit is contained in:
parent
341d012f6a
commit
090fda0c31
2 changed files with 22 additions and 2 deletions
|
@ -32,6 +32,8 @@ module Fog
|
|||
attribute :fault, :squash => 'message'
|
||||
attribute :user_data
|
||||
|
||||
attr_writer :private_key, :private_key_path, :public_key, :public_key_path
|
||||
|
||||
attr_writer :username
|
||||
|
||||
def initialize(attributes={})
|
||||
|
@ -72,6 +74,24 @@ module Fog
|
|||
self.key_name = new_keypair && new_keypair.name
|
||||
end
|
||||
|
||||
def private_key_path
|
||||
@private_key_path ||= Fog.credentials[:private_key_path]
|
||||
@private_key_path &&= File.expand_path(@private_key_path)
|
||||
end
|
||||
|
||||
def private_key
|
||||
@private_key ||= private_key_path && File.read(private_key_path)
|
||||
end
|
||||
|
||||
def public_key_path
|
||||
@public_key_path ||= Fog.credentials[:public_key_path]
|
||||
@public_key_path &&= File.expand_path(@public_key_path)
|
||||
end
|
||||
|
||||
def public_key
|
||||
@public_key ||= public_key_path && File.read(public_key_path)
|
||||
end
|
||||
|
||||
def ready?
|
||||
state == 'active'
|
||||
end
|
||||
|
|
|
@ -62,7 +62,7 @@ module Fog
|
|||
|
||||
spot_request.save
|
||||
spot_request.wait_for { ready? }
|
||||
Fog.wait_for { server = connection.servers.get(spot_request.instance_id) }
|
||||
Fog.wait_for { server = connection.servers.get(spot_request.reload.instance_id) }
|
||||
server = connection.servers.get(spot_request.instance_id)
|
||||
if spot_request.tags
|
||||
for key, value in spot_request.tags
|
||||
|
@ -74,7 +74,7 @@ module Fog
|
|||
end
|
||||
end
|
||||
server.wait_for { ready? }
|
||||
server.setup(:key_data => [server.private_key])
|
||||
server.setup(:key_data => [spot_request.private_key])
|
||||
server
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue