incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject svn commit: r962295 - in /incubator/deltacloud/trunk/server: lib/converters/xml_converter.rb lib/deltacloud/helpers/hardware_profiles_helper.rb server.rb views/instances/new.html.haml views/instances/show.html.haml
Date Thu, 08 Jul 2010 23:44:04 GMT
Author: lutter
Date: Thu Jul  8 23:44:04 2010
New Revision: 962295

URL: http://svn.apache.org/viewvc?rev=962295&view=rev
Log:
Server: Show instances with HWP, create instances with them

Modified:
    incubator/deltacloud/trunk/server/lib/converters/xml_converter.rb
    incubator/deltacloud/trunk/server/lib/deltacloud/helpers/hardware_profiles_helper.rb
    incubator/deltacloud/trunk/server/server.rb
    incubator/deltacloud/trunk/server/views/instances/new.html.haml
    incubator/deltacloud/trunk/server/views/instances/show.html.haml

Modified: incubator/deltacloud/trunk/server/lib/converters/xml_converter.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/converters/xml_converter.rb?rev=962295&r1=962294&r2=962295&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/converters/xml_converter.rb (original)
+++ incubator/deltacloud/trunk/server/lib/converters/xml_converter.rb Thu Jul  8 23:44:04
2010
@@ -82,6 +82,13 @@ module Converters
               builder.owner_id( obj.owner_id )
               builder.image( :href=>@link_builder.send( :image_url, obj.image_id ) )
               builder.flavor( :href=>@link_builder.send( :flavor_url, obj.flavor_id )
)
+              builder.__send__( 'hardware-profile', :href=>@link_builder.send( :hardware_profile_url,
obj.instance_profile.name) ) do
+                builder.id( obj.instance_profile.name )
+                obj.instance_profile.overrides.each do |p, v|
+                  u = ::Deltacloud::HardwareProfile::unit(p)
+                  builder.property( :kind=>:fixed, :name=>p, :unit=>u, :value=>v
)
+                end
+              end
               builder.realm( :href=>@link_builder.send( :realm_url, obj.realm_id ) ) if
obj.realm_id
               builder.state( obj.state )
               builder.actions {

Modified: incubator/deltacloud/trunk/server/lib/deltacloud/helpers/hardware_profiles_helper.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/lib/deltacloud/helpers/hardware_profiles_helper.rb?rev=962295&r1=962294&r2=962295&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/lib/deltacloud/helpers/hardware_profiles_helper.rb (original)
+++ incubator/deltacloud/trunk/server/lib/deltacloud/helpers/hardware_profiles_helper.rb Thu
Jul  8 23:44:04 2010
@@ -13,10 +13,23 @@ module HardwareProfilesHelper
     end
   end
 
+  def format_instance_profile(ip)
+    o = ip.overrides.collect do |p, v|
+      u = hardware_property_unit(p)
+      "#{p} = #{v} #{u}"
+    end
+    if o.empty?
+      ""
+    else
+      "with #{o.join(", ")}"
+    end
+  end
+
+  private
   def hardware_property_unit(prop)
-    u = prop.unit
+    u = ::Deltacloud::HardwareProfile::unit(prop)
     u = "" if ["label", "count"].include?(u)
-    u = "vcpus" if prop.name == :cpu
+    u = "vcpus" if prop == :cpu
     u
   end
 end

Modified: incubator/deltacloud/trunk/server/server.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/server.rb?rev=962295&r1=962294&r2=962295&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/server.rb (original)
+++ incubator/deltacloud/trunk/server/server.rb Thu Jul  8 23:44:04 2010
@@ -214,6 +214,7 @@ get "/api/instances/new" do
   @instance = Instance.new( { :id=>params[:id], :image_id=>params[:image_id] } )
   @image   = driver.image( credentials, :id => params[:image_id] )
   @flavors = driver.flavors( credentials, { :architecture=>@image.architecture } )
+  @hardware_profiles = driver.hardware_profiles(credentials, :architecture => @image.architecture
)
   @realms = driver.realms(credentials)
   respond_to do |format|
     format.html { haml :"instances/new" }
@@ -250,7 +251,12 @@ collection :instances do
     param :image_id,     :string, :required
     param :realm_id,     :string, :optional
     param :flavor_id,    :string, :optional
+    param :hwp_id,       :string, :optional
     control do
+      # FIXME: Strictly speaking, we'd need to check that only either
+      # hwp_id or flavor_id are set, but not both. Since flavors will go
+      # away shortly, we can be a little sloppy
+      params[:hwp_id] = params[:flavor_id] if params[:flavor_id]
       @image = driver.image(credentials, :id => params[:image_id])
       instance = driver.create_instance(credentials, @image.id, params)
       respond_to do |format|

Modified: incubator/deltacloud/trunk/server/views/instances/new.html.haml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/views/instances/new.html.haml?rev=962295&r1=962294&r2=962295&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/views/instances/new.html.haml (original)
+++ incubator/deltacloud/trunk/server/views/instances/new.html.haml Thu Jul  8 23:44:04 2010
@@ -8,16 +8,34 @@
   %label
     Instance Name:
   %input{ :name => 'name', :size => 30 }/
-  - if !@flavors.empty?
-    %h3 What flavor of machine?
-    - for flavor in @flavors
+  - if !@hardware_profiles.empty?
+    %h3 What size machine?
+    - for hwp in @hardware_profiles
       .radio-group
-        %label{ :for => "flavor_id_#{flavor.id}" }
-          %input{ :type => :radio, :name => 'flavor_id', :value => flavor.id }/
-          = flavor.id
+        %label{ :for => "hwp_id_#{hwp.name}" }
+          %input{ :type => :radio, :name => 'hwp_id', :value => hwp.name }/
+          = hwp.name
           %br/
           %span.radio-group-details
-            = "#{flavor.architecture}, #{flavor.memory} GB, #{flavor.storage} GB"
+            - first = true
+            - hwp.properties.select { |prop| prop.fixed? }.each do |prop|
+              - unless first
+                ,
+              - first = false
+              = format_hardware_property prop
+          - hwp.properties.reject { |prop| prop.fixed? }.each do |prop|
+            %span.radio-group-details
+              %label{ :for => "#{prop.param}_#{hwp.name}" }
+                = prop.name
+              - if prop.kind == :enum
+                %select{ :size => 1, :name => prop.param }
+                  - for v in prop.values
+                    %option= v
+                = prop.unit
+              - else
+                %input{ :name => prop.param, :size => 10, :value => "#{prop.default}"
}
+                = prop.unit
+                (value must be between #{prop.first} #{prop.unit} and #{prop.last} #{prop.unit})
   - if !@realms.empty?
     %h3 Where do you want it?
     - for realm in @realms

Modified: incubator/deltacloud/trunk/server/views/instances/show.html.haml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/views/instances/show.html.haml?rev=962295&r1=962294&r2=962295&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/views/instances/show.html.haml (original)
+++ incubator/deltacloud/trunk/server/views/instances/show.html.haml Thu Jul  8 23:44:04 2010
@@ -19,6 +19,12 @@
     %dd
       = @instance.flavor_id ? link_to(@instance.flavor_id, flavor_url(@instance.flavor_id))
: 'default'
   %di
+    %dt Hardware Profile
+    %dd
+      - prof = @instance.instance_profile
+      = link_to(prof.name, hardware_profile_url(prof.name))
+      = format_instance_profile(prof)
+  %di
     %dt Realm
     %dd
       = @instance.realm_id ? link_to(@instance.realm_id, realm_url(@instance.realm_id)) :
'default'



Mime
View raw message