Skip to content

Commit

Permalink
Added 'instance_count' feature for EC2 driver
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/incubator/deltacloud/trunk@1064070 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
mfojtik committed Jan 27, 2011
1 parent 507f1a4 commit c5fb3ea
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 17 deletions.
7 changes: 7 additions & 0 deletions server/lib/deltacloud/base_driver/features.rb
Original file line number Diff line number Diff line change
Expand Up @@ -197,5 +197,12 @@ def features_for_operation(collection, operation)
end
end

declare_feature :instances, :instance_count do
description "Number of instances to be launch with at once"
operation :create do
param :instance_count, :string, :optional
end
end

end
end
17 changes: 11 additions & 6 deletions server/lib/deltacloud/drivers/ec2/ec2_driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def supported_collections
feature :instances, :user_data
feature :instances, :authentication_key
feature :instances, :security_group
feature :instances, :instance_count
feature :images, :owner_id
feature :buckets, :bucket_location
feature :instances, :register_to_load_balancer
Expand Down Expand Up @@ -132,12 +133,12 @@ def images(credentials, opts={})
convert_image(image)
end
end
else
owner_id = opts[:owner_id] || "amazon"
safely do
img_arr = ec2.describe_images_by_owner(owner_id, "machine").collect do |image|
convert_image(image)
end
return img_arr
end
owner_id = opts[:owner_id] || "amazon"
safely do
img_arr = ec2.describe_images_by_owner(owner_id, "machine").collect do |image|
convert_image(image)
end
end
img_arr = filter_on( img_arr, :architecture, opts )
Expand Down Expand Up @@ -184,6 +185,10 @@ def create_instance(credentials, image_id, opts={})
instance_options.merge!(:availability_zone => opts[:realm_id]) if opts[:realm_id]
instance_options.merge!(:instance_type => opts[:hwp_id]) if opts[:hwp_id]
instance_options.merge!(:group_ids => opts[:security_group]) if opts[:security_group]
instance_options.merge!(
:min_count => opts[:instance_count],
:max_count => opts[:instance_count]
) if opts[:instance_count] and opts[:instance_count].length!=0
safely do
new_instance = convert_instance(ec2.launch_instances(image_id, instance_options).first)
# TODO: Rework this to use client_id for name instead of tag
Expand Down
30 changes: 19 additions & 11 deletions server/views/instances/new.html.haml
Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
%h1 New Instance
%h1 Launch new Instance

%h3{:class => "description"}= @image.description
%h2= @image.id
%h3= @image.description

%form{ :action => instances_url, :method => :post }
%form{ :action => instances_url, :method => :post, :class => :new_instance }
%input{ :name => :image_id, :type => :hidden, :value => @instance.image_id }/
%p
%label
Instance Name:
%input{ :name => 'name', :size => 30 }/
Name:
%input{ :name => 'name', :size => 30, :type => :text }/
-if driver_has_feature?(:instance_count)
%p
%label
Number of instances:
%input{ :type => :text, :value => "1", :name => :instance_count }
-if driver_has_feature?(:register_to_load_balancer)
%p
%label
Assign to load balancer:
%select{:name => 'load_balancer_id'}
%option{:value => ""}
- @load_balancers.each do |load_balancer|
%option{:value => load_balancer.id} #{load_balancer.id}
Load balancer to assign:
%select{:name => 'load_balancer_id'}
%option
- @load_balancers.each do |load_balancer|
%option{:value => load_balancer.id} #{load_balancer.id}
-if driver_has_feature?(:authentication_key)
%p
%label
Instance Keyname:
%input{:name => 'keyname', :size => 30 }
%select{:name => 'keyname'}
%option
- @keys.each do |key|
%option{ :value => key.id } #{key.id}
- if !@hardware_profiles.empty?
%h3 What size machine?
- for hwp in @hardware_profiles
Expand Down

0 comments on commit c5fb3ea

Please sign in to comment.