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 2013/04/04 18:14:44 UTC

[PATCH core] Core: Add 'public_key' feature for :keys collection

From: Michal Fojtik <mf...@redhat.com>

This feature indicate wheter cloud provider support
uploading of custom PEM keys or not.

Signed-off-by: Michal fojtik <mf...@redhat.com>
---
 server/lib/deltacloud/collections/keys.rb                         | 1 -
 server/lib/deltacloud/drivers/digitalocean/digitalocean_driver.rb | 1 +
 server/lib/deltacloud/drivers/features.rb                         | 7 +++++++
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/server/lib/deltacloud/collections/keys.rb b/server/lib/deltacloud/collections/keys.rb
index d1b5541..c5df3f9 100644
--- a/server/lib/deltacloud/collections/keys.rb
+++ b/server/lib/deltacloud/collections/keys.rb
@@ -34,7 +34,6 @@ module Deltacloud::Collections
 
       operation :create, :with_capability => :create_key do
         param :name,  :string,  :required
-        param :public_key, :string, :optional
         control do
           @key = driver.create_key(credentials, { :key_name => params[:name], :public_key => params[:public_key]})
           status 201
diff --git a/server/lib/deltacloud/drivers/digitalocean/digitalocean_driver.rb b/server/lib/deltacloud/drivers/digitalocean/digitalocean_driver.rb
index 666f105..ff4d967 100644
--- a/server/lib/deltacloud/drivers/digitalocean/digitalocean_driver.rb
+++ b/server/lib/deltacloud/drivers/digitalocean/digitalocean_driver.rb
@@ -22,6 +22,7 @@ module Deltacloud
 
         feature :instances, :user_name, :authentication_key
         feature :images, :owner_id
+        feature :keys, :public_key
 
         define_instance_states do
           start.to( :pending )          .on( :create )
diff --git a/server/lib/deltacloud/drivers/features.rb b/server/lib/deltacloud/drivers/features.rb
index 2f3621c..5f19032 100644
--- a/server/lib/deltacloud/drivers/features.rb
+++ b/server/lib/deltacloud/drivers/features.rb
@@ -30,6 +30,13 @@ module Deltacloud
 
     features do
 
+      feature :public_key, :for => :keys do
+        description "Allow to upload custom SSH public key"
+        operation :create do
+          param :public_key,  :string,  :optional,  [],  "SSH public key"
+        end
+      end
+
       feature :owner_id, :for => :images do
         description "Filter images using owner id"
         operation :index do
-- 
1.8.1.4


Re: [PATCH core] Core: Add 'public_key' feature for :keys collection

Posted by David Lutterkort <lu...@redhat.com>.
On Thu, 2013-04-04 at 18:14 +0200, mfojtik@redhat.com wrote:
> From: Michal Fojtik <mf...@redhat.com>
> 
> This feature indicate wheter cloud provider support
> uploading of custom PEM keys or not.

Is the public_key for the create operation truly optional ?

Also, we need an update for the docs to go with this.

David



Re: [PATCH core] Core: Add 'public_key' feature for :keys collection

Posted by Michal Fojtik <mf...@redhat.com>.
On 04/05/2013 10:28 AM, marios@redhat.com wrote:
> On 04/04/13 19:14, mfojtik@redhat.com wrote:
>> From: Michal Fojtik <mf...@redhat.com>
>>
>> This feature indicate wheter cloud provider support
>> uploading of custom PEM keys or not.
>>
>
> we already have a 'import_key' feature -  see openstack driver (same
> thing, import existing public key when you want to add to Keys collection)

+1 good point I overlooked that one. This seems exactly what 
DigitalOcean needs.

One change I will send as new patch is that we should not have 
'public_key' in create operation in keys (it is feature param).

Also as we already agreed, the 'feature name' should be the same as the 
parameter name that this feature provides. So instead of 'import_key' I 
will call the feature 'public_key' or 'public_ssh_key' (same name for 
feature parameter).

Off topic:

Do we have any feature to indicate how the key is returned?

For example in EC2, when I create a new key, the PEM key is returned in 
<pem>. Where if I create new key in OpenStack/DigitalOcean, then key is 
returned as public SSH key in 'PEM'.

We should have a feature that will say that in this provider you get PEM 
key back and in this provider you get 'Public SSH key' back.

  -- Michal

