1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

Merge pull request #479 from dpiddy/various-fixes

Various fixes
This commit is contained in:
Wesley Beary 2011-08-23 08:25:31 -07:00
commit 614c3d0133
7 changed files with 24 additions and 9 deletions

View file

@ -38,11 +38,13 @@ module Fog
instance = self.data[:instances][instance_id] instance = self.data[:instances][instance_id]
address = self.data[:addresses][public_ip] address = self.data[:addresses][public_ip]
if instance && address if instance && address
if current_instance = self.data[:instances][address['instanceId']]
current_instance['ipAddress'] = current_instance['originalIpAddress']
end
address['instanceId'] = instance_id address['instanceId'] = instance_id
instance['originalIpAddress'] = instance['ipAddress']
# detach other address (if any) # detach other address (if any)
if self.data[:addresses][instance['originalIpAddress']] if self.data[:addresses][instance['ipAddress']]
self.data[:addresses][instance['originalIpAddress']]['instanceId'] = nil self.data[:addresses][instance['ipAddress']]['instanceId'] = nil
end end
instance['ipAddress'] = public_ip instance['ipAddress'] = public_ip
instance['dnsName'] = Fog::AWS::Mock.dns_name_for(public_ip) instance['dnsName'] = Fog::AWS::Mock.dns_name_for(public_ip)

View file

@ -45,8 +45,8 @@ module Fog
raise Fog::Compute::AWS::NotFound.new("The snapshot '#{snapshot_id}' does not exist.") raise Fog::Compute::AWS::NotFound.new("The snapshot '#{snapshot_id}' does not exist.")
end end
if snapshot && size && size != snapshot['volumeSize'] if snapshot && size && size < snapshot['volumeSize']
raise Fog::Compute::AWS::NotFound.new("The snapshot '#{snapshot_id}' with the specified size of '#{size}' does not exist.") raise Fog::Compute::AWS::NotFound.new("The snapshot '#{snapshot_id}' has size #{snapshot['volumeSize']} which is greater than #{size}.")
elsif snapshot && !size elsif snapshot && !size
size = snapshot['volumeSize'] size = snapshot['volumeSize']
end end

View file

@ -158,6 +158,7 @@ module Fog
when 'pending' when 'pending'
if Time.now - instance['launchTime'] >= Fog::Mock.delay if Time.now - instance['launchTime'] >= Fog::Mock.delay
instance['ipAddress'] = Fog::AWS::Mock.ip_address instance['ipAddress'] = Fog::AWS::Mock.ip_address
instance['originalIpAddress'] = instance['ipAddress']
instance['dnsName'] = Fog::AWS::Mock.dns_name_for(instance['ipAddress']) instance['dnsName'] = Fog::AWS::Mock.dns_name_for(instance['ipAddress'])
instance['privateIpAddress'] = Fog::AWS::Mock.ip_address instance['privateIpAddress'] = Fog::AWS::Mock.ip_address
instance['privateDnsName'] = Fog::AWS::Mock.private_dns_name_for(instance['privateIpAddress']) instance['privateDnsName'] = Fog::AWS::Mock.private_dns_name_for(instance['privateIpAddress'])

View file

@ -28,6 +28,7 @@ module Fog
params.merge!(Fog::AWS.indexed_param('ProductCode', attributes['ProductCode'] || [])) params.merge!(Fog::AWS.indexed_param('ProductCode', attributes['ProductCode'] || []))
request({ request({
'Action' => 'ModifyImageAttribute', 'Action' => 'ModifyImageAttribute',
'ImageId' => image_id,
:idempotent => true, :idempotent => true,
:parser => Fog::Parsers::Compute::AWS::Basic.new :parser => Fog::Parsers::Compute::AWS::Basic.new
}.merge!(params)) }.merge!(params))

View file

@ -8,7 +8,7 @@ module Fog
# Modify instance attributes # Modify instance attributes
# #
# ==== Parameters # ==== Parameters
# * image_id<~String> - Id of machine image to modify # * instance_id<~String> - Id of instance to modify
# * attributes<~Hash>: # * attributes<~Hash>:
# 'InstanceType.Value'<~String> - New instance type # 'InstanceType.Value'<~String> - New instance type
# 'Kernel.Value'<~String> - New kernel value # 'Kernel.Value'<~String> - New kernel value
@ -21,11 +21,12 @@ module Fog
# #
# {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyInstanceAttribute.html] # {Amazon API Reference}[http://docs.amazonwebservices.com/AWSEC2/latest/APIReference/ApiReference-query-ModifyInstanceAttribute.html]
# #
def modify_instance_attributes(image_id, attributes) def modify_instance_attributes(instance_id, attributes)
params = {} params = {}
params.merge!(Fog::AWS.indexed_param('GroupId', attributes['GroupId'] || [])) params.merge!(Fog::AWS.indexed_param('GroupId', attributes['GroupId'] || []))
request({ request({
'Action' => 'ModifyInstanceAttribute', 'Action' => 'ModifyInstanceAttribute',
'InstanceId' => instance_id,
:idempotent => true, :idempotent => true,
:parser => Fog::Parsers::Compute::AWS::Basic.new :parser => Fog::Parsers::Compute::AWS::Basic.new
}.merge!(params)) }.merge!(params))

View file

@ -25,6 +25,7 @@ module Fog
params.merge!(Fog::AWS.indexed_param('CreateVolumePermission.Remove.%d.UserId', attributes['Remove.UserId'] || [])) params.merge!(Fog::AWS.indexed_param('CreateVolumePermission.Remove.%d.UserId', attributes['Remove.UserId'] || []))
request({ request({
'Action' => 'ModifySnapshotAttribute', 'Action' => 'ModifySnapshotAttribute',
'SnapshotId' => snapshot_id,
:idempotent => true, :idempotent => true,
:parser => Fog::Parsers::Compute::AWS::Basic.new :parser => Fog::Parsers::Compute::AWS::Basic.new
}.merge!(params)) }.merge!(params))

View file

@ -37,8 +37,17 @@ module Fog
def get_bucket_location(bucket_name) def get_bucket_location(bucket_name)
response = Excon::Response.new response = Excon::Response.new
if bucket = self.data[:buckets][bucket_name] if bucket = self.data[:buckets][bucket_name]
location_constraint = case bucket['LocationConstraint']
when 'us-east-1'
nil
when 'eu-east-1'
'EU'
else
bucket['LocationConstraint']
end
response.status = 200 response.status = 200
response.body = {'LocationConstraint' => bucket['LocationConstraint'] } response.body = {'LocationConstraint' => location_constraint }
else else
response.status = 404 response.status = 404
raise(Excon::Errors.status_error({:expects => 200}, response)) raise(Excon::Errors.status_error({:expects => 200}, response))