mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[compute|aws] fixes for bootstrap and placing attributes json
This commit is contained in:
parent
05b66ee6c7
commit
bfe7efdd10
3 changed files with 24 additions and 2 deletions
|
@ -185,11 +185,12 @@ module Fog
|
|||
def setup(credentials = {})
|
||||
requires :identity, :public_ip_address, :username
|
||||
require 'multi_json'
|
||||
require 'net/ssh'
|
||||
|
||||
commands = [
|
||||
%{mkdir .ssh},
|
||||
%{passwd -l #{username}},
|
||||
%{echo "#{MultiJson.encode(attributes)}" >> ~/attributes.json}
|
||||
%{echo "#{MultiJson.encode(Fog::JSON.sanitize(attributes))}" >> ~/attributes.json}
|
||||
]
|
||||
if public_key
|
||||
commands << %{echo "#{public_key}" >> ~/.ssh/authorized_keys}
|
||||
|
@ -212,7 +213,7 @@ module Fog
|
|||
end
|
||||
|
||||
def ssh(commands)
|
||||
requires :identity, :public_ip_address, :username
|
||||
requires :public_ip_address, :username
|
||||
|
||||
options = {}
|
||||
options[:key_data] = [private_key] if private_key
|
||||
|
|
|
@ -23,6 +23,7 @@ require 'fog/core/credentials'
|
|||
require 'fog/core/deprecation'
|
||||
require 'fog/core/errors'
|
||||
require 'fog/core/hmac'
|
||||
require 'fog/core/json'
|
||||
require 'fog/core/model'
|
||||
require 'fog/core/mock'
|
||||
require 'fog/core/parser' # FIXME: would be better to only load when nokogiri is required
|
||||
|
|
20
lib/fog/core/json.rb
Normal file
20
lib/fog/core/json.rb
Normal file
|
@ -0,0 +1,20 @@
|
|||
module Fog
|
||||
module JSON
|
||||
|
||||
def self.sanitize(data)
|
||||
case data
|
||||
when Array
|
||||
data.map {|datum| sanitize(datum)}
|
||||
when Hash
|
||||
for key, value in data
|
||||
data[key] = sanitize(value)
|
||||
end
|
||||
when ::Time
|
||||
data.strftime("%Y-%m-%dT%H:%M:%SZ")
|
||||
else
|
||||
data
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue