mirror of
https://github.com/fog/fog.git
synced 2022-11-09 13:51:43 -05:00
commit
614c3d0133
7 changed files with 24 additions and 9 deletions
|
@ -38,11 +38,13 @@ module Fog
|
|||
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)
|
||||
|
|
|
@ -45,8 +45,8 @@ module Fog
|
|||
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
|
||||
|
|
|
@ -85,7 +85,7 @@ module Fog
|
|||
|
||||
instance_set = self.data[:instances].values
|
||||
instance_set = apply_tag_filters(instance_set, filters)
|
||||
|
||||
|
||||
aliases = {
|
||||
'architecture' => 'architecture',
|
||||
'availability-zone' => 'availabilityZone',
|
||||
|
@ -158,6 +158,7 @@ module Fog
|
|||
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'])
|
||||
|
|
|
@ -28,6 +28,7 @@ module Fog
|
|||
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))
|
||||
|
|
|
@ -8,7 +8,7 @@ module Fog
|
|||
# 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
|
||||
|
@ -21,11 +21,12 @@ module Fog
|
|||
#
|
||||
# {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))
|
||||
|
|
|
@ -25,6 +25,7 @@ module Fog
|
|||
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))
|
||||
|
|
|
@ -37,8 +37,17 @@ module Fog
|
|||
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))
|
||||
|
|
Loading…
Reference in a new issue