mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
[compute] fixes/skips to get examples working
This commit is contained in:
parent
794ff0d181
commit
32960d165a
5 changed files with 28 additions and 15 deletions
|
@ -9,9 +9,12 @@ Shindo.tests('compute examples', 'compute') do
|
|||
# iterate over all the providers
|
||||
Fog.providers.each do |provider|
|
||||
|
||||
# FIXME: implement expected shared compute stuff for these providers as well
|
||||
next if ['Bluebox', 'Brightbox', 'Ecloud', 'GoGrid', 'Linode', 'NewServers', 'Ninefold', 'Slicehost', 'StormOnDemand', 'VirtualBox', 'Voxel'].include?(provider)
|
||||
|
||||
provider = eval(provider) # convert from string to object
|
||||
|
||||
# skip if provider does not have storage
|
||||
# skip if provider does not have compute
|
||||
next unless provider.respond_to?(:services) && provider.services.include?(:compute)
|
||||
|
||||
tests(provider, provider.to_s.downcase) do
|
||||
|
@ -46,10 +49,15 @@ Shindo.tests('compute examples', 'compute') do
|
|||
end
|
||||
|
||||
# scp a directory to a server
|
||||
Dir.mkdir('/tmp/lorem')
|
||||
file = ::File.new('/tmp/lorem/lorem.txt', 'w')
|
||||
file.write(File.read(lorem_path))
|
||||
lorem_dir = File.join([File.dirname(__FILE__), '..', 'tests'])
|
||||
tests("@server.scp('#{lorem_dir}', '/tmp/lorem', :recursive => true)").succeeds do
|
||||
@server.scp(lorem_dir, '/tmp/lorem', :recursive => true)
|
||||
end
|
||||
File.delete('/tmp/lorem/lorem.txt')
|
||||
Dir.rmdir('/tmp/lorem')
|
||||
|
||||
# destroy the server
|
||||
tests('@server.destroy').succeeds do
|
||||
|
|
|
@ -41,7 +41,8 @@ Gem::Specification.new do |s|
|
|||
s.add_dependency('formatador', '>=0.1.3')
|
||||
s.add_dependency('json')
|
||||
s.add_dependency('mime-types')
|
||||
s.add_dependency('net-ssh', '>=2.1.3')
|
||||
s.add_dependency('net-scp', '>=1.0.4')
|
||||
s.add_dependency('net-ssh', '>=2.1.4')
|
||||
s.add_dependency('nokogiri', '>=1.4.4')
|
||||
s.add_dependency('ruby-hmac')
|
||||
|
||||
|
|
|
@ -44,7 +44,8 @@ module Fog
|
|||
def initialize(attributes={})
|
||||
self.groups ||= ["default"] unless attributes[:subnet_id]
|
||||
self.flavor_id ||= 't1.micro'
|
||||
self.image_id ||= begin
|
||||
self.image_id ||= begin
|
||||
self.username = 'ubuntu'
|
||||
case attributes[:connection].instance_variable_get(:@region) # Ubuntu 10.04 LTS 64bit (EBS)
|
||||
when 'ap-northeast-1'
|
||||
'ami-5e0fa45f'
|
||||
|
@ -179,13 +180,15 @@ module Fog
|
|||
end
|
||||
|
||||
# wait for aws to be ready
|
||||
Timeout::timeout(120) do
|
||||
Timeout::timeout(360) do
|
||||
begin
|
||||
Fog::SSH.new(public_ip_address, username, credentials.merge(:timeout => 4)).run('pwd')
|
||||
Timeout::timeout(8) do
|
||||
Fog::SSH.new(public_ip_address, username, credentials.merge(:timeout => 4)).run('pwd')
|
||||
end
|
||||
rescue Errno::ECONNREFUSED
|
||||
sleep(2)
|
||||
retry
|
||||
rescue Net::SSH::AuthenticationFailed, Timeout::Error => e
|
||||
rescue Net::SSH::AuthenticationFailed, Timeout::Error
|
||||
retry
|
||||
end
|
||||
end
|
||||
|
|
|
@ -14,7 +14,7 @@ module Fog
|
|||
|
||||
attribute :name
|
||||
attribute :image_id # id or name
|
||||
attribute :public_ip_address, :aliases => 'ip'
|
||||
attribute :public_ip_address, :aliases => 'ip', :squash => 'ip'
|
||||
attribute :memory # server.ram
|
||||
attribute :state
|
||||
attribute :description # Optional
|
||||
|
@ -59,36 +59,36 @@ module Fog
|
|||
|
||||
def save
|
||||
raise Fog::Errors::Error.new('Resaving an existing object may create a duplicate') if identity
|
||||
requires :name, :image_id, :ip, :memory
|
||||
requires :name, :image_id, :memory, :public_ip_address
|
||||
options = {
|
||||
'isSandbox' => sandbox,
|
||||
'image' => image_id
|
||||
}
|
||||
options = options.reject {|key, value| value.nil?}
|
||||
data = connection.grid_server_add(image, ip, name, memory, options)
|
||||
data = connection.grid_server_add(image, public_ip_address, name, memory, options)
|
||||
merge_attributes(data.body)
|
||||
true
|
||||
end
|
||||
|
||||
def ssh(commands)
|
||||
requires :ip, :identity, :username
|
||||
requires :identity, :public_ip_address, :username
|
||||
|
||||
options = {}
|
||||
options[:key_data] = [private_key] if private_key
|
||||
Fog::SSH.new(ip['ip'], username, options).run(commands)
|
||||
Fog::SSH.new(public_ip_address, username, options).run(commands)
|
||||
end
|
||||
|
||||
def scp(local_path, remote_path, upload_options = {})
|
||||
requires :ip, :username
|
||||
requires :public_ip_address, :username
|
||||
|
||||
scp_options = {}
|
||||
scp_options[:key_data] = [private_key] if private_key
|
||||
Fog::SCP.new(ip['ip'], username, scp_options).upload(local_path, remote_path, upload_options)
|
||||
Fog::SCP.new(public_ip_address, username, scp_options).upload(local_path, remote_path, upload_options)
|
||||
end
|
||||
|
||||
def setup(credentials = {})
|
||||
requires :ip, :identity, :public_key, :username
|
||||
Fog::SSH.new(ip['ip'], username, credentials).run([
|
||||
requires :identity, :public_ip_address, :public_key, :username
|
||||
Fog::SSH.new(public_ip_address, username, credentials).run([
|
||||
%{mkdir .ssh},
|
||||
%{echo "#{public_key}" >> ~/.ssh/authorized_keys},
|
||||
%{passwd -l root},
|
||||
|
|
|
@ -17,6 +17,7 @@ module Fog
|
|||
def bootstrap(new_attributes = {})
|
||||
server = create(new_attributes)
|
||||
server.wait_for { ready? }
|
||||
server.setup
|
||||
server
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue