deltacloud-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "marios@redhat.com" <mandr...@redhat.com>
Subject Re: [PATCH core] Core: Added user_name and user_description feature for images collection (DTACLOUD-122)
Date Mon, 12 Mar 2012 07:55:22 GMT
Hi Koper,

On 11/03/12 00:49, Koper, Dies wrote:
> Hi Michal,
> 
> I haven't followed the conversations on IRC and in the bug report, but I
> find the 'user_name' variable confusing in the patch.
> Does this feature allow users to specific a user name that will be
> created in the image/instance's OS which they can later use to log in
> with?
> Or is it just for users to give a name to the image? In that case,
> 'image_name' or just 'name' would be more obvious.

good question; In this case 'user_name' is about signalling whether or
not a given driver will accept a 'user defined name' for the
to-be-created image.

Whilst I understand the possibility for confusion about what 'user_name'
means I think there is slight misunderstanding. 'user_name' is not the
parameter itself, but rather the advertisement that the user can provide
a 'name' parameter. For example:

REQUEST: GET /api?format=xml

RESPONSE:
<api>
( 8<---snip ... )

  <link href='http://localhost:3001/api/images' rel='images'>
    <feature name='owner_id'> </feature>
    <feature name='user_name'></feature>
  </link>
  <link href='http://localhost:3001/api/instances' rel='instances'>
    <feature name='user_data'>
    </feature>
    <feature name='authentication_key'>
    </feature>
    <feature name='firewalls'>
    </feature>
    <feature name='instance_count'>
    </feature>
    <feature name='attach_snapshot'>
    </feature>
    <feature name='hardware_profiles'>
    </feature>
  </link>

</api>

In the above, you can see the 'owner_id' and 'user_name' features
advertised for the 'images' collection and a whole bunch of features
advertised for the 'instances' collection. The exact meaning of these
features is given in the API: http://deltacloud.apache.org/api#h2_1

With respect to the 'user_name' feature for images, this is simply
specifying that for the given back-end cloud provider driver, the user
can specify a 'name' parameter as part of the 'image_create' operation.

At the moment the API documentation won't include information for the
new 'user_name' and 'user_description' features for the images
collection since these are just being defined by Michal's patches... I
expect the docs will catch up soon enough.

Going slightly out of scope here, one problem that I personally find
with the features mechanism is the reliance of the out-of-band
documentation (the API). We advertise the features, but the xml/json
description of them is not enough information for the client; in
particular we don't define which operation (e.g. 'user_name' for
'images' applies to the create operation, i.e. POST /api/images) and
also we don't define the parameter(s) name(s) (i.e. 'name' for the
'user_name' feature). I believe part of the problem is finding an
unambiguous way in which to serialize this information to xml and so for
now we rely on the API. At least I *think* that is the problem; I'd be
interested to hear of anyone else's thoughts on this and suggestions for
improving this mechanism,


marios










