You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@deltacloud.apache.org by lu...@redhat.com on 2010/10/29 01:59:15 UTC

Two small fixes

These two patches massage the API a little: the first one removes storage
snapshots and volumes from the RHEV-M driver, support for them was greatly
exaggerated. The second patch removes anything from the storage
volume/snapshot API that I'd consider risky in terms of keeping the API
stable.

With these patches, I am actually happy with the state of the API, and will
proceed to the next step: a release.

David


Re: Two small fixes

Posted by David Lutterkort <lu...@redhat.com>.
On Fri, 2010-10-29 at 15:39 -0400, Toby Crawley wrote:
> Sounds good - I'll try to start cranking out patches early next week.
> Would you prefer them posted to the list, or attached to jiras?

I prefer git format-patch && git send-email --thread

David



Re: Two small fixes

Posted by Toby Crawley <tc...@redhat.com>.
On 10/29/2010 01:55 PM, David Lutterkort wrote:
> Hi Toby,
>
> On Thu, 2010-10-28 at 21:20 -0400, Toby Crawley wrote:
>> I've done a bit of work to support storage volume
>> creation/deletion/attachment in the client, server, and ec2 driver to
>> support the SteamCannon project. These changes are currently in our
>> fork (http://github.com/steamcannon/steamcannon-deltacloud), which was
>
> That repo doesn't exist - I assume you mean
> http://github.com/steamcannon/deltacloud

Correct - sorry about that.

>
> Since that repo was forked off the old deltacloud repo, and not off the
> ASF one (http://github.com/apache/deltacloud which mirrors
> git://git.apache.org/deltacloud.git which is a git version of the
> official svn repo) I assume there's a bit of work to be done to
> reconcile the forks.

The fork was initially off of old code, but we've been merging in changes from git://git.apache.org/deltacloud.git periodically, with the 
latest being just after the core v0.0.8/client v0.0.9.8 release. so it's not too far out of date, though the Michal's xml_to_class changes 
will take a bit of work to merge, since I had changes there as well.

>
>>   forked from core v0.0.8/client v0.0.9.8. The features follow the
>> existing ec2 centric model, which I realize is not the plan going
>> forward. They also currently don't have any tests, but are working
>> well for the current version of SteamCannon.
>>
>> I would love to help get these changes integrated into Deltacloud
>> proper (along with tests), and get us off of a fork. I'd be happy to
>> work with the Deltacloud team to make whatever changes are necessary
>> to implement whatever new storage volume api is needed. If you guys
>> aren't ready to design a storage volume api, I'm also willing to pull
>> the changes out into companion gems - this may require a few changes
>> to core/client to make them plugable.
>
> I'd love to have these additions in the 'official' Deltacloud - why
> don't we start the process of integrating the SC fork by you posting
> patches for the storage volume additions.
>
>> I should have some time next week to devote to this.
>
> I'll probably not be very responsive next week, since I'll be at
> ApacheCon. But don't let that keep you from doing stuff ;)

Sounds good - I'll try to start cranking out patches early next week. Would you prefer them posted to the list, or attached to jiras?

>
> David
>
>


Re: Two small fixes

Posted by David Lutterkort <lu...@redhat.com>.
Hi Toby,

On Thu, 2010-10-28 at 21:20 -0400, Toby Crawley wrote:
> I've done a bit of work to support storage volume
> creation/deletion/attachment in the client, server, and ec2 driver to
> support the SteamCannon project. These changes are currently in our
> fork (http://github.com/steamcannon/steamcannon-deltacloud), which was

That repo doesn't exist - I assume you mean
http://github.com/steamcannon/deltacloud

Since that repo was forked off the old deltacloud repo, and not off the
ASF one (http://github.com/apache/deltacloud which mirrors
git://git.apache.org/deltacloud.git which is a git version of the
official svn repo) I assume there's a bit of work to be done to
reconcile the forks.

>  forked from core v0.0.8/client v0.0.9.8. The features follow the
> existing ec2 centric model, which I realize is not the plan going
> forward. They also currently don't have any tests, but are working
> well for the current version of SteamCannon.
> 
> I would love to help get these changes integrated into Deltacloud
> proper (along with tests), and get us off of a fork. I'd be happy to
> work with the Deltacloud team to make whatever changes are necessary
> to implement whatever new storage volume api is needed. If you guys
> aren't ready to design a storage volume api, I'm also willing to pull
> the changes out into companion gems - this may require a few changes
> to core/client to make them plugable.

I'd love to have these additions in the 'official' Deltacloud - why
don't we start the process of integrating the SC fork by you posting
patches for the storage volume additions.

> I should have some time next week to devote to this.

I'll probably not be very responsive next week, since I'll be at
ApacheCon. But don't let that keep you from doing stuff ;)

David



Re: Two small fixes

Posted by Toby Crawley <tc...@redhat.com>.
David:

I've done a bit of work to support storage volume creation/deletion/attachment in the client, server, and ec2 driver to support the 
SteamCannon project. These changes are currently in our fork (http://github.com/steamcannon/steamcannon-deltacloud), which was forked from 
core v0.0.8/client v0.0.9.8. The features follow the existing ec2 centric model, which I realize is not the plan going forward. They also 
currently don't have any tests, but are working well for the current version of SteamCannon.

I would love to help get these changes integrated into Deltacloud proper (along with tests), and get us off of a fork. I'd be happy to work 
with the Deltacloud team to make whatever changes are necessary to implement whatever new storage volume api is needed. If you guys aren't 
ready to design a storage volume api, I'm also willing to pull the changes out into companion gems - this may require a few changes to 
core/client to make them plugable.

I should have some time next week to devote to this.

Toby


On 10/28/2010 07:59 PM, lutter@redhat.com wrote:
> These two patches massage the API a little: the first one removes storage
> snapshots and volumes from the RHEV-M driver, support for them was greatly
> exaggerated. The second patch removes anything from the storage
> volume/snapshot API that I'd consider risky in terms of keeping the API
> stable.
>
> With these patches, I am actually happy with the state of the API, and will
> proceed to the next step: a release.
>
> David
>


[PATCH 1/2] RHEVM Driver: small fixes

Posted by lu...@redhat.com.
From: David Lutterkort <lu...@redhat.com>

  - remove dummy implementations of storage volumes/snapshots
  - fix syntax error
  - implement supported_collections
---
 .../lib/deltacloud/drivers/rhevm/rhevm_driver.rb   |   24 ++++---------------
 1 files changed, 5 insertions(+), 19 deletions(-)

diff --git a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
index 23a20b7..c33158e 100644
--- a/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
+++ b/server/lib/deltacloud/drivers/rhevm/rhevm_driver.rb
@@ -35,6 +35,10 @@ class RHEVMDriver < Deltacloud::BaseDriver
 
   feature :instances, :user_name
 
+  def supported_collections
+    DEFAULT_COLLECTIONS.reject { |c| [ :storage_volumes, :storage_snapshots ].include?(c) }
+  end
+
   #
   # Execute a Powershell command, and convert the output
   # to YAML in order to get back an array of maps.
@@ -85,6 +89,7 @@ class RHEVMDriver < Deltacloud::BaseDriver
       "STOPPED"
     when "POWERING UP"
       "PENDING"
+    end
   end
 
   define_hardware_profile 'rhevm'
@@ -232,25 +237,6 @@ class RHEVMDriver < Deltacloud::BaseDriver
     vm = execute(credentials, "deleteVm.ps1", image_id)
     vm_to_instance(vm[0])
   end
-
-  #
-  # Storage Volumes
-  #
-
-  def storage_volumes(credentials, ids=nil)
-    volumes = []
-    volumes
-  end
-
-  #
-  # Storage Snapshots
-  #
-
-  def storage_snapshots(credentials, ids=nil)
-    snapshots = []
-    snapshots
-  end
-
 end
 
     end
-- 
1.7.2.3


[PATCH 2/2] Storage volumes/snapshots: massage a little

Posted by lu...@redhat.com.
From: David Lutterkort <lu...@redhat.com>

Some minor changes to storage volumes/snapshots, mostly with a view of not
exposing things we might not be able to support:

  - include a unit in the capacity of a volume

  - put the instance/device pair at which a volume might be mounted into a
    <mount/> element, in case we ever need to talk about add'l instances in
    connection with a volume

  - do not report a state for snapshots and volumes; those need to be
    normalized first
---
 client/lib/deltacloud.rb                      |   24 +++++++++++++++---------
 client/specs/storage_volume_spec.rb           |    2 --
 server/views/storage_snapshots/index.xml.haml |    2 --
 server/views/storage_snapshots/show.xml.haml  |    2 --
 server/views/storage_volumes/index.xml.haml   |   12 ++++++------
 server/views/storage_volumes/show.xml.haml    |   14 +++++++-------
 tests/mock/storage_snapshots.feature          |    1 -
 tests/mock/storage_volumes.feature            |    5 +----
 8 files changed, 29 insertions(+), 33 deletions(-)

diff --git a/client/lib/deltacloud.rb b/client/lib/deltacloud.rb
index f797223..c632594 100644
--- a/client/lib/deltacloud.rb
+++ b/client/lib/deltacloud.rb
@@ -90,7 +90,7 @@ module DeltaCloud
     # Define methods based on 'rel' attribute in entry point
     # Two methods are declared: 'images' and 'image'
     def declare_entry_points_methods(entry_points)
-      
+
       API.instance_eval do
         entry_points.keys.select {|k| [:instance_states].include?(k)==false }.each do |model|
 
@@ -99,13 +99,13 @@ module DeltaCloud
               base_object_collection(model, response)
             end
           end
-          
+
           define_method :"#{model.to_s.singularize}" do |*args|
             request(:get, "#{entry_points[model]}/#{args[0]}") do |response|
               base_object(model, response)
             end
           end
-          
+
           define_method :"fetch_#{model.to_s.singularize}" do |url|
             id = url.grep(/\/#{model}\/(.*)$/)
             self.send(model.to_s.singularize.to_sym, $1)
@@ -129,7 +129,7 @@ module DeltaCloud
 
     # Convert XML response to defined Ruby Class
     def xml_to_class(base_object, item)
-      
+
       return nil unless item
 
       params = {
@@ -166,11 +166,17 @@ module DeltaCloud
           end && next
         end
 
+        if attribute.name == 'mount'
+          obj.add_link!("instance", (attribute/"./instance/@id").first)
+          obj.add_text!("device", (attribute/"./device/@name").first.value)
+          next
+        end
+
         # Deal with collections like public-addresses, private-addresses
         if (attribute/'./*').length > 0
           obj.add_collection!(attribute.name, (attribute/'*').collect { |value| value.text }) && next
         end
-        
+
         # Anything else is treaten as text object
         obj.add_text!(attribute.name, attribute.text.convert)
       end
@@ -185,15 +191,15 @@ module DeltaCloud
         api_xml = Nokogiri::XML(response)
         @driver_name = api_xml.xpath('/api').first['driver']
         @api_version = api_xml.xpath('/api').first['version']
-        
+
         api_xml.css("api > link").each do |entry_point|
           rel, href = entry_point['rel'].to_sym, entry_point['href']
           @entry_points.store(rel, href)
-          
+
           entry_point.css("feature").each do |feature|
             @features[rel] ||= []
             @features[rel] << feature['name'].to_sym
-            
+
           end
         end
       end
@@ -247,7 +253,7 @@ module DeltaCloud
       if conf[:query_args] != {}
         conf[:path] += '?' + URI.escape(conf[:query_args].collect{ |key, value| "#{key}=#{value}" }.join('&')).to_s
       end
-      
+
       if conf[:method].eql?(:post)
         RestClient.send(:post, conf[:path], conf[:form_data], default_headers) do |response, request, block|
           handle_backend_error(response) if response.code.eql?(500)
diff --git a/client/specs/storage_volume_spec.rb b/client/specs/storage_volume_spec.rb
index f57d9c1..4ed23b7 100644
--- a/client/specs/storage_volume_spec.rb
+++ b/client/specs/storage_volume_spec.rb
@@ -44,7 +44,6 @@ describe "storage volumes" do
       storage_volume = client.storage_volume( 'vol3' )
       storage_volume.id.should eql( 'vol3' )
       storage_volume.uri.should eql( API_URL + '/storage_volumes/vol3' )
-      storage_volume.state.should eql( 'IN-USE' )
       storage_volume.capacity.should eql( 1.0 )
       storage_volume.device.should eql( '/dev/sda1' )
       storage_volume.instance.should_not be_nil
@@ -61,7 +60,6 @@ describe "storage volumes" do
       storage_volume.should_not be_nil
       storage_volume.id.should eql( 'vol3' )
       storage_volume.uri.should eql( API_URL + '/storage_volumes/vol3' )
-      storage_volume.state.should eql( 'IN-USE' )
       storage_volume.capacity.should eql( 1.0 )
       storage_volume.device.should eql( '/dev/sda1' )
       storage_volume.instance.should_not be_nil
diff --git a/server/views/storage_snapshots/index.xml.haml b/server/views/storage_snapshots/index.xml.haml
index 4813798..8748532 100644
--- a/server/views/storage_snapshots/index.xml.haml
+++ b/server/views/storage_snapshots/index.xml.haml
@@ -4,6 +4,4 @@
     %storage_snapshot{ :href => storage_snapshot_url(snapshot.id), :id => snapshot.id }
       %created<
         =snapshot.created
-      %state<
-        =snapshot.state
       %storage_volume{ :href => storage_volume_url(snapshot.storage_volume_id), :id => snapshot.storage_volume_id }
diff --git a/server/views/storage_snapshots/show.xml.haml b/server/views/storage_snapshots/show.xml.haml
index 8043d1b..3cfa8a6 100644
--- a/server/views/storage_snapshots/show.xml.haml
+++ b/server/views/storage_snapshots/show.xml.haml
@@ -2,6 +2,4 @@
 %storage_snapshot{:href => storage_snapshot_url(@storage_snapshot.id), :id => @storage_snapshot.id }
   %created<
     =@storage_snapshot.created
-  %state<
-    =@storage_snapshot.state
   %storage_volume{:href => storage_volume_url(@storage_snapshot.storage_volume_id), :id => @storage_snapshot.storage_volume_id}
diff --git a/server/views/storage_volumes/index.xml.haml b/server/views/storage_volumes/index.xml.haml
index a96ab61..471169c 100644
--- a/server/views/storage_volumes/index.xml.haml
+++ b/server/views/storage_volumes/index.xml.haml
@@ -4,10 +4,10 @@
     %storage_volume{ :href => storage_volume_url(volume.id), :id => volume.id }
       %created<
         =volume.created
-      %capacity<
-        =volume.capacity
-      - unless volume.device.nil?
-        %device<
-          =volume.device
+      %capacity{ :unit => "GB" }<
+        = volume.capacity
       - unless volume.instance_id.nil?
-        %instance{:href => instance_url(volume.instance_id), :id => volume.instance_id}
+        %mount
+          %instance{:href => instance_url(volume.instance_id), :id => volume.instance_id}
+          - unless volume.device.nil?
+            %device{ :name => volume.device }
diff --git a/server/views/storage_volumes/show.xml.haml b/server/views/storage_volumes/show.xml.haml
index b64ff87..ebf1b24 100644
--- a/server/views/storage_volumes/show.xml.haml
+++ b/server/views/storage_volumes/show.xml.haml
@@ -2,10 +2,10 @@
 %storage_volume{ :href => storage_volume_url(@storage_volume.id), :id => @storage_volume.id}
   %created<
     =@storage_volume.created
-  %capacity<
-    =@storage_volume.capacity
-  %device<
-    =@storage_volume.device
-  %state<
-    =@storage_volume.state
-  %instance{:href => @storage_volume.instance_id, :id => @storage_volume.instance_id}
+  %capacity{ :unit => "GB" }<
+    = @storage_volume.capacity
+  - unless @storage_volume.instance_id.nil?
+    %mount
+      %instance{:href => @storage_volume.instance_id, :id => @storage_volume.instance_id}
+      - unless @storage_volume.device.nil?
+        %device{ :name => @storage_volume.device }
diff --git a/tests/mock/storage_snapshots.feature b/tests/mock/storage_snapshots.feature
index 6870aff..fdaff9c 100644
--- a/tests/mock/storage_snapshots.feature
+++ b/tests/mock/storage_snapshots.feature
@@ -23,5 +23,4 @@ Feature: Accessing storage snapshots
     Then client should get this storage_snapshot
     And this storage_snapshot should have:
     | created |
-    | state |
     | storage_volume |
diff --git a/tests/mock/storage_volumes.feature b/tests/mock/storage_volumes.feature
index f431bc8..3011cf5 100644
--- a/tests/mock/storage_volumes.feature
+++ b/tests/mock/storage_volumes.feature
@@ -6,7 +6,7 @@ Feature: Accessing storage volumes
  # expected: ["capacity", "created", "device", "instance", "state"],
  #    got: ["capacity", "created"] (using ==)
  #
- # When I remove device, instance and state I got back 
+ # When I remove device, instance and state I got back
  # ["capacity", "created", "device", "instance", "state"]
  #
  # Anyway this test isn't usefull, because storage volumes will be
@@ -39,6 +39,3 @@ Feature: Accessing storage volumes
     And this storage_volume should have:
     | created |
     | capacity |
-    | state |
-    | device |
-    | instance |
-- 
1.7.2.3


Re: Two small fixes

Posted by Michal Fojtik <mf...@redhat.com>.
On 28/10/10 16:59 -0700, lutter@redhat.com wrote:
>These two patches massage the API a little: the first one removes storage
>snapshots and volumes from the RHEV-M driver, support for them was greatly
>exaggerated. The second patch removes anything from the storage
>volume/snapshot API that I'd consider risky in terms of keeping the API
>stable.
>
>With these patches, I am actually happy with the state of the API, and will
>proceed to the next step: a release.

ACK && ACK for release. Btw. latest client pushed in SVN has version number
0.1.0, maybe we can push out core with same release number to be in sync
for both things. (core 0.1.0)

   -- Michal

-- 
--------------------------------------------------------
Michal Fojtik, mfojtik@redhat.com
Deltacloud API: http://deltacloud.org
--------------------------------------------------------