incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject svn commit: r961996 - in /incubator/deltacloud/trunk/framework: app/controllers/ app/views/instances/ lib/drivers/ public/stylesheets/ public/stylesheets/sass/
Date Thu, 08 Jul 2010 23:15:45 GMT
Author: lutter
Date: Thu Jul  8 23:15:45 2010
New Revision: 961996

URL: http://svn.apache.org/viewvc?rev=961996&view=rev
Log:
Allow spinning up of images against appropriate VM flavors.

Modified:
    incubator/deltacloud/trunk/framework/app/controllers/instances_controller.rb
    incubator/deltacloud/trunk/framework/app/views/instances/new.html.erb
    incubator/deltacloud/trunk/framework/app/views/instances/show.html.erb
    incubator/deltacloud/trunk/framework/lib/drivers/ec2.rb
    incubator/deltacloud/trunk/framework/public/stylesheets/application.css
    incubator/deltacloud/trunk/framework/public/stylesheets/sass/application.sass

Modified: incubator/deltacloud/trunk/framework/app/controllers/instances_controller.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/app/controllers/instances_controller.rb?rev=961996&r1=961995&r2=961996&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/app/controllers/instances_controller.rb (original)
+++ incubator/deltacloud/trunk/framework/app/controllers/instances_controller.rb Thu Jul 
8 23:15:45 2010
@@ -39,7 +39,6 @@ class InstancesController < ApplicationC
 
   def new
     @instance = {
-                  :new_record=>true,
                   :id=>params[:id],
                   :image_id=>params[:image_id],
                 } 
@@ -48,7 +47,16 @@ class InstancesController < ApplicationC
   end
 
   def create
-    instance = driver.create_instance( credentials, params[:image_id] )
+    @image   = driver.image( credentials, params[:image_id] )
+    if ( params[:flavor_id].nil? )
+      @flavors = driver.flavors_by_architecture( credentials, @image[:architecture] )
+      @instance = {
+                    :id=>params[:id],
+                    :image_id=>params[:image_id],
+                  } 
+      render :action=>:new and return 
+    end
+    instance = driver.create_instance( credentials, @image[:id], params[:flavor_id] )
     redirect_to instance_url( instance[:id] )
   end
 

Modified: incubator/deltacloud/trunk/framework/app/views/instances/new.html.erb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/app/views/instances/new.html.erb?rev=961996&r1=961995&r2=961996&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/app/views/instances/new.html.erb (original)
+++ incubator/deltacloud/trunk/framework/app/views/instances/new.html.erb Thu Jul  8 23:15:45
2010
@@ -1,11 +1,20 @@
 <h1>New Instance</h1>
 
-<h2><%= @instance[:image_id] %></h2>
+<h2><%= @image[:id] %></h2>
+<h3><%= @image[:description] %></h3>
 
 <% form_tag instances_url do %>
   <%= hidden_field_tag :image_id, @instance[:image_id] %>
-  <select>
-    <%= options_for_select @flavors, nil %>
-  </select>
+  <% for flavor in @flavors %>
+    <div class="radio-group">
+      <label for="flavor_id_<%=flavor[:id]%>">
+        <%= radio_button_tag 'flavor_id', flavor[:id] %>
+        <%= flavor[:id] %><br/>
+        <span class="radio-group-details">
+          <%= flavor[:architecture] %>, <%= flavor[:memory] %> GB, <%= flavor[:storage]
%> GB
+        </span>
+      </label>
+    </div>
+  <% end %>
   <%= submit_tag 'create' %>
 <% end %>

Modified: incubator/deltacloud/trunk/framework/app/views/instances/show.html.erb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/app/views/instances/show.html.erb?rev=961996&r1=961995&r2=961996&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/app/views/instances/show.html.erb (original)
+++ incubator/deltacloud/trunk/framework/app/views/instances/show.html.erb Thu Jul  8 23:15:45
2010
@@ -23,7 +23,7 @@
       Flavor
     </dt>
     <dd>
-      <%= @instance[:flavor] %>
+      <%= link_to @instance[:flavor_id], flavor_url( @instance[:flavor_id] ) %>
     </dd>
   </di>
   <di>

Modified: incubator/deltacloud/trunk/framework/lib/drivers/ec2.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/lib/drivers/ec2.rb?rev=961996&r1=961995&r2=961996&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/lib/drivers/ec2.rb (original)
+++ incubator/deltacloud/trunk/framework/lib/drivers/ec2.rb Thu Jul  8 23:15:45 2010
@@ -86,7 +86,7 @@ module Drivers
       instances
     end
 
-    def create_instance(credentials, image_id)
+    def create_instance(credentials, image_id, flavor_id)
       ec2 = new_client( credentials )
       ec2_instances = ec2.run_instances( 
                             image_id, 
@@ -95,7 +95,7 @@ module Drivers
                             nil,
                             '',
                             'public',
-                            'm1.small' )
+                            flavor_id.gsub( /-/, '.' ) )
       convert_instance( ec2_instances.first )
     end
 

Modified: incubator/deltacloud/trunk/framework/public/stylesheets/application.css
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/public/stylesheets/application.css?rev=961996&r1=961995&r2=961996&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/public/stylesheets/application.css (original)
+++ incubator/deltacloud/trunk/framework/public/stylesheets/application.css Thu Jul  8 23:15:45
2010
@@ -50,3 +50,22 @@ table {
     background-color: #cccccc; }
   table td {
     background-color: #eeeeee; }
+
+.radio-group {
+  font-size: 90%;
+  margin-bottom: 1em;
+  background-color: #cccccc; }
+  .radio-group label {
+    font-weight: bold; }
+
+.radio-group-details {
+  font-weight: normal;
+  display: block;
+  padding-left: 1em;
+  background-color: #eeeeee;
+  padding: 1ex; }
+
+input[type='radio'] {
+  margin-top: 1ex;
+  margin-left: 1ex;
+  margin-bottom: 1ex; }

Modified: incubator/deltacloud/trunk/framework/public/stylesheets/sass/application.sass
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/public/stylesheets/sass/application.sass?rev=961996&r1=961995&r2=961996&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/public/stylesheets/sass/application.sass (original)
+++ incubator/deltacloud/trunk/framework/public/stylesheets/sass/application.sass Thu Jul
 8 23:15:45 2010
@@ -61,3 +61,21 @@ table
     :background-color = !td_bg
 
 
+.radio-group
+  :font-size 90%
+  :margin-bottom 1em
+  :background-color = !th_bg
+  label
+    :font-weight bold
+
+.radio-group-details
+  :font-weight normal
+  :display block
+  :padding-left 1em
+  :background-color = !td_bg
+  :padding 1ex
+
+input[type='radio']
+  :margin-top 1ex
+  :margin-left 1ex
+  :margin-bottom 1ex



Mime
View raw message