>
> marios
>
>> Signed-off-by: Michal fojtik <mf...@redhat.com>
>> ---
>>   server/lib/deltacloud/collections/keys.rb                         | 1 -
>>   server/lib/deltacloud/drivers/digitalocean/digitalocean_driver.rb | 1 +
>>   server/lib/deltacloud/drivers/features.rb                         | 7 +++++++
>>   3 files changed, 8 insertions(+), 1 deletion(-)
>>
>> diff --git a/server/lib/deltacloud/collections/keys.rb b/server/lib/deltacloud/collections/keys.rb
>> index d1b5541..c5df3f9 100644
>> --- a/server/lib/deltacloud/collections/keys.rb
>> +++ b/server/lib/deltacloud/collections/keys.rb
>> @@ -34,7 +34,6 @@ module Deltacloud::Collections
>>
>>         operation :create, :with_capability => :create_key do
>>           param :name,  :string,  :required
>> -        param :public_key, :string, :optional
>>           control do
>>             @key = driver.create_key(credentials, { :key_name => params[:name], :public_key => params[:public_key]})
>>             status 201
>> diff --git a/server/lib/deltacloud/drivers/digitalocean/digitalocean_driver.rb b/server/lib/deltacloud/drivers/digitalocean/digitalocean_driver.rb
>> index 666f105..ff4d967 100644
>> --- a/server/lib/deltacloud/drivers/digitalocean/digitalocean_driver.rb
>> +++ b/server/lib/deltacloud/drivers/digitalocean/digitalocean_driver.rb
>> @@ -22,6 +22,7 @@ module Deltacloud
>>
>>           feature :instances, :user_name, :authentication_key
>>           feature :images, :owner_id
>> +        feature :keys, :public_key
>>
>>           define_instance_states do
>>             start.to( :pending )          .on( :create )
>> diff --git a/server/lib/deltacloud/drivers/features.rb b/server/lib/deltacloud/drivers/features.rb
>> index 2f3621c..5f19032 100644
>> --- a/server/lib/deltacloud/drivers/features.rb
>> +++ b/server/lib/deltacloud/drivers/features.rb
>> @@ -30,6 +30,13 @@ module Deltacloud
>>
>>       features do
>>
>> +      feature :public_key, :for => :keys do
>> +        description "Allow to upload custom SSH public key"
>> +        operation :create do
>> +          param :public_key,  :string,  :optional,  [],  "SSH public key"
>> +        end
>> +      end
>> +
>>         feature :owner_id, :for => :images do
>>           description "Filter images using owner id"
>>           operation :index do
>>
>


-- 

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

Re: [PATCH core] Core: Add 'public_key' feature for :keys collection

Posted by "marios@redhat.com" <ma...@redhat.com>.
On 04/04/13 19:14, mfojtik@redhat.com wrote:
> From: Michal Fojtik <mf...@redhat.com>
> 
> This feature indicate wheter cloud provider support
> uploading of custom PEM keys or not.
> 

we already have a 'import_key' feature -  see openstack driver (same
thing, import existing public key when you want to add to Keys collection)

marios

> Signed-off-by: Michal fojtik <mf...@redhat.com>
> ---
>  server/lib/deltacloud/collections/keys.rb                         | 1 -
>  server/lib/deltacloud/drivers/digitalocean/digitalocean_driver.rb | 1 +
>  server/lib/deltacloud/drivers/features.rb                         | 7 +++++++
>  3 files changed, 8 insertions(+), 1 deletion(-)
> 
> diff --git a/server/lib/deltacloud/collections/keys.rb b/server/lib/deltacloud/collections/keys.rb
> index d1b5541..c5df3f9 100644
> --- a/server/lib/deltacloud/collections/keys.rb
> +++ b/server/lib/deltacloud/collections/keys.rb
> @@ -34,7 +34,6 @@ module Deltacloud::Collections
>  
>        operation :create, :with_capability => :create_key do
>          param :name,  :string,  :required
> -        param :public_key, :string, :optional
>          control do
>            @key = driver.create_key(credentials, { :key_name => params[:name], :public_key => params[:public_key]})
>            status 201
> diff --git a/server/lib/deltacloud/drivers/digitalocean/digitalocean_driver.rb b/server/lib/deltacloud/drivers/digitalocean/digitalocean_driver.rb
> index 666f105..ff4d967 100644
> --- a/server/lib/deltacloud/drivers/digitalocean/digitalocean_driver.rb
> +++ b/server/lib/deltacloud/drivers/digitalocean/digitalocean_driver.rb
> @@ -22,6 +22,7 @@ module Deltacloud
>  
>          feature :instances, :user_name, :authentication_key
>          feature :images, :owner_id
> +        feature :keys, :public_key
>  
>          define_instance_states do
>            start.to( :pending )          .on( :create )
> diff --git a/server/lib/deltacloud/drivers/features.rb b/server/lib/deltacloud/drivers/features.rb
> index 2f3621c..5f19032 100644
> --- a/server/lib/deltacloud/drivers/features.rb
> +++ b/server/lib/deltacloud/drivers/features.rb
> @@ -30,6 +30,13 @@ module Deltacloud
>  
>      features do
>  
> +      feature :public_key, :for => :keys do
> +        description "Allow to upload custom SSH public key"
> +        operation :create do
> +          param :public_key,  :string,  :optional,  [],  "SSH public key"
> +        end
> +      end
> +
>        feature :owner_id, :for => :images do
>          description "Filter images using owner id"
>          operation :index do
>