> 
> Thanks,
> Dies Koper
> 
> 
>> -----Original Message-----
>> From: mfojtik@redhat.com [mailto:mfojtik@redhat.com]
>> Sent: Saturday, 10 March 2012 4:51 AM
>> To: dev@deltacloud.apache.org
>> Subject: [PATCH core] Core: Added user_name and user_description
> feature
>> for images collection (DTACLOUD-122)
>>
>> From: Michal Fojtik <mfojtik@redhat.com>
>>
>> Previously all drivers that support creating images from instances
>> automatically accepted :name and :description parameters.
>> However in VSphere those parameters are ignored and resulting image
>> inherits name and description for instance used for creation.
>>
>> This patch add two new features for :images collection, that
>> are set for all drivers that support image creation except VSphere.
>>
>> Signed-off-by: Michal fojtik <mfojtik@redhat.com>
>> ---
>>  server/lib/deltacloud/base_driver/features.rb      |   14
> ++++++++++++++
>>  server/lib/deltacloud/drivers/ec2/ec2_driver.rb    |    2 ++
>>  server/lib/deltacloud/drivers/mock/mock_driver.rb  |    2 ++
>>  .../drivers/openstack/openstack_driver.rb          |    1 +
>>  .../drivers/rackspace/rackspace_driver.rb          |    5 +++--
>>  .../lib/deltacloud/drivers/rhevm/rhevm_driver.rb   |    3 ++-
>>  .../deltacloud/drivers/vsphere/vsphere_driver.rb   |    1 -
>>  server/lib/deltacloud/server.rb                    |    8 +++-----
>>  8 files changed, 27 insertions(+), 9 deletions(-)
>>
>> diff --git a/server/lib/deltacloud/base_driver/features.rb
>> b/server/lib/deltacloud/base_driver/features.rb
>> index af1a9c5..37e5ef0 100644
>> --- a/server/lib/deltacloud/base_driver/features.rb
>> +++ b/server/lib/deltacloud/base_driver/features.rb
>> @@ -160,6 +160,20 @@ module Deltacloud
>>        end
>>      end
>>
>> +    declare_feature :images,  :user_name do
>> +      description "Allow specifying user name for created image"
>> +      operation :create do
>> +        param :name,  :string,  :optional,  [],  "Image name"
>> +      end
>> +    end
>> +
>> +    declare_feature :images,  :user_description do
>> +      description "Allow specifying user description for created
> image"
>> +      operation :create do
>> +        param :description, :string,  :optional,  [],  "Image
> description"
>> +      end
>> +    end
>> +
>>      declare_feature :instances, :user_name do
>>        description "Accept a user-defined name on instance creation"
>>        operation :create do
>> diff --git a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
>> b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
>> index 52e91c2..e718971 100644
>> --- a/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
>> +++ b/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
>> @@ -42,6 +42,8 @@ module Deltacloud
>>          feature :instances, :firewalls
>>          feature :instances, :instance_count
>>          feature :images, :owner_id
>> +        feature :images, :user_name
>> +        feature :images, :user_description
>>          feature :buckets, :bucket_location
>>          feature :instances, :attach_snapshot
>>
>> diff --git a/server/lib/deltacloud/drivers/mock/mock_driver.rb
>> b/server/lib/deltacloud/drivers/mock/mock_driver.rb
>> index 765338d..ce77fe2 100644
>> --- a/server/lib/deltacloud/drivers/mock/mock_driver.rb
>> +++ b/server/lib/deltacloud/drivers/mock/mock_driver.rb
>> @@ -87,6 +87,8 @@ module Deltacloud::Drivers::Mock
>>      feature :instances, :user_name
>>      feature :instances, :user_data
>>      feature :instances, :authentication_key
>> +    feature :images, :user_name
>> +    feature :images, :user_description
>>
>>      def initialize
>>        if ENV["DELTACLOUD_MOCK_STORAGE"]
>> diff --git
> a/server/lib/deltacloud/drivers/openstack/openstack_driver.rb
>> b/server/lib/deltacloud/drivers/openstack/openstack_driver.rb
>> index 845ddee..82a2b07 100644
>> --- a/server/lib/deltacloud/drivers/openstack/openstack_driver.rb
>> +++ b/server/lib/deltacloud/drivers/openstack/openstack_driver.rb
>> @@ -25,6 +25,7 @@ module Deltacloud
>>          feature :instances, :user_name
>>          feature :instances, :authentication_password
>>          feature :instances, :user_files
>> +        feature :images, :user_name
>>
>>          def supported_collections
>>            DEFAULT_COLLECTIONS - [ :storage_snapshots,
> :storage_volumes  ]
>> #+ [ :buckets ]
>> diff --git
> a/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
>> b/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
>> index 3779c41..feaa646 100644
>> --- a/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
>> +++ b/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
>> @@ -28,6 +28,7 @@ class RackspaceDriver < Deltacloud::BaseDriver
>>    feature :instances, :user_name
>>    feature :instances, :authentication_password
>>    feature :instances, :user_files
>> +  feature :images, :user_name
>>
>>    def supported_collections
>>      DEFAULT_COLLECTIONS + [ :buckets ] -
>> [ :storage_snapshots, :storage_volumes ]
>> @@ -100,8 +101,8 @@ class RackspaceDriver < Deltacloud::BaseDriver
>>        image = server.create_image(opts[:name])
>>        Image.new(
>>          :id => image.id.to_s,
>> -        :name => image.name,
>> -        :description => image.name,
>> +        :name => opts[:name] || image.name,
>> +        :description => opts[:description] || image.description,
>>          :owner_id => credentials.user,
>>          :state => image.status,
>>          :architecture => 'x86_64'
>> diff --git a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
>> b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
>> index b350071..ac4fe72 100644
>> --- a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
>> +++ b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
>> @@ -32,6 +32,7 @@ class RHEVMDriver < Deltacloud::BaseDriver
>>    end
>>
>>    feature :instances, :user_data
>> +  feature :images, :user_name
>>
>>    USER_NAME_MAX =
>> feature(:instances, :user_name).constraints[:max_length]
>>
>> @@ -110,7 +111,7 @@ class RHEVMDriver < Deltacloud::BaseDriver
>>      end
>>      safely do
>>        new_image = client.create_template(opts[:id], :name =>
> (opts[:name]
>> || template_name),
>> -                                         :description =>
> opts[:description])
>> +                                         :description =>
> opts[:description] ||
>> template_name)
>>        convert_image(client, new_image)
>>      end
>>    end
>> diff --git a/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
>> b/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
>> index f3aeaa5..cbcaa22 100644
>> --- a/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
>> +++ b/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
>> @@ -34,7 +34,6 @@ module Deltacloud::Drivers::VSphere
>>      feature :instances, :user_data
>>      feature :instances, :user_name
>>
>> -
>>      def supported_collections
>>        DEFAULT_COLLECTIONS - [:storage_volumes, :storage_snapshots]
>>      end
>> diff --git a/server/lib/deltacloud/server.rb
> b/server/lib/deltacloud/server.rb
>> index 5ef3cb0..53dd705 100644
>> --- a/server/lib/deltacloud/server.rb
>> +++ b/server/lib/deltacloud/server.rb
>> @@ -249,14 +249,12 @@ END
>>    operation :create do
>>      description 'Create image from instance'
>>      with_capability :create_image
>> -    param :instance_id,	 :string, :required
>> -    param :name,	 :string, :optional
>> -    param :description,	 :string, :optional
>> +    param :instance_id, :string, :required
>>      control do
>>        @image = driver.create_image(credentials, {
>> -	:id => params[:instance_id],
>> +        :id => params[:instance_id],
>>          :name => params[:name],
>> -	:description => params[:description]
>> +        :description => params[:description]
>>        })
>>        status 201  # Created
>>        response['Location'] = image_url(@image.id)
>> --
>> 1.7.9.1
>>
> 
> 


Mime
View raw message