incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject svn commit: r1028865 - in /incubator/deltacloud/trunk: client/lib/ client/specs/ server/views/storage_snapshots/ server/views/storage_volumes/ tests/mock/
Date Fri, 29 Oct 2010 17:59:09 GMT
Author: lutter
Date: Fri Oct 29 17:59:09 2010
New Revision: 1028865

URL: http://svn.apache.org/viewvc?rev=1028865&view=rev
Log:
Storage volumes/snapshots: massage a little

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

Modified:
    incubator/deltacloud/trunk/client/lib/deltacloud.rb
    incubator/deltacloud/trunk/client/specs/storage_volume_spec.rb
    incubator/deltacloud/trunk/server/views/storage_snapshots/index.xml.haml
    incubator/deltacloud/trunk/server/views/storage_snapshots/show.xml.haml
    incubator/deltacloud/trunk/server/views/storage_volumes/index.xml.haml
    incubator/deltacloud/trunk/server/views/storage_volumes/show.xml.haml
    incubator/deltacloud/trunk/tests/mock/storage_snapshots.feature
    incubator/deltacloud/trunk/tests/mock/storage_volumes.feature

Modified: incubator/deltacloud/trunk/client/lib/deltacloud.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client/lib/deltacloud.rb?rev=1028865&r1=1028864&r2=1028865&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client/lib/deltacloud.rb (original)
+++ incubator/deltacloud/trunk/client/lib/deltacloud.rb Fri Oct 29 17:59:09 2010
@@ -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)

Modified: incubator/deltacloud/trunk/client/specs/storage_volume_spec.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client/specs/storage_volume_spec.rb?rev=1028865&r1=1028864&r2=1028865&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client/specs/storage_volume_spec.rb (original)
+++ incubator/deltacloud/trunk/client/specs/storage_volume_spec.rb Fri Oct 29 17:59:09 2010
@@ -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

Modified: incubator/deltacloud/trunk/server/views/storage_snapshots/index.xml.haml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/views/storage_snapshots/index.xml.haml?rev=1028865&r1=1028864&r2=1028865&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/views/storage_snapshots/index.xml.haml (original)
+++ incubator/deltacloud/trunk/server/views/storage_snapshots/index.xml.haml Fri Oct 29 17:59:09
2010
@@ -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 }

Modified: incubator/deltacloud/trunk/server/views/storage_snapshots/show.xml.haml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/views/storage_snapshots/show.xml.haml?rev=1028865&r1=1028864&r2=1028865&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/views/storage_snapshots/show.xml.haml (original)
+++ incubator/deltacloud/trunk/server/views/storage_snapshots/show.xml.haml Fri Oct 29 17:59:09
2010
@@ -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}

Modified: incubator/deltacloud/trunk/server/views/storage_volumes/index.xml.haml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/views/storage_volumes/index.xml.haml?rev=1028865&r1=1028864&r2=1028865&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/views/storage_volumes/index.xml.haml (original)
+++ incubator/deltacloud/trunk/server/views/storage_volumes/index.xml.haml Fri Oct 29 17:59:09
2010
@@ -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 }

Modified: incubator/deltacloud/trunk/server/views/storage_volumes/show.xml.haml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/views/storage_volumes/show.xml.haml?rev=1028865&r1=1028864&r2=1028865&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/views/storage_volumes/show.xml.haml (original)
+++ incubator/deltacloud/trunk/server/views/storage_volumes/show.xml.haml Fri Oct 29 17:59:09
2010
@@ -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 }

Modified: incubator/deltacloud/trunk/tests/mock/storage_snapshots.feature
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/tests/mock/storage_snapshots.feature?rev=1028865&r1=1028864&r2=1028865&view=diff
==============================================================================
--- incubator/deltacloud/trunk/tests/mock/storage_snapshots.feature (original)
+++ incubator/deltacloud/trunk/tests/mock/storage_snapshots.feature Fri Oct 29 17:59:09 2010
@@ -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 |

Modified: incubator/deltacloud/trunk/tests/mock/storage_volumes.feature
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/tests/mock/storage_volumes.feature?rev=1028865&r1=1028864&r2=1028865&view=diff
==============================================================================
--- incubator/deltacloud/trunk/tests/mock/storage_volumes.feature (original)
+++ incubator/deltacloud/trunk/tests/mock/storage_volumes.feature Fri Oct 29 17:59:09 2010
@@ -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 |



Mime
View raw message