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
|
@ -31,6 +31,8 @@ module Fog
|
||||||
attribute :tags, :aliases => 'tagSet'
|
attribute :tags, :aliases => 'tagSet'
|
||||||
attribute :fault, :squash => 'message'
|
attribute :fault, :squash => 'message'
|
||||||
attribute :user_data
|
attribute :user_data
|
||||||
|
|
||||||
|
attr_writer :private_key, :private_key_path, :public_key, :public_key_path
|
||||||
|
|
||||||
attr_writer :username
|
attr_writer :username
|
||||||
|
|
||||||
|
@ -71,6 +73,24 @@ module Fog
|
||||||
def key_pair=(new_keypair)
|
def key_pair=(new_keypair)
|
||||||
self.key_name = new_keypair && new_keypair.name
|
self.key_name = new_keypair && new_keypair.name
|
||||||
end
|
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?
|
def ready?
|
||||||
state == 'active'
|
state == 'active'
|
||||||
|
|
|
@ -62,7 +62,7 @@ module Fog
|
||||||
|
|
||||||
spot_request.save
|
spot_request.save
|
||||||
spot_request.wait_for { ready? }
|
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)
|
server = connection.servers.get(spot_request.instance_id)
|
||||||
if spot_request.tags
|
if spot_request.tags
|
||||||
for key, value in spot_request.tags
|
for key, value in spot_request.tags
|
||||||
|
@ -74,7 +74,7 @@ module Fog
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
server.wait_for { ready? }
|
server.wait_for { ready? }
|
||||||
server.setup(:key_data => [server.private_key])
|
server.setup(:key_data => [spot_request.private_key])
|
||||||
server
|
server
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue