mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
Merge pull request #841 from ryanstout/master
Fix SpotRequest loading and Private/Public key setting.
This commit is contained in:
commit
131259f0a5
2 changed files with 23 additions and 3 deletions
|
@ -31,6 +31,8 @@ module Fog
|
|||
attribute :tags, :aliases => 'tagSet'
|
||||
attribute :fault, :squash => 'message'
|
||||
attribute :user_data
|
||||
|
||||
attr_writer :private_key, :private_key_path, :public_key, :public_key_path
|
||||
|
||||
attr_writer :username
|
||||
|
||||
|
@ -71,6 +73,24 @@ module Fog
|
|||
def key_pair=(new_keypair)
|
||||
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'
|
||||
|
|
|
@ -43,7 +43,7 @@ module Fog
|
|||
unless spot_request.key_pair = connection.key_pairs.get("fog_#{name}")
|
||||
spot_request.key_pair = connection.key_pairs.create(
|
||||
:name => "fog_#{name}",
|
||||
:public_key => server.public_key
|
||||
:public_key => spot_request.public_key
|
||||
)
|
||||
end
|
||||
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