You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by lu...@apache.org on 2010/07/09 01:15:22 UTC

svn commit: r961991 - in /incubator/deltacloud/trunk/framework: app/controllers/instances_controller.rb app/controllers/storage_snapshots_controller.rb app/helpers/conversion_helper.rb lib/converters/xml_converter.rb lib/drivers/ec2.rb

Author: lutter
Date: Thu Jul  8 23:15:22 2010
New Revision: 961991

URL: http://svn.apache.org/viewvc?rev=961991&view=rev
Log:
Adjust XML serialization to handle lack of an account/owner resource.
Adjust for singular/plural delegation.

Modified:
    incubator/deltacloud/trunk/framework/app/controllers/instances_controller.rb
    incubator/deltacloud/trunk/framework/app/controllers/storage_snapshots_controller.rb
    incubator/deltacloud/trunk/framework/app/helpers/conversion_helper.rb
    incubator/deltacloud/trunk/framework/lib/converters/xml_converter.rb
    incubator/deltacloud/trunk/framework/lib/drivers/ec2.rb

Modified: incubator/deltacloud/trunk/framework/app/controllers/instances_controller.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/app/controllers/instances_controller.rb?rev=961991&r1=961990&r2=961991&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/app/controllers/instances_controller.rb (original)
+++ incubator/deltacloud/trunk/framework/app/controllers/instances_controller.rb Thu Jul  8 23:15:22 2010
@@ -20,7 +20,6 @@ class InstancesController < ApplicationC
   def show
     @instance = driver.instance( credentials, params[:id] )
 
-
     respond_to do |format|
       format.html {
         render :text=>'resource not found', :status=>404 and return unless @instance

Modified: incubator/deltacloud/trunk/framework/app/controllers/storage_snapshots_controller.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/app/controllers/storage_snapshots_controller.rb?rev=961991&r1=961990&r2=961991&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/app/controllers/storage_snapshots_controller.rb (original)
+++ incubator/deltacloud/trunk/framework/app/controllers/storage_snapshots_controller.rb Thu Jul  8 23:15:22 2010
@@ -18,6 +18,7 @@ class StorageSnapshotsController < Appli
       format.html
       format.json
       format.xml {
+        render :xml=>convert_to_xml( :storage_snapshot, @snapshot )
       }
     end
   end

Modified: incubator/deltacloud/trunk/framework/app/helpers/conversion_helper.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/app/helpers/conversion_helper.rb?rev=961991&r1=961990&r2=961991&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/app/helpers/conversion_helper.rb (original)
+++ incubator/deltacloud/trunk/framework/app/helpers/conversion_helper.rb Thu Jul  8 23:15:22 2010
@@ -4,7 +4,7 @@ load 'converters/xml_converter.rb'
 module ConversionHelper
 
   def convert_to_xml(type, obj)
-    if ( [ :account, :image, :instance ].include?( type ) )
+    if ( [ :account, :image, :instance, :storage_volume, :storage_snapshot ].include?( type ) )
       Converters::XMLConverter.new( self, type ).convert(obj)
     end
   end

Modified: incubator/deltacloud/trunk/framework/lib/converters/xml_converter.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/lib/converters/xml_converter.rb?rev=961991&r1=961990&r2=961991&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/lib/converters/xml_converter.rb (original)
+++ incubator/deltacloud/trunk/framework/lib/converters/xml_converter.rb Thu Jul  8 23:15:22 2010
@@ -2,12 +2,13 @@
 module Converters
 
   ALIASES = {
-    :owner=>:account
+    :owner=>nil
   }
 
-  def self.get_url_type(type)
+  def self.url_type(type)
     type = type.to_sym
-    ALIASES[type] || type
+    return ALIASES[type] if ( ALIASES.keys.include?( type ) )
+    type
   end
 
   def self.tag_name(type)
@@ -44,8 +45,12 @@ module Converters
               end
             elsif ( k.to_s =~/^(.*)_id$/ )
               type = $1
-              url_type = Converters.get_type( $1 )
-              builder.__send__( type, :href=>@link_builder.send( "#{url_type}_url", v ) )
+              url_type = Converters.url_type( $1 )
+              unless ( url_type.nil? )
+                builder.__send__( type, :href=>@link_builder.send( "#{url_type}_url", v ) )
+              else
+                builder.__send__( "#{type}_id", v )
+              end
             else
               builder.__send__( Converters.tag_name( k ), v )
             end

Modified: incubator/deltacloud/trunk/framework/lib/drivers/ec2.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/framework/lib/drivers/ec2.rb?rev=961991&r1=961990&r2=961991&view=diff
==============================================================================
--- incubator/deltacloud/trunk/framework/lib/drivers/ec2.rb (original)
+++ incubator/deltacloud/trunk/framework/lib/drivers/ec2.rb Thu Jul  8 23:15:22 2010
@@ -34,7 +34,7 @@ module Drivers
     # Instances
     # 
 
-    def instances(credentials, *ids)
+    def instances(credentials, ids)
       ec2 = new_client(credentials)
       instances = []
       safely do