deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michal Fojtik <mfoj...@redhat.com>
Subject Re: meaning of 'root_type' attribute added to Image and HardwareProfile
Date Tue, 14 May 2013 07:13:32 GMT
On 05/14/2013 05:44 AM, Koper, Dies wrote:
> Hi Michal,
>
> I must not have been paying attention at the time. I just noticed
> <root_type>transient</root_type> on fgcp's image descriptions.
> I'd like to confirm that that is the correct value for fgcp and ror, but
> I don't quite understand what it means.
> Or is this an attribute only relevant to EC2?
> What would one use it for?

Yes, the value is used to differentiate between 'EBS' volume and 
'non-EBS' volume. The 'EBS' volume is 'persistent' and the other one is 
'transient'. If the disk volume (root hard drive) stay in 
/api/storage_volumes for FGCP then the right value would be 'persistent'.

   -- Michal

>
> Regards,
> Dies Koper
>
>
>> -----Original Message-----
>> From: mfojtik@redhat.com [mailto:mfojtik@redhat.com]
>> Sent: Tuesday, 29 January 2013 8:05 AM
>> To: dev@deltacloud.apache.org
>> Subject: [PATCH core] API CHANGE: Added the 'root_type' attribute to
> Image
>> and HardwareProfile
>>
>> From: Michal Fojtik <mfojtik@redhat.com>
>>
>> The new 'root_type' attribute in case of Image contains information
>> about the root device type. There are two possible values:
>>
>> persistent - Volume or other 'persistent' storage type (EBS)
>> transient  - Default device that is part of the Image itself
>> (instance-store)
>>
>> In case of HardwareProfile this attribute is presented as a fixed
>> 'property' called 'root_type'. The possible values are the same as
> above.
>>
>> The hardware profile and image root_type attributes *must* match in
> order
>> to create a new instance. In other case an HTTP 400 (Bad Request) will
>> be
>> returned to client.
>>
>> Signed-off-by: Michal fojtik <mfojtik@redhat.com>
>> ---
>>   server/lib/deltacloud/collections/instances.rb   |  2 +-
>>   server/lib/deltacloud/drivers/ec2/ec2_driver.rb  | 13 ++++++++++++-
>>   server/lib/deltacloud/models/hardware_profile.rb |  4 ++++
>>   server/lib/deltacloud/models/image.rb            |  6 ++++++
>>   server/tests/drivers/ec2/images_test.rb          |  7 +++++++
>>   server/views/images/show.html.haml               |  5 ++++-
>>   server/views/images/show.xml.haml                |  1 +
>>   server/views/instances/new.html.haml             |  2 +-
>>   8 files changed, 36 insertions(+), 4 deletions(-)
>>
>> diff --git a/server/lib/deltacloud/collections/instances.rb
>> b/server/lib/deltacloud/collections/instances.rb
>> index ffdf09d..adddacf 100644
>> --- a/server/lib/deltacloud/collections/instances.rb
>> +++ b/server/lib/deltacloud/collections/instances.rb
>> @@ -23,7 +23,7 @@ module Deltacloud::Collections
>>
>>       new_route_for(:instances) do
>>         @instance =
>> Instance.new( { :id=>params[:id], :image_id=>params[:image_id] } )
>> -      @image   = Image.new( :id => params[:image_id] )
>> +      @image   = driver.image(credentials, :id => params[:image_id])
>>         @hardware_profiles =
>> driver.hardware_profiles(credentials, :architecture =>
>> @image.architecture )
>>         @realms = [Realm.new(:id => params[:realm_id])] if
>> params[:realm_id]
>>         @realms ||= driver.realms(credentials)
>> diff --git a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
>> b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
>> index 9c10ff8..cd048c9 100644
>> --- a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
>> +++ b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
>> @@ -53,6 +53,7 @@ module Deltacloud
>>             memory             613
>>             storage            160
>>             architecture       ['i386','x86_64']
>> +          root_type          :persistent
>>           end
>>
>>           define_hardware_profile('m1.small') do
>> @@ -938,10 +939,15 @@ module Deltacloud
>>               :owner_id => image[:aws_owner],
>>               :architecture => image[:aws_architecture],
>>               :hardware_profiles => image_profiles(image, profiles),
>> -            :state => image[:aws_state]
>> +            :state => image[:aws_state],
>> +            :root_type =>
>> convert_root_type(image[:aws_root_device_type])
>>             )
>>           end
>>
>> +        def convert_root_type(type)
>> +          type == 'ebs' ? 'persistent' : 'transient'
>> +        end
>> +
>>           def convert_instance(instance)
>>             can_create_image = 'ebs'.eql?(instance[:root_device_type])
>> and 'RUNNING'.eql?(convert_state(instance[:aws_state]))
>>             inst_profile_opts={}
>> @@ -1146,6 +1152,11 @@ module Deltacloud
>>           end
>>
>>           exceptions do
>> +
>> +          on /root device is not supported for the instance/ do
>> +            status 400
>> +          end
>> +
>>             on /(AuthFailure|InvalidAccessKeyId)/ do
>>               status 401
>>             end
>> diff --git a/server/lib/deltacloud/models/hardware_profile.rb
>> b/server/lib/deltacloud/models/hardware_profile.rb
>> index 5b4aa4e..9d76a2e 100644
>> --- a/server/lib/deltacloud/models/hardware_profile.rb
>> +++ b/server/lib/deltacloud/models/hardware_profile.rb
>> @@ -46,11 +46,15 @@ module Deltacloud
>>       property :architecture
>>       property :memory
>>       property :storage
>> +    property :root_type
>>
>>       def initialize(profile_id, &block)
>>         @properties   = {}
>>         super(:id => profile_id)
>>         result = instance_eval(&block) if block_given?
>> +      unless @properties.include? :root_type
>> +        root_type(:transient)
>> +      end
>>         @name ||= profile_id
>>         result
>>       end
>> diff --git a/server/lib/deltacloud/models/image.rb
>> b/server/lib/deltacloud/models/image.rb
>> index 551d861..6359661 100644
>> --- a/server/lib/deltacloud/models/image.rb
>> +++ b/server/lib/deltacloud/models/image.rb
>> @@ -24,6 +24,11 @@ class Image < BaseModel
>>     attr_accessor :state
>>     attr_accessor :hardware_profiles
>>     attr_accessor :creation_time
>> +  attr_accessor :root_type
>> +
>> +  def root_type
>> +    @root_type || 'transient'
>> +  end
>>
>>     def to_hash(context)
>>       {
>> @@ -34,6 +39,7 @@ class Image < BaseModel
>>         :owner => owner_id,
>>         :architecture => architecture,
>>         :state => state,
>> +      :root_type => storage_type,
>>         :creation_time => creation_time,
>>         :hardware_profiles => hardware_profiles.map { |p|
>>           { :id => p.id, :href =>
>> context.hardware_profile_url(p.id), :rel => :hardware_profile }
>> diff --git a/server/tests/drivers/ec2/images_test.rb
>> b/server/tests/drivers/ec2/images_test.rb
>> index 857ede7..cf56c9f 100644
>> --- a/server/tests/drivers/ec2/images_test.rb
>> +++ b/server/tests/drivers/ec2/images_test.rb
>> @@ -45,4 +45,11 @@ describe 'Ec2Driver Images' do
>>       @driver.image(:id => 'unknown').must_be_nil
>>     end
>>
>> +  it 'must advertise the image storage_type' do
>> +    VCR.insert_cassette
>> 'test_0004_must_allow_to_retrieve_single_image'
>> +    @driver.image(:id => 'ami-aecd60c7').wont_be_nil
>> +    @driver.image(:id => 'ami-aecd60c7').storage_type.wont_be_nil
>> +    @driver.image(:id => 'ami-aecd60c7').storage_type.must_equal
>> 'ebs'
>> +  end
>> +
>>   end
>> diff --git a/server/views/images/show.html.haml
>> b/server/views/images/show.html.haml
>> index f12ecb4..4ee622d 100644
>> --- a/server/views/images/show.html.haml
>> +++ b/server/views/images/show.html.haml
>> @@ -21,11 +21,14 @@
>>         %li{ :'data-role' => 'list-divider'} Creation Time
>>         %li
>>           %p{ :'data-role' => 'fieldcontain'}=@image.creation_time
>> +    %li{ :'data-role' => 'list-divider'} Root Device Type
>> +    %li
>> +      %p{ :'data-role' => 'fieldcontain'}=@image.root_type
>>       %li{ :'data-role' => 'list-divider'} Architecture
>>       %li
>>         %p{ :'data-role' => 'fieldcontain'}=@image.architecture
>>       - if @image.hardware_profiles
>> -      %li{ :'data-role' => 'list-divider'} Hardware Profiles
>> +      %li{ :'data-role' => 'list-divider'} Compatible Hardware
>> Profiles
>>         %li
>>           %div{ :'data-role' => 'controlgroup', :'data-type' =>
>> "horizontal" }
>>             - @image.hardware_profiles.each do |hwp|
>> diff --git a/server/views/images/show.xml.haml
>> b/server/views/images/show.xml.haml
>> index db33666..ac014af 100644
>> --- a/server/views/images/show.xml.haml
>> +++ b/server/views/images/show.xml.haml
>> @@ -13,6 +13,7 @@
>>       %hardware_profiles
>>         - @image.hardware_profiles.each do |profile|
>>           %hardware_profile{ :href =>
>> hardware_profile_url(profile.id), :id => profile.id, :rel
>> => :hardware_profile }
>> +  %root_type=@image.root_type
>>     %actions
>>       %link{ :rel => 'create_instance', :method => :post, :href =>
>> "#{instances_url};image_id=#{@image.id}"}
>>       - if driver.respond_to? :destroy_image
>> diff --git a/server/views/instances/new.html.haml
>> b/server/views/instances/new.html.haml
>> index 77881ea..f6f674e 100644
>> --- a/server/views/instances/new.html.haml
>> +++ b/server/views/instances/new.html.haml
>> @@ -2,7 +2,7 @@
>>   =subheader "#{@image.id}"
>>
>>   .hidden_content
>> -  - @hardware_profiles.each do |profile|
>> +  - @image.hardware_profiles.each do |profile|
>>       %div{ :'data-role' => :fieldcontain, :id =>
>> "hwp_properties_#{profile.name}", :class => 'property_block'}
>>         - profile.properties.reject { |prop| prop.fixed? }.each do
> |prop|
>>           %label{ :for => "#{prop.param}_#{profile.name}", :class =>
>> 'ui-input-text' }=prop.name
>> --
>> 1.8.1
>>
>
>


-- 

Michal Fojtik <mfojtik@redhat.com>
Deltacloud API, CloudForms

Mime
View raw message