This commit is contained in:
geemus (Wesley Beary) 2010-04-14 20:32:56 -07:00
Родитель 5981bee1c8
Коммит 9cad16f71f
4 изменённых файлов: 35 добавлений и 0 удалений

Просмотреть файл

@ -5,6 +5,7 @@ gem 'excon', '>= 0.0.21'
gem 'formatador', ">= 0.0.10"
gem 'json', ">= 0"
gem 'mime-types', ">= 0"
gem 'net-ssh', ">= 0"
gem 'nokogiri', ">= 0"
gem 'ruby-hmac', ">= 0"
gem 'rspec', '>= 0'

Просмотреть файл

@ -11,6 +11,7 @@ begin
gem.add_dependency('formatador', '>=0.0.10')
gem.add_dependency('json')
gem.add_dependency('mime-types')
gem.add_dependency('net-ssh')
gem.add_dependency('nokogiri')
gem.add_dependency('ruby-hmac')
gem.name = "fog"

Просмотреть файл

@ -8,6 +8,7 @@ require 'hmac-sha1'
require 'hmac-sha2'
require 'json'
require 'mime/types'
require 'net/ssh'
require 'nokogiri'
require 'time'
@ -21,6 +22,7 @@ require 'fog/collection'
require 'fog/connection'
require 'fog/model'
require 'fog/parser'
require 'fog/ssh'
require 'fog/aws'
require 'fog/rackspace'
require 'fog/slicehost'

31
lib/fog/ssh.rb Normal file
Просмотреть файл

@ -0,0 +1,31 @@
module Fog
class SSH
def initialize(address, username, options = {})
unless options[:keys] || options[:password]
raise ArgumentError.new(':keys or :password are required to initialize SSH')
end
@address = address
@username = username
@options = options.merge!(:paranoid => false)
end
def run(commands)
commands = [*commands]
results = []
Net::SSH.start(@address, @username, @options) do |ssh|
commands.each do |command|
result = { :command => command }
ssh.exec!("bash -lc #{command.inspect}") do |channel, stream, data|
result[stream] = data
end
results << result
end
end
results
end
end
end