update ec2 to newest api version and fix the broken specs
This commit is contained in:
parent
6c4f0d2538
commit
dae035bf56
|
@ -25,10 +25,6 @@ You'll get reminded that things are missing.
|
|||
So just add the missing stuff and you are off to the races:
|
||||
|
||||
server = AWS.servers.create(:image_id => 'ami-5ee70037')
|
||||
# you might also want a security group, which would go more like this:
|
||||
# AWS.servers.create(:image_id => 'ami-5ee70037', :groups => ['secure'])
|
||||
# NOTE: currently you can only have one group at boot time, so the first
|
||||
# element of the array will be used (and the rest will be disregarded)
|
||||
|
||||
But don't forget to cleanup or you'll regret it when you get the bill:
|
||||
|
||||
|
@ -50,6 +46,8 @@ Lets boot up a server on EC2
|
|||
|
||||
# boot a gentoo server
|
||||
server = connection.servers.new(:image_id => 'ami-5ee70037')
|
||||
# you might also want to add the server to security groups, which goes like this:
|
||||
# AWS.servers.create(:image_id => 'ami-5ee70037', :groups => ['web', 'db'])
|
||||
|
||||
# wait for it to be ready to do stuff
|
||||
server.wait_for { ready? }
|
||||
|
|
|
@ -157,7 +157,7 @@ module Fog
|
|||
'SignatureMethod' => 'HmacSHA256',
|
||||
'SignatureVersion' => '2',
|
||||
'Timestamp' => Time.now.utc.strftime("%Y-%m-%dT%H:%M:%SZ"),
|
||||
'Version' => '2009-04-04'
|
||||
'Version' => '2009-11-30'
|
||||
})
|
||||
|
||||
body = ''
|
||||
|
|
|
@ -24,7 +24,7 @@ module Fog
|
|||
attribute :user_data
|
||||
|
||||
def initialize(attributes)
|
||||
@groups ||= []
|
||||
@groups ||= ["default"]
|
||||
super
|
||||
end
|
||||
|
||||
|
@ -104,8 +104,8 @@ module Fog
|
|||
if @availability_zone
|
||||
options['Placement.AvailabilityZone'] = @availability_zone
|
||||
end
|
||||
unless @groups.empty?
|
||||
options['SecurityGroup'] = @groups.first
|
||||
@groups.each_with_index do |group, index|
|
||||
options["SecurityGroup.#{index}"] = group
|
||||
end
|
||||
if @kernel_id
|
||||
options['KernelId'] = @kernel_id
|
||||
|
|
|
@ -6,15 +6,15 @@ module Fog
|
|||
class TerminateInstances < Fog::Parsers::Base
|
||||
|
||||
def reset
|
||||
@instance = { 'previousState' => {}, 'shutdownState' => {} }
|
||||
@instance = { 'previousState' => {}, 'currentState' => {} }
|
||||
@response = { 'instancesSet' => [] }
|
||||
end
|
||||
|
||||
def start_element(name, attrs = [])
|
||||
if name == 'previousState'
|
||||
@in_previous_state = true
|
||||
elsif name == 'shutdownState'
|
||||
@in_shutdown_state = true
|
||||
elsif name == 'currentState'
|
||||
@in_current_state = true
|
||||
end
|
||||
@value = ''
|
||||
end
|
||||
|
@ -25,25 +25,25 @@ module Fog
|
|||
@instance[name] = @value
|
||||
when 'item'
|
||||
@response['instancesSet'] << @instance
|
||||
@instance = { 'previousState' => {}, 'shutdownState' => {} }
|
||||
@instance = { 'previousState' => {}, 'currentState' => {} }
|
||||
when 'code'
|
||||
if @in_previous_state
|
||||
@instance['previousState'][name] = @value.to_i
|
||||
elsif @in_shutdown_state
|
||||
@instance['shutdownState'][name] = @value.to_i
|
||||
elsif @in_current_state
|
||||
@instance['currentState'][name] = @value.to_i
|
||||
end
|
||||
when 'name'
|
||||
if @in_previous_state
|
||||
@instance['previousState'][name] = @value
|
||||
elsif @in_shutdown_state
|
||||
@instance['shutdownState'][name] = @value
|
||||
elsif @in_current_state
|
||||
@instance['currentState'][name] = @value
|
||||
end
|
||||
when 'previousState'
|
||||
@in_previous_state = false
|
||||
when 'requestId'
|
||||
@response[name] = @value
|
||||
when 'shutdownState'
|
||||
@in_shutdown_state = false
|
||||
when 'currentState'
|
||||
@in_current_state = false
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ unless Fog.mocking?
|
|||
# * 'Placement.AvailabilityZone'<~String> - Placement constraint for instances
|
||||
# * 'DeviceName'<~String> - ?
|
||||
# * 'Encoding'<~String> - ?
|
||||
# * 'SecurityGroup'<~String> - Name of security group for instances
|
||||
# * 'SecurityGroup.n'<~String> - Indexed names of security groups for instances
|
||||
# * 'InstanceType'<~String> - Type of instance to boot. Valid options
|
||||
# in ['m1.small', 'm1.large', 'm1.xlarge', 'c1.medium', 'c1.xlarge', 'm2.2xlarge', 'm2.4xlarge']
|
||||
# default is 'm1.small'
|
||||
|
|
|
@ -24,7 +24,6 @@ describe 'Fog::AWS::EC2::Server' do
|
|||
server = @servers.new({
|
||||
'amiLaunchIndex' => 'ami_launch_index',
|
||||
'dnsName' => 'dns_name',
|
||||
'groupId' => 'group_id',
|
||||
'imageId' => 'image_id',
|
||||
'instanceId' => 'instance_id',
|
||||
'instanceType' => 'instance_type',
|
||||
|
@ -37,10 +36,8 @@ describe 'Fog::AWS::EC2::Server' do
|
|||
})
|
||||
server.ami_launch_index.should == 'ami_launch_index'
|
||||
server.dns_name.should == 'dns_name'
|
||||
server.group_id.should == 'group_id'
|
||||
server.image_id.should == 'image_id'
|
||||
server.id.should == 'instance_id'
|
||||
server.flavor.should == 'instance_type'
|
||||
server.kernel_id.should == 'kernel_id'
|
||||
server.key_name.should == 'key_name'
|
||||
server.created_at.should == 'launch_time'
|
||||
|
|
|
@ -77,8 +77,10 @@ describe 'Fog::AWS::EC2::Snapshots' do
|
|||
end
|
||||
|
||||
it "should return true when it succeeds" do
|
||||
@snapshot.save.should be_true
|
||||
@snapshot.destroy
|
||||
eventually do
|
||||
@snapshot.save.should be_true
|
||||
@snapshot.destroy
|
||||
end
|
||||
end
|
||||
|
||||
it "should not exist in addresses before save" do
|
||||
|
|
|
@ -9,21 +9,21 @@ describe 'Fog::AWS::EC2::Snapshots' do
|
|||
end
|
||||
|
||||
it "should include persisted snapshots" do
|
||||
volume = AWS[:ec2].volumes.create(:availability_zone => 'us-east-1a', :size => 1, :device => 'dev/sdz1')
|
||||
snapshot = volume.snapshots.create
|
||||
AWS[:ec2].snapshots.all.map {|snapshot| snapshot.id}.should include(snapshot.id)
|
||||
snapshot.destroy
|
||||
volume.destroy
|
||||
@volume = AWS[:ec2].volumes.create(:availability_zone => 'us-east-1a', :size => 1, :device => 'dev/sdz1')
|
||||
eventually { @snapshot = @volume.snapshots.create }
|
||||
AWS[:ec2].snapshots.all.map {|snapshot| snapshot.id}.should include(@snapshot.id)
|
||||
@snapshot.destroy
|
||||
@volume.destroy
|
||||
end
|
||||
|
||||
it "should limit snapshots by volume if present" do
|
||||
volume = AWS[:ec2].volumes.create(:availability_zone => 'us-east-1a', :size => 1, :device => 'dev/sdz1')
|
||||
other_volume = AWS[:ec2].volumes.create(:availability_zone => 'us-east-1a', :size => 1, :device => 'dev/sdz1')
|
||||
snapshot = volume.snapshots.create
|
||||
other_volume.snapshots.all.map {|snapshot| snapshot.id}.should_not include(snapshot.id)
|
||||
snapshot.destroy
|
||||
other_volume.destroy
|
||||
volume.destroy
|
||||
@volume = AWS[:ec2].volumes.create(:availability_zone => 'us-east-1a', :size => 1, :device => 'dev/sdz1')
|
||||
@other_volume = AWS[:ec2].volumes.create(:availability_zone => 'us-east-1a', :size => 1, :device => 'dev/sdz1')
|
||||
eventually { @snapshot = @volume.snapshots.create }
|
||||
@other_volume.snapshots.all.map {|snapshot| snapshot.id}.should_not include(@snapshot.id)
|
||||
@snapshot.destroy
|
||||
@other_volume.destroy
|
||||
@volume.destroy
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -14,9 +14,11 @@ describe 'EC2.associate_address' do
|
|||
end
|
||||
|
||||
it "should return proper attributes" do
|
||||
actual = AWS[:ec2].associate_address(@instance_id, @public_ip)
|
||||
actual.body['requestId'].should be_a(String)
|
||||
[false, true].should include(actual.body['return'])
|
||||
eventually(128) do
|
||||
actual = AWS[:ec2].associate_address(@instance_id, @public_ip)
|
||||
actual.body['requestId'].should be_a(String)
|
||||
[false, true].should include(actual.body['return'])
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -5,8 +5,10 @@ describe 'EC2.disassociate_address' do
|
|||
|
||||
before(:each) do
|
||||
@instance_id = AWS[:ec2].run_instances(GENTOO_AMI, 1, 1).body['instancesSet'].first['instanceId']
|
||||
@public_ip = AWS[:ec2].allocate_address.body['publicIp']
|
||||
AWS[:ec2].associate_address(@instance_id, @public_ip)
|
||||
eventually(128) do
|
||||
@public_ip = AWS[:ec2].allocate_address.body['publicIp']
|
||||
AWS[:ec2].associate_address(@instance_id, @public_ip)
|
||||
end
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
|
|
|
@ -16,10 +16,10 @@ describe 'EC2.terminate_instances' do
|
|||
previous_state = instance['previousState']
|
||||
previous_state['code'].should be_a(Integer)
|
||||
previous_state['name'].should be_a(String)
|
||||
instance['shutdownState'].should be_a(Hash)
|
||||
shutdown_state = instance['shutdownState']
|
||||
shutdown_state['code'].should be_a(Integer)
|
||||
shutdown_state['name'].should be_a(String)
|
||||
instance['currentState'].should be_a(Hash)
|
||||
current_state = instance['currentState']
|
||||
current_state['code'].should be_a(Integer)
|
||||
current_state['name'].should be_a(String)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
--colour
|
|
@ -5,19 +5,21 @@ current_directory = File.dirname(__FILE__)
|
|||
require "#{current_directory}/../lib/fog"
|
||||
# Fog.mock!
|
||||
|
||||
# inlined spec.opts
|
||||
require "#{current_directory}/compact_progress_bar_formatter"
|
||||
Spec::Runner.options.parse_format("Spec::Runner::Formatter::CompactProgressBarFormatter")
|
||||
Spec::Runner.options.loadby = 'mtime'
|
||||
Spec::Runner.options.reverse = true
|
||||
|
||||
unless defined?(LOADED_SPEC_OPTS)
|
||||
# inlined spec.opts
|
||||
require "#{current_directory}/compact_progress_bar_formatter"
|
||||
Spec::Runner.options.parse_format("Spec::Runner::Formatter::CompactProgressBarFormatter")
|
||||
Spec::Runner.options.loadby = 'mtime'
|
||||
Spec::Runner.options.reverse = true
|
||||
LOADED_SPEC_OPTS = true
|
||||
end
|
||||
|
||||
|
||||
module AWS
|
||||
class << self
|
||||
def [](service)
|
||||
@@connections ||= Hash.new do |hash, key|
|
||||
credentials = Fog.credentials[:default].reject do |k, v|
|
||||
credentials = Fog.credentials.reject do |k, v|
|
||||
![:aws_access_key_id, :aws_secret_access_key].include?(k)
|
||||
end
|
||||
hash[key] = case key
|
||||
|
@ -40,7 +42,7 @@ module Rackspace
|
|||
class << self
|
||||
def [](service)
|
||||
@@connections ||= Hash.new do |hash, key|
|
||||
credentials = Fog.credentials[:default].reject do |k, v|
|
||||
credentials = Fog.credentials.reject do |k, v|
|
||||
![:rackspace_api_key, :rackspace_username].include?(k)
|
||||
end
|
||||
hash[key] = case key
|
||||
|
@ -59,7 +61,7 @@ module Slicehost
|
|||
class << self
|
||||
def [](service)
|
||||
@@connections ||= Hash.new do |hash, key|
|
||||
credentials = Fog.credentials[:default].reject do |k, v|
|
||||
credentials = Fog.credentials.reject do |k, v|
|
||||
![:slicehost_password].include?(k)
|
||||
end
|
||||
hash[key] = case key
|
||||
|
|
Loading…
Reference in New Issue