Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes #479

Merged
merged 4 commits into from Aug 23, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/fog/compute/requests/aws/associate_address.rb
Expand Up @@ -38,11 +38,13 @@ def associate_address(instance_id, public_ip)
instance = self.data[:instances][instance_id]
address = self.data[:addresses][public_ip]
if instance && address
if current_instance = self.data[:instances][address['instanceId']]
current_instance['ipAddress'] = current_instance['originalIpAddress']
end
address['instanceId'] = instance_id
instance['originalIpAddress'] = instance['ipAddress']
# detach other address (if any)
if self.data[:addresses][instance['originalIpAddress']]
self.data[:addresses][instance['originalIpAddress']]['instanceId'] = nil
if self.data[:addresses][instance['ipAddress']]
self.data[:addresses][instance['ipAddress']]['instanceId'] = nil
end
instance['ipAddress'] = public_ip
instance['dnsName'] = Fog::AWS::Mock.dns_name_for(public_ip)
Expand Down
4 changes: 2 additions & 2 deletions lib/fog/compute/requests/aws/create_volume.rb
Expand Up @@ -45,8 +45,8 @@ def create_volume(availability_zone, size, snapshot_id = nil)
raise Fog::Compute::AWS::NotFound.new("The snapshot '#{snapshot_id}' does not exist.")
end

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.")
if snapshot && size && size < snapshot['volumeSize']
raise Fog::Compute::AWS::NotFound.new("The snapshot '#{snapshot_id}' has size #{snapshot['volumeSize']} which is greater than #{size}.")
elsif snapshot && !size
size = snapshot['volumeSize']
end
Expand Down
3 changes: 2 additions & 1 deletion lib/fog/compute/requests/aws/describe_instances.rb
Expand Up @@ -85,7 +85,7 @@ def describe_instances(filters = {})

instance_set = self.data[:instances].values
instance_set = apply_tag_filters(instance_set, filters)

aliases = {
'architecture' => 'architecture',
'availability-zone' => 'availabilityZone',
Expand Down Expand Up @@ -158,6 +158,7 @@ def describe_instances(filters = {})
when 'pending'
if Time.now - instance['launchTime'] >= Fog::Mock.delay
instance['ipAddress'] = Fog::AWS::Mock.ip_address
instance['originalIpAddress'] = instance['ipAddress']
instance['dnsName'] = Fog::AWS::Mock.dns_name_for(instance['ipAddress'])
instance['privateIpAddress'] = Fog::AWS::Mock.ip_address
instance['privateDnsName'] = Fog::AWS::Mock.private_dns_name_for(instance['privateIpAddress'])
Expand Down
1 change: 1 addition & 0 deletions lib/fog/compute/requests/aws/modify_image_attribute.rb
Expand Up @@ -28,6 +28,7 @@ def modify_image_attribute(image_id, attributes)
params.merge!(Fog::AWS.indexed_param('ProductCode', attributes['ProductCode'] || []))
request({
'Action' => 'ModifyImageAttribute',
'ImageId' => image_id,
:idempotent => true,
:parser => Fog::Parsers::Compute::AWS::Basic.new
}.merge!(params))
Expand Down
5 changes: 3 additions & 2 deletions lib/fog/compute/requests/aws/modify_instance_attribute.rb
Expand Up @@ -8,7 +8,7 @@ class Real
# Modify instance attributes
#
# ==== Parameters
# * image_id<~String> - Id of machine image to modify
# * instance_id<~String> - Id of instance to modify
# * attributes<~Hash>:
# 'InstanceType.Value'<~String> - New instance type
# 'Kernel.Value'<~String> - New kernel value
Expand All @@ -21,11 +21,12 @@ class Real
#
# {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.merge!(Fog::AWS.indexed_param('GroupId', attributes['GroupId'] || []))
request({
'Action' => 'ModifyInstanceAttribute',
'InstanceId' => instance_id,
:idempotent => true,
:parser => Fog::Parsers::Compute::AWS::Basic.new
}.merge!(params))
Expand Down
1 change: 1 addition & 0 deletions lib/fog/compute/requests/aws/modify_snapshot_attribute.rb
Expand Up @@ -25,6 +25,7 @@ def modify_snapshot_attribute(snapshot_id, attributes)
params.merge!(Fog::AWS.indexed_param('CreateVolumePermission.Remove.%d.UserId', attributes['Remove.UserId'] || []))
request({
'Action' => 'ModifySnapshotAttribute',
'SnapshotId' => snapshot_id,
:idempotent => true,
:parser => Fog::Parsers::Compute::AWS::Basic.new
}.merge!(params))
Expand Down
11 changes: 10 additions & 1 deletion lib/fog/storage/requests/aws/get_bucket_location.rb
Expand Up @@ -37,8 +37,17 @@ class Mock # :nodoc:all
def get_bucket_location(bucket_name)
response = Excon::Response.new
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.body = {'LocationConstraint' => bucket['LocationConstraint'] }
response.body = {'LocationConstraint' => location_constraint }
else
response.status = 404
raise(Excon::Errors.status_error({:expects => 200}, response))
Expand Down