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

EBS-Optimized Instances support for EC2 #241

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 6 additions & 4 deletions lib/rubber/cloud/fog.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ def table_store(table_key)
raise NotImplementedError, "No table store available for generic fog adapter"
end

def create_instance(ami, ami_type, security_groups, availability_zone)
def create_instance(ami, ami_type, security_groups, availability_zone, ebs_optimized)
response = @compute_provider.servers.create(:image_id => ami,
:flavor_id => ami_type,
:groups => security_groups,
:availability_zone => availability_zone,
:key_name => env.key_name)
:key_name => env.key_name,
:ebs_optimized => ebs_optimized)
instance_id = response.id
return instance_id
end
Expand Down Expand Up @@ -236,8 +237,9 @@ def destroy_static_ip(ip)
return address.destroy
end

def create_volume(size, zone)
volume = @compute_provider.volumes.create(:size => size.to_s, :availability_zone => zone)
def create_volume(size, zone, volume_type, iops)
volume = @compute_provider.volumes.create(:size => size.to_s, :availability_zone => zone,
:type => volume_type, :iops => iops)
return volume.id
end

Expand Down
3 changes: 2 additions & 1 deletion lib/rubber/recipes/rubber/instances.rb
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ def create_instance(instance_alias, instance_roles, create_spot_instance)
ami = cloud_env.image_id
ami_type = cloud_env.image_type
availability_zone = env.availability_zone
ebs_optimized = cloud_env.ebs_optimized

create_spot_instance ||= cloud_env.spot_instance

Expand Down Expand Up @@ -294,7 +295,7 @@ def create_instance(instance_alias, instance_roles, create_spot_instance)

if !create_spot_instance || (create_spot_instance && max_wait_time < 0)
logger.info "Creating instance #{ami}/#{ami_type}/#{security_groups.join(',') rescue 'Default'}/#{availability_zone || 'Default'}"
instance_id = cloud.create_instance(ami, ami_type, security_groups, availability_zone)
instance_id = cloud.create_instance(ami, ami_type, security_groups, availability_zone, ebs_optimized)
end

logger.info "Instance #{instance_alias} created: #{instance_id}"
Expand Down
6 changes: 3 additions & 3 deletions lib/rubber/recipes/rubber/volumes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@
detach_volume(volume_id)
end

def create_volume(size, zone)
volumeId = cloud.create_volume(size.to_s, zone)
def create_volume(size, zone, volume_type, iops)
volumeId = cloud.create_volume(size.to_s, zone, volume_type, iops.to_s)
fatal "Failed to create volume" if volumeId.nil?
return volumeId
end
Expand All @@ -91,7 +91,7 @@ def setup_volume(ic, vol_spec)
# first create the volume if we don't have a global record (artifacts) for it
if ! vol_id
logger.info "Creating volume for #{ic.full_name}:#{vol_spec['device']}"
vol_id = create_volume(vol_spec['size'], vol_spec['zone'])
vol_id = create_volume(vol_spec['size'], vol_spec['zone'], vol_spec['type'], vol_spec['iops'])
artifacts['volumes'][key] = vol_id
rubber_instances.save
created = vol_spec['device']
Expand Down
18 changes: 18 additions & 0 deletions templates/base/config/rubber/rubber.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ cloud_providers:
image_type: m1.small
image_id: ami-eafa5883

# EBS I/O optimized instace
# EBS-optimized instances deliver dedicated throughput between Amazon EC2 and Amazon EBS, with options
# between 500 Mbps and 1000 Mbps depending on the instance type used.
# Read more and make sure that your image_type supports ebs_optimized function at: http://aws.amazon.com/ec2/instance-types/
ebs_optimized: false

# OPTIONAL: EC2 spot instance request support.
#
# Enables the creation of spot instance requests. Rubber will wait synchronously until the request is fulfilled,
Expand Down Expand Up @@ -244,20 +250,32 @@ stop_on_error_cmd: "function error_exit { exit 99; }; trap error_exit ERR"
# device: /dev/sdh # OS device to attach volume to
# mount: /mnt/mysql # The directory to mount this volume to
# filesystem: ext3 # the filesystem to create on volume
# type: standard # type of volume, standard or io1
# iops: 500 # The number of I/O operations per second (IOPS) that the volume supports.
# # Required when the volume type is io1; not used with standard volumes.
# - size: 10 # size of vol in GBs
# zone: us-east-1a # zone to create volume in, needs to match host's zone
# device: /dev/sdi # OS device to attach volume to
# mount: /mnt/logs # The directory to mount this volume to
# filesystem: ext3 # the filesystem to create on volume
# type: standard # type of volume, standard or io1
# iops: 500 # The number of I/O operations per second (IOPS) that the volume supports.
# # Required when the volume type is io1; not used with standard volumes.
#
# # volumes without mount/filesystem can be used in raid arrays
#
# - size: 50 # size of vol in GBs
# zone: us-east-1a # zone to create volume in, needs to match host's zone
# device: /dev/sdx # OS device to attach volume to
# type: standard # type of volume, standard or io1
# iops: 500 # The number of I/O operations per second (IOPS) that the volume supports.
# # Required when the volume type is io1; not used with standard volumes.
# - size: 50 # size of vol in GBs
# zone: us-east-1a # zone to create volume in, needs to match host's zone
# device: /dev/sdy # OS device to attach volume to
# type: standard # type of volume, standard or io1
# iops: 500 # The number of I/O operations per second (IOPS) that the volume supports.
# # Required when the volume type is io1; not used with standard volumes.
#
# # Use some ephemeral volumes for raid array
# local_volumes:
Expand Down
2 changes: 1 addition & 1 deletion test/cloud/aws_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class AwsTest < Test::Unit::TestCase
end

should "create instance" do
assert @cloud.create_instance('', '', '', '')
assert @cloud.create_instance('', '', '', '', '')
end

end
Expand Down
2 changes: 1 addition & 1 deletion test/cloud/fog_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class FogTest < Test::Unit::TestCase
end

should "create instance" do
assert @cloud.create_instance('', '', '', '')
assert @cloud.create_instance('', '', '', '', '')
end

end
Expand Down