You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by mf...@redhat.com on 2011/01/19 15:14:52 UTC
Added support for launching multiple instance at once (EC2)
Hi,
First patch will add a new feature (currently only EC2 supports that)
for launching multiple instances in instance create call.
Using 'instance_count' param you can choose how many instance will be
creating using properties you choosed (image, hwp, realm).
Sadly, there is support for that in GoGrid, Rackspace or RHEV-M API AFAIK.
(If i'm wrong please correct me ;)
Second patch is really minor, since I added new text input in
launch instance screen, it becomes look very messy, so I cleaned
up layout a little bit.
Also I replaced 'realm' in instances list screen with hardware profile,
which I think is much more usefull for tester/developer IMHO.
-- Michal
Re: Added support for launching multiple instance at once (EC2)
Posted by Michal Fojtik <mf...@redhat.com>.
On 26/01/11 13:27 -0500, Toby Crawley wrote:
>ACK - this patch works for me.
Thanks for review! Pushed.
-- Michal
>
>On Jan 19, 2011, at 9:14 AM, mfojtik@redhat.com wrote:
>
>> Hi,
>>
>> First patch will add a new feature (currently only EC2 supports that)
>> for launching multiple instances in instance create call.
>>
>> Using 'instance_count' param you can choose how many instance will be
>> creating using properties you choosed (image, hwp, realm).
>>
>> Sadly, there is support for that in GoGrid, Rackspace or RHEV-M API AFAIK.
>> (If i'm wrong please correct me ;)
>>
>> Second patch is really minor, since I added new text input in
>> launch instance screen, it becomes look very messy, so I cleaned
>> up layout a little bit.
>>
>> Also I replaced 'realm' in instances list screen with hardware profile,
>> which I think is much more usefull for tester/developer IMHO.
>>
>> -- Michal
>>
>
>---
>Toby Crawley
>tcrawley@redhat.com
>
>
>
>
--
--------------------------------------------------------
Michal Fojtik, mfojtik@redhat.com
Deltacloud API: http://deltacloud.org
--------------------------------------------------------
Re: Added support for launching multiple instance at once (EC2)
Posted by Toby Crawley <tc...@redhat.com>.
ACK - this patch works for me.
On Jan 19, 2011, at 9:14 AM, mfojtik@redhat.com wrote:
> Hi,
>
> First patch will add a new feature (currently only EC2 supports that)
> for launching multiple instances in instance create call.
>
> Using 'instance_count' param you can choose how many instance will be
> creating using properties you choosed (image, hwp, realm).
>
> Sadly, there is support for that in GoGrid, Rackspace or RHEV-M API AFAIK.
> (If i'm wrong please correct me ;)
>
> Second patch is really minor, since I added new text input in
> launch instance screen, it becomes look very messy, so I cleaned
> up layout a little bit.
>
> Also I replaced 'realm' in instances list screen with hardware profile,
> which I think is much more usefull for tester/developer IMHO.
>
> -- Michal
>
---
Toby Crawley
tcrawley@redhat.com
[PATCH core 1/2] Added 'instance_count' feature for EC2 driver
Posted by mf...@redhat.com.
From: Michal Fojtik <mf...@redhat.com>
---
server/lib/deltacloud/base_driver/features.rb | 7 +++++
server/lib/deltacloud/drivers/ec2/ec2_driver.rb | 17 ++++++++----
server/views/instances/new.html.haml | 30 ++++++++++++++--------
3 files changed, 37 insertions(+), 17 deletions(-)
diff --git a/server/lib/deltacloud/base_driver/features.rb b/server/lib/deltacloud/base_driver/features.rb
index f20f635..7ec1209 100644
--- a/server/lib/deltacloud/base_driver/features.rb
+++ b/server/lib/deltacloud/base_driver/features.rb
@@ -191,5 +191,12 @@ module Deltacloud
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
diff --git a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
index 7a4b394..0eaaadc 100644
--- a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
+++ b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
@@ -41,6 +41,7 @@ module Deltacloud
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
@@ -132,12 +133,12 @@ module Deltacloud
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 )
@@ -184,6 +185,10 @@ module Deltacloud
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
diff --git a/server/views/instances/new.html.haml b/server/views/instances/new.html.haml
index 558582d..3307183 100644
--- a/server/views/instances/new.html.haml
+++ b/server/views/instances/new.html.haml
@@ -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
--
1.7.3.4
[PATCH core 2/2] Minor UI fixes in launch instance form
Posted by mf...@redhat.com.
From: Michal Fojtik <mf...@redhat.com>
---
server/lib/deltacloud/models/instance.rb | 12 ++++++++
server/lib/deltacloud/models/instance_profile.rb | 4 ++
server/public/stylesheets/compiled/application.css | 30 ++++++++++++++++++++
server/server.rb | 1 +
server/views/images/index.html.haml | 3 +-
server/views/instances/index.html.haml | 4 +-
6 files changed, 50 insertions(+), 4 deletions(-)
diff --git a/server/lib/deltacloud/models/instance.rb b/server/lib/deltacloud/models/instance.rb
index 3c052b9..467d93f 100644
--- a/server/lib/deltacloud/models/instance.rb
+++ b/server/lib/deltacloud/models/instance.rb
@@ -31,6 +31,18 @@ class Instance < BaseModel
attr_accessor :keyname
attr_accessor :authn_error
+ def to_s
+ name
+ end
+
+ def hardware_profile
+ instance_profile
+ end
+
+ def hardware_profile=(profile)
+ instance_profile = profile
+ end
+
def initialize(init=nil)
super(init)
self.actions = [] if self.actions.nil?
diff --git a/server/lib/deltacloud/models/instance_profile.rb b/server/lib/deltacloud/models/instance_profile.rb
index 4e0ce74..ac6081e 100644
--- a/server/lib/deltacloud/models/instance_profile.rb
+++ b/server/lib/deltacloud/models/instance_profile.rb
@@ -38,6 +38,10 @@ class InstanceProfile < BaseModel
id
end
+ def to_s
+ name
+ end
+
def overrides
[:memory, :storage, :architecture, :cpu].inject({}) do |h, p|
if v = instance_variable_get("@#{p}")
diff --git a/server/public/stylesheets/compiled/application.css b/server/public/stylesheets/compiled/application.css
index dd8e763..e354d41 100644
--- a/server/public/stylesheets/compiled/application.css
+++ b/server/public/stylesheets/compiled/application.css
@@ -637,3 +637,33 @@ li.docs {
border : 1px solid #c00;
background : #fbd1d1;
}
+
+.new_instance {
+ border : 1px solid #ccc;
+ border-radius : 5px;
+ background : #eee;
+ clear : both;
+}
+
+.new_instance p {
+ margin : 5px;
+ clear : both;
+}
+
+.new_instance p label {
+ float : left;
+ width : 190px;
+}
+
+.new_instance p input[type=text]{
+ border : 1px solid #ccc;
+ font-size : 115%;
+ border-radius : 5px;
+ width : 220px;
+}
+
+h3.description {
+ float : right;
+ font-size : 70%;
+ color : #ccc;
+}
diff --git a/server/server.rb b/server/server.rb
index 8c3b72c..b5460a8 100644
--- a/server/server.rb
+++ b/server/server.rb
@@ -203,6 +203,7 @@ get "/api/instances/new" do
@image = driver.image( credentials, :id => params[:image_id] )
@hardware_profiles = driver.hardware_profiles(credentials, :architecture => @image.architecture )
@realms = driver.realms(credentials)
+ @keys = driver.keys(credentials) if driver_has_feature?(:authentication_key)
if driver_has_feature?(:register_to_load_balancer)
@load_balancers = driver.load_balancers(credentials)
end
diff --git a/server/views/images/index.html.haml b/server/views/images/index.html.haml
index a713259..b9ef869 100644
--- a/server/views/images/index.html.haml
+++ b/server/views/images/index.html.haml
@@ -1,5 +1,4 @@
-%h1
- Images
+%h1 Images
%table.display
%thead
diff --git a/server/views/instances/index.html.haml b/server/views/instances/index.html.haml
index 2bd4607..e07c174 100644
--- a/server/views/instances/index.html.haml
+++ b/server/views/instances/index.html.haml
@@ -7,7 +7,7 @@
%th Owner
%th Name
%th Image
- %th Realm
+ %th Profile
%th State
%th Actions
%tbody
@@ -22,7 +22,7 @@
%td
= link_to instance.image_id, image_url( instance.image_id )
%td
- = instance.realm_id ? link_to(instance.realm_id, realm_url( instance.realm_id )) : 'default'
+ = instance.hardware_profile ? link_to(instance.hardware_profile, hardware_profile_url( instance.instance_profile.id )) : 'default'
%td
= instance.state
%td
--
1.7.3.4