Changes made to enable Amazon's Private Cloud. See README for more details.

This commit is contained in:
Mat Ellis 2010-08-17 18:28:06 +08:00 committed by Wesley Beary
parent d5c6dda516
commit f0a02ed4bc
4 changed files with 25 additions and 3 deletions

View File

@ -1,5 +1,14 @@
http://geemus.com/fog.png
= VIRTUAL PRIVATE CLOUD ON AMAZON:
This version of fog has been modified to support Amazon's virtual private cloud. It is based on v0.2.22 (which was available at the time). It should be regarded as experimental. We have made a pull request to the fog maintainers. This patch was uploaded to Github on 17 August 2010.
= CHANGES FOR VPC COMPATIBILITY:
* Introduction of a subnet parameter (to define which subnet_id the virtual private instance will run on)
* Remove security groups from the EC2 API request when there is a subnet_id present
fog is the Ruby cloud computing library.
The quick and dirty, top to bottom:

View File

@ -29,10 +29,11 @@ module Fog
attribute :root_device_name, 'rootDeviceName'
attribute :root_device_type, 'rootDeviceType'
attribute :state, 'instanceState'
attribute :subnet_id, 'subnetId'
attribute :user_data
def initialize(attributes={})
@groups ||= ["default"]
@groups ||= ["default"] if attributes[:subnet_id].blank?
@flavor_id ||= 'm1.small'
super
end
@ -57,7 +58,7 @@ module Fog
end
# def security_group
# connection.security_groups.all(@group_id)
# connection.security_groups.all(@group_id)
# end
#
# def security_group=(new_security_group)
@ -124,8 +125,18 @@ module Fog
'Placement.AvailabilityZone' => @availability_zone,
'RamdiskId' => @ramdisk_id,
'SecurityGroup' => @groups,
'SubnetId' => subnet_id,
'UserData' => @user_data
}
# If subnet is defined we are working on a virtual private cloud
# subnet & security group cannot co-exist. I wish VPC just ignored
# the security group parameter instead, it would be much easier!
if subnet_id.blank?
options.delete('SubnetId')
else
options.delete('SecurityGroup')
end
data = connection.run_instances(@image_id, 1, 1, options)
merge_attributes(data.body['instancesSet'].first)

View File

@ -76,6 +76,8 @@ module Fog
else
@instance['monitoring'][name] = false
end
when 'subnetId'
@response[name] = @value
end
end

View File

@ -86,7 +86,7 @@ module Fog
end
end
end
if security_groups = [*options.delete('SecurityGroup')]
if security_groups = [*options.delete('SecurityGroup')] # cannot use Security Groups on Virtual Private Clouds
options.merge!(AWS.indexed_param('SecurityGroup', security_groups))
end
if options['UserData']