deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mfoj...@apache.org
Subject git commit: Core: Added user_name and user_description feature for images collection (DTACLOUD-122)
Date Mon, 12 Mar 2012 13:55:39 GMT
Updated Branches:
  refs/heads/master a4bb0be3f -> d28c40c1c


Core: Added user_name and user_description feature for images collection (DTACLOUD-122)

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.


Project: http://git-wip-us.apache.org/repos/asf/deltacloud/repo
Commit: http://git-wip-us.apache.org/repos/asf/deltacloud/commit/d28c40c1
Tree: http://git-wip-us.apache.org/repos/asf/deltacloud/tree/d28c40c1
Diff: http://git-wip-us.apache.org/repos/asf/deltacloud/diff/d28c40c1

Branch: refs/heads/master
Commit: d28c40c1cb06d252eb4c39adba3924f171944cca
Parents: a4bb0be
Author: Michal Fojtik <mfojtik@redhat.com>
Authored: Fri Mar 9 18:47:59 2012 +0100
Committer: Michal fojtik <mfojtik@redhat.com>
Committed: Mon Mar 12 14:56:30 2012 +0100

----------------------------------------------------------------------
 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(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d28c40c1/server/lib/deltacloud/base_driver/features.rb
----------------------------------------------------------------------
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

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d28c40c1/server/lib/deltacloud/drivers/ec2/ec2_driver.rb
----------------------------------------------------------------------
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
 

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d28c40c1/server/lib/deltacloud/drivers/mock/mock_driver.rb
----------------------------------------------------------------------
diff --git a/server/lib/deltacloud/drivers/mock/mock_driver.rb b/server/lib/deltacloud/drivers/mock/mock_driver.rb
index e522926..86e096e 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"]

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d28c40c1/server/lib/deltacloud/drivers/openstack/openstack_driver.rb
----------------------------------------------------------------------
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 ]

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d28c40c1/server/lib/deltacloud/drivers/rackspace/rackspace_driver.rb
----------------------------------------------------------------------
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'

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d28c40c1/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
----------------------------------------------------------------------
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

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d28c40c1/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
----------------------------------------------------------------------
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

http://git-wip-us.apache.org/repos/asf/deltacloud/blob/d28c40c1/server/lib/deltacloud/server.rb
----------------------------------------------------------------------
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)


Mime
View raw message