1
0
Fork 0
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:
geemus 2011-08-09 13:39:43 -05:00
parent 05b66ee6c7
commit bfe7efdd10
3 changed files with 24 additions and 2 deletions

View file

@ -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

View file

@ -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
View 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