incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject svn commit: r962108 - in /incubator/deltacloud/trunk/client-ruby/lib: ./ models/
Date Thu, 08 Jul 2010 23:23:21 GMT
Author: lutter
Date: Thu Jul  8 23:23:20 2010
New Revision: 962108

URL: http://svn.apache.org/viewvc?rev=962108&view=rev
Log:
Added a DCloud module for the model

Modified:
    incubator/deltacloud/trunk/client-ruby/lib/deltacloud.rb
    incubator/deltacloud/trunk/client-ruby/lib/models/base_model.rb
    incubator/deltacloud/trunk/client-ruby/lib/models/flavor.rb
    incubator/deltacloud/trunk/client-ruby/lib/models/image.rb
    incubator/deltacloud/trunk/client-ruby/lib/models/instance.rb
    incubator/deltacloud/trunk/client-ruby/lib/models/realm.rb
    incubator/deltacloud/trunk/client-ruby/lib/models/state.rb
    incubator/deltacloud/trunk/client-ruby/lib/models/storage_snapshot.rb
    incubator/deltacloud/trunk/client-ruby/lib/models/storage_volume.rb
    incubator/deltacloud/trunk/client-ruby/lib/models/transition.rb

Modified: incubator/deltacloud/trunk/client-ruby/lib/deltacloud.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client-ruby/lib/deltacloud.rb?rev=962108&r1=962107&r2=962108&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client-ruby/lib/deltacloud.rb (original)
+++ incubator/deltacloud/trunk/client-ruby/lib/deltacloud.rb Thu Jul  8 23:23:20 2010
@@ -50,7 +50,7 @@ class DeltaCloud
         doc = REXML::Document.new( response.body )
         doc.get_elements( 'flavors/flavor' ).each do |flavor|
           uri = flavor.attributes['href']
-          flavors << Flavor.new( self, uri, flavor )
+          flavors << DCloud::Flavor.new( self, uri, flavor )
         end
       end
     end
@@ -63,7 +63,7 @@ class DeltaCloud
         doc = REXML::Document.new( response.body )
         doc.get_elements( 'flavors/flavor' ).each do |flavor|
           uri = flavor.attributes['href']
-          return Flavor.new( self, uri, flavor )
+          return DCloud::Flavor.new( self, uri, flavor )
         end
       end
     end
@@ -72,7 +72,7 @@ class DeltaCloud
 
   def fetch_flavor(uri)
     xml = fetch_resource( :flavor, uri )
-    return Flavor.new( self, uri, xml ) if xml
+    return DCloud::Flavor.new( self, uri, xml ) if xml
     nil
   end
 
@@ -82,9 +82,9 @@ class DeltaCloud
       if ( response.is_a?( Net::HTTPSuccess ) )
         doc = REXML::Document.new( response.body )
         doc.get_elements( 'states/state' ).each do |state_elem|
-          state = State.new( state_elem.attributes['name'] )
+          state = DCloud::State.new( state_elem.attributes['name'] )
           state_elem.get_elements( 'transition' ).each do |transition_elem|
-            state.transitions << Transition.new( 
+            state.transitions << DCloud::Transition.new( 
                                    transition_elem.attributes['to'],
                                    transition_elem.attributes['action']
                                  )
@@ -108,7 +108,7 @@ class DeltaCloud
         doc = REXML::Document.new( response.body )
         doc.get_elements( 'realms/realm' ).each do |realm|
           uri = realm.attributes['href']
-          realms << Realm.new( self, uri, realm )
+          realms << DCloud::Realm.new( self, uri, realm )
         end
       end
     end
@@ -121,7 +121,7 @@ class DeltaCloud
         doc = REXML::Document.new( response.body )
         doc.get_elements( 'realms/realm' ).each do |realm|
           uri = realm.attributes['href']
-          return Realm.new( self, uri, realm )
+          return DCloud::Realm.new( self, uri, realm )
         end
       end
     end
@@ -130,7 +130,7 @@ class DeltaCloud
 
   def fetch_realm(uri)
     xml = fetch_resource( :realm, uri )
-    return Realm.new( self, uri, xml ) if xml
+    return DCloud::Realm.new( self, uri, xml ) if xml
     nil
   end
 
@@ -142,7 +142,7 @@ class DeltaCloud
         doc = REXML::Document.new( response.body )
         doc.get_elements( 'images/image' ).each do |image|
           uri = image.attributes['href']
-          images << Image.new( self, uri, image )
+          images << DCloud::Image.new( self, uri, image )
         end
       end
     end
@@ -155,7 +155,7 @@ class DeltaCloud
         doc = REXML::Document.new( response.body )
         doc.get_elements( 'images/image' ).each do |instance|
           uri = instance.attributes['href']
-          return Image.new( self, uri, instance )
+          return DCloud::Image.new( self, uri, instance )
         end
       end
     end
@@ -164,7 +164,7 @@ class DeltaCloud
 
   def fetch_image(uri)
     xml = fetch_resource( :image, uri )
-    return Image.new( self, uri, xml ) if xml
+    return DCloud::Image.new( self, uri, xml ) if xml
     nil
   end
 
@@ -188,7 +188,7 @@ class DeltaCloud
         doc = REXML::Document.new( response.body )
         doc.get_elements( 'instances/instance' ).each do |instance|
           uri = instance.attributes['href']
-          return Instance.new( self, uri, instance )
+          return DCloud::Instance.new( self, uri, instance )
         end
       end
     end
@@ -224,7 +224,7 @@ class DeltaCloud
         doc = REXML::Document.new( response.body )
         instance = doc.root
         uri = instance.attributes['href']
-        return Instance.new( self, uri, instance )
+        return DCloud::Instance.new( self, uri, instance )
       end
     end  
   end
@@ -236,7 +236,7 @@ class DeltaCloud
         doc = REXML::Document.new( response.body )
         doc.get_elements( 'storage-volumes/storage-volume' ).each do |instance|
           uri = instance.attributes['href']
-          storage_volumes << StorageVolume.new( self, uri, instance )
+          storage_volumes << DCloud::StorageVolume.new( self, uri, instance )
         end
       end
     end
@@ -249,7 +249,7 @@ class DeltaCloud
         doc = REXML::Document.new( response.body )
         doc.get_elements( 'storage-volumes/storage-volume' ).each do |storage_volume|
           uri = storage_volume.attributes['href']
-          return StorageVolume.new( self, uri, storage_volume )
+          return DCloud::StorageVolume.new( self, uri, storage_volume )
         end
       end
     end
@@ -258,7 +258,7 @@ class DeltaCloud
 
   def fetch_storage_volume(uri)
     xml = fetch_resource( :storage_volume, uri ) 
-    return StorageVolume.new( self, uri, xml ) if xml
+    return DCloud::StorageVolume.new( self, uri, xml ) if xml
     nil
   end
 
@@ -269,7 +269,7 @@ class DeltaCloud
         doc = REXML::Document.new( response.body )
         doc.get_elements( 'storage-snapshots/storage-snapshot' ).each do |instance|
           uri = instance.attributes['href']
-          storage_snapshots << StorageSnapshot.new( self, uri, instance )
+          storage_snapshots << DCloud::StorageSnapshot.new( self, uri, instance )
         end
       end
     end
@@ -282,7 +282,7 @@ class DeltaCloud
         doc = REXML::Document.new( response.body )
         doc.get_elements( 'storage-snapshots/storage-snapshot' ).each do |storage_snapshot|
           uri = storage_snapshot.attributes['href']
-          return StorageSnapshot.new( self, uri, storage_snapshot )
+          return DCloud::StorageSnapshot.new( self, uri, storage_snapshot )
         end
       end
     end

Modified: incubator/deltacloud/trunk/client-ruby/lib/models/base_model.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client-ruby/lib/models/base_model.rb?rev=962108&r1=962107&r2=962108&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client-ruby/lib/models/base_model.rb (original)
+++ incubator/deltacloud/trunk/client-ruby/lib/models/base_model.rb Thu Jul  8 23:23:20 2010
@@ -1,61 +1,63 @@
 
-class BaseModel
+module DCloud
+    class BaseModel
 
-  def self.xml_tag_name(name=nil)
-    unless ( name.nil? ) 
-      @xml_tag_name = name
-    end
-    @xml_tag_name || self.class.name.downcase.to_sym
-  end
+      def self.xml_tag_name(name=nil)
+        unless ( name.nil? ) 
+          @xml_tag_name = name
+        end
+        @xml_tag_name || self.class.name.downcase.to_sym
+      end
+
+
+      def self.attribute(attr)
+        build_reader attr
+      end
+
+      def self.build_reader(attr)
+        eval "
+          def #{attr}
+            check_load_payload
+            @#{attr}
+          end
+        "
+      end
 
+      attr_reader :uri
 
-  def self.attribute(attr)
-    build_reader attr
-  end
+      def initialize(client, uri=nil, xml=nil)
+        @client      = client
+        @uri         = uri
+        @loaded      = false
+        load_payload( xml )
+      end
 
-  def self.build_reader(attr)
-    eval "
-      def #{attr}
+      def id()
         check_load_payload
-        @#{attr}
+        @id
       end
-    "
-  end
 
-  attr_reader :uri
+     
+      protected
 
-  def initialize(client, uri=nil, xml=nil)
-    @client      = client
-    @uri         = uri
-    @loaded      = false
-    load_payload( xml )
-  end
-
-  def id()
-    check_load_payload
-    @id
-  end
-
- 
-  protected
-
-  attr_reader :client
-
-  def check_load_payload()
-    return if @loaded
-    xml = @client.fetch_resource( self.class.xml_tag_name.to_sym, @uri )
-    load_payload(xml)
-  end
-
-  def load_payload(xml=nil)
-    unless ( xml.nil? )
-      @loaded = true
-      @id = xml.text( 'id' ) 
-    end
-  end
+      attr_reader :client
+
+      def check_load_payload()
+        return if @loaded
+        xml = @client.fetch_resource( self.class.xml_tag_name.to_sym, @uri )
+        load_payload(xml)
+      end
 
-  def unload
-    @loaded = false
-  end
+      def load_payload(xml=nil)
+        unless ( xml.nil? )
+          @loaded = true
+          @id = xml.text( 'id' ) 
+        end
+      end
 
+      def unload
+        @loaded = false
+      end
+
+    end
 end

Modified: incubator/deltacloud/trunk/client-ruby/lib/models/flavor.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client-ruby/lib/models/flavor.rb?rev=962108&r1=962107&r2=962108&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client-ruby/lib/models/flavor.rb (original)
+++ incubator/deltacloud/trunk/client-ruby/lib/models/flavor.rb Thu Jul  8 23:23:20 2010
@@ -1,24 +1,26 @@
 
 require 'models/base_model'
 
-class Flavor < BaseModel
+module DCloud
+    class Flavor < BaseModel
 
-  xml_tag_name :flavor
+      xml_tag_name :flavor
 
-  attribute :memory
-  attribute :storage
-  attribute :architecture
-
-  def initialize(client, uri, xml=nil)
-    super( client, uri, xml )
-  end
-
-  def load_payload(xml=nil)
-    super(xml)
-    unless xml.nil?
-      @memory = xml.text( 'memory' ).to_f
-      @storage = xml.text( 'storage' ).to_f
-      @architecture = xml.text( 'architecture' )
+      attribute :memory
+      attribute :storage
+      attribute :architecture
+
+      def initialize(client, uri, xml=nil)
+        super( client, uri, xml )
+      end
+
+      def load_payload(xml=nil)
+        super(xml)
+        unless xml.nil?
+          @memory = xml.text( 'memory' ).to_f
+          @storage = xml.text( 'storage' ).to_f
+          @architecture = xml.text( 'architecture' )
+        end
+      end
     end
-  end
 end

Modified: incubator/deltacloud/trunk/client-ruby/lib/models/image.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client-ruby/lib/models/image.rb?rev=962108&r1=962107&r2=962108&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client-ruby/lib/models/image.rb (original)
+++ incubator/deltacloud/trunk/client-ruby/lib/models/image.rb Thu Jul  8 23:23:20 2010
@@ -1,25 +1,27 @@
 
 require 'models/base_model'
 
-class Image < BaseModel
+module DCloud
+    class Image < BaseModel
 
-  xml_tag_name :image
+      xml_tag_name :image
 
-  attribute :description
-  attribute :owner_id
-  attribute :architecture
-
-  def initialize(client, uri, xml=nil)
-    super( client, uri, xml )
-  end
-
-  def load_payload(xml)
-    super( xml )
-    unless xml.nil?
-      @description = xml.text( 'description' )
-      @owner_id = xml.text( 'owner_id' )
-      @architecture = xml.text( 'architecture' )
-    end
-  end
+      attribute :description
+      attribute :owner_id
+      attribute :architecture
+
+      def initialize(client, uri, xml=nil)
+        super( client, uri, xml )
+      end
+
+      def load_payload(xml)
+        super( xml )
+        unless xml.nil?
+          @description = xml.text( 'description' )
+          @owner_id = xml.text( 'owner_id' )
+          @architecture = xml.text( 'architecture' )
+        end
+      end
 
+    end
 end

Modified: incubator/deltacloud/trunk/client-ruby/lib/models/instance.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client-ruby/lib/models/instance.rb?rev=962108&r1=962107&r2=962108&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client-ruby/lib/models/instance.rb (original)
+++ incubator/deltacloud/trunk/client-ruby/lib/models/instance.rb Thu Jul  8 23:23:20 2010
@@ -1,73 +1,75 @@
 
 require 'models/base_model'
 
-class Instance < BaseModel
+module DCloud
+    class Instance < BaseModel
 
-  xml_tag_name :instance
+      xml_tag_name :instance
 
-  attribute :owner_id
-  attribute :public_addresses
-  attribute :private_addresses
-  attribute :state
-  attribute :actions
-  attribute :image
-  attribute :flavor
-  attribute :realm
-  attribute :action_urls
-
-  def initialize(client, uri, xml=nil)
-    @action_urls = {}
-    super( client, uri, xml )
-  end
-
-  def start!()
-    url = action_urls['start']
-    throw Exception.new( "Unable to start" ) unless url
-    client.post_instance( url )
-    unload
-  end
-
-  def reboot!()
-    url = action_urls['reboot']
-    throw Exception.new( "Unable to reboot" ) unless url
-    client.post_instance( url )
-    unload
-  end
-
-  def stop!()
-    url = action_urls['stop']
-    throw Exception.new( "Unable to stop" ) unless url
-    client.post_instance( url )
-    unload
-  end
-
-  def load_payload(xml=nil)
-    super(xml)
-    unless xml.nil?
-      @owner_id = xml.text('owner_id')
-      @public_addresses = []
-      xml.get_elements( 'public-addresses/address' ).each do |address|
-        @public_addresses << address.text
+      attribute :owner_id
+      attribute :public_addresses
+      attribute :private_addresses
+      attribute :state
+      attribute :actions
+      attribute :image
+      attribute :flavor
+      attribute :realm
+      attribute :action_urls
+
+      def initialize(client, uri, xml=nil)
+        @action_urls = {}
+        super( client, uri, xml )
       end
-      @private_addresses = []
-      xml.get_elements( 'private-addresses/address' ).each do |address|
-        @private_addresses << address.text
+
+      def start!()
+        url = action_urls['start']
+        throw Exception.new( "Unable to start" ) unless url
+        client.post_instance( url )
+        unload
+      end
+
+      def reboot!()
+        url = action_urls['reboot']
+        throw Exception.new( "Unable to reboot" ) unless url
+        client.post_instance( url )
+        unload
       end
-      image_uri = xml.get_elements( 'image' )[0].attributes['href']
-      @image = Image.new( @client, image_uri )
-      flavor_uri = xml.get_elements( 'flavor' )[0].attributes['href']
-      @flavor = Flavor.new( @client, flavor_uri )
-      realm_uri = xml.get_elements( 'realm' )[0].attributes['href']
-      @realm = Realm.new( @client, realm_uri )
-      @state = xml.text( 'state' )
-      @actions = []
-      xml.get_elements( 'actions/link' ).each do |link|
-        action_name = link.attributes['rel']
-        if ( action_name )
-          @actions << link.attributes['rel']
-          @action_urls[ link.attributes['rel'] ] = link.attributes['href']
+
+      def stop!()
+        url = action_urls['stop']
+        throw Exception.new( "Unable to stop" ) unless url
+        client.post_instance( url )
+        unload
+      end
+
+      def load_payload(xml=nil)
+        super(xml)
+        unless xml.nil?
+          @owner_id = xml.text('owner_id')
+          @public_addresses = []
+          xml.get_elements( 'public-addresses/address' ).each do |address|
+            @public_addresses << address.text
+          end
+          @private_addresses = []
+          xml.get_elements( 'private-addresses/address' ).each do |address|
+            @private_addresses << address.text
+          end
+          image_uri = xml.get_elements( 'image' )[0].attributes['href']
+          @image = Image.new( @client, image_uri )
+          flavor_uri = xml.get_elements( 'flavor' )[0].attributes['href']
+          @flavor = Flavor.new( @client, flavor_uri )
+          realm_uri = xml.get_elements( 'realm' )[0].attributes['href']
+          @realm = Realm.new( @client, realm_uri )
+          @state = xml.text( 'state' )
+          @actions = []
+          xml.get_elements( 'actions/link' ).each do |link|
+            action_name = link.attributes['rel']
+            if ( action_name )
+              @actions << link.attributes['rel']
+              @action_urls[ link.attributes['rel'] ] = link.attributes['href']
+            end
+          end
         end
       end
     end
-  end
 end

Modified: incubator/deltacloud/trunk/client-ruby/lib/models/realm.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client-ruby/lib/models/realm.rb?rev=962108&r1=962107&r2=962108&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client-ruby/lib/models/realm.rb (original)
+++ incubator/deltacloud/trunk/client-ruby/lib/models/realm.rb Thu Jul  8 23:23:20 2010
@@ -1,28 +1,30 @@
 require 'models/base_model'
 
-class Realm < BaseModel
+module DCloud
+    class Realm < BaseModel
 
-  xml_tag_name :realm
+      xml_tag_name :realm
 
-  attribute :name
-  attribute :state
-  attribute :limit
+      attribute :name
+      attribute :state
+      attribute :limit
 
-  def initialize(client, uri, xml=nil)
-    super( client, uri, xml )
-  end
+      def initialize(client, uri, xml=nil)
+        super( client, uri, xml )
+      end
 
-  def load_payload(xml=nil)
-    super(xml)
-    unless xml.nil?
-      @name = xml.text( 'name' )
-      @state = xml.text( 'state' )
-      @limit = xml.text( 'limit' )
-      if ( @limit.nil? || @limit == '' )
-        @limit = :unlimited
-      else
-        @limit = @limit.to_f
+      def load_payload(xml=nil)
+        super(xml)
+        unless xml.nil?
+          @name = xml.text( 'name' )
+          @state = xml.text( 'state' )
+          @limit = xml.text( 'limit' )
+          if ( @limit.nil? || @limit == '' )
+            @limit = :unlimited
+          else
+            @limit = @limit.to_f
+          end
+        end
       end
     end
-  end
 end

Modified: incubator/deltacloud/trunk/client-ruby/lib/models/state.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client-ruby/lib/models/state.rb?rev=962108&r1=962107&r2=962108&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client-ruby/lib/models/state.rb (original)
+++ incubator/deltacloud/trunk/client-ruby/lib/models/state.rb Thu Jul  8 23:23:20 2010
@@ -1,12 +1,13 @@
+module DCloud
+    class State
 
-class State
+      attr_accessor :name
+      attr_accessor :transitions
 
-  attr_accessor :name
-  attr_accessor :transitions
-
-  def initialize(name)
-    @name = name
-    @transitions = []
-  end
+      def initialize(name)
+        @name = name
+        @transitions = []
+      end
 
+    end
 end

Modified: incubator/deltacloud/trunk/client-ruby/lib/models/storage_snapshot.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client-ruby/lib/models/storage_snapshot.rb?rev=962108&r1=962107&r2=962108&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client-ruby/lib/models/storage_snapshot.rb (original)
+++ incubator/deltacloud/trunk/client-ruby/lib/models/storage_snapshot.rb Thu Jul  8 23:23:20
2010
@@ -1,31 +1,33 @@
 
 require 'models/base_model'
 
-class StorageSnapshot < BaseModel
+module DCloud
+    class StorageSnapshot < BaseModel
 
-  xml_tag_name :storage_snapshot
+      xml_tag_name :storage_snapshot
 
-  attribute :created
-  attribute :state
-  attribute :storage_volume
-
-  def initialize(client, uri, xml=nil)
-    super( client, uri, xml )
-  end
-
-  def load_payload(xml=nil)
-    super(xml)
-    unless xml.nil?
-      @created = xml.text( 'created' )
-      @state = xml.text( 'state' )
-      storage_volumes = xml.get_elements( 'storage-volume' )
-      if ( ! storage_volumes.empty? )
-        storage_volume = storage_volumes.first
-        storage_volume_href = storage_volume.attributes['href']
-        if ( storage_volume_href ) 
-          @storage_volume = StorageVolume.new( @client, storage_volume_href )
+      attribute :created
+      attribute :state
+      attribute :storage_volume
+
+      def initialize(client, uri, xml=nil)
+        super( client, uri, xml )
+      end
+
+      def load_payload(xml=nil)
+        super(xml)
+        unless xml.nil?
+          @created = xml.text( 'created' )
+          @state = xml.text( 'state' )
+          storage_volumes = xml.get_elements( 'storage-volume' )
+          if ( ! storage_volumes.empty? )
+            storage_volume = storage_volumes.first
+            storage_volume_href = storage_volume.attributes['href']
+            if ( storage_volume_href ) 
+              @storage_volume = StorageVolume.new( @client, storage_volume_href )
+            end
+          end
         end
       end
     end
-  end
 end

Modified: incubator/deltacloud/trunk/client-ruby/lib/models/storage_volume.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client-ruby/lib/models/storage_volume.rb?rev=962108&r1=962107&r2=962108&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client-ruby/lib/models/storage_volume.rb (original)
+++ incubator/deltacloud/trunk/client-ruby/lib/models/storage_volume.rb Thu Jul  8 23:23:20
2010
@@ -1,34 +1,36 @@
 require 'models/base_model'
 
-class StorageVolume < BaseModel
+module DCloud
+    class StorageVolume < BaseModel
 
-  xml_tag_name :storage_volume
+      xml_tag_name :storage_volume
 
-  attribute :created
-  attribute :state
-  attribute :capacity
-  attribute :device
-  attribute :instance
+      attribute :created
+      attribute :state
+      attribute :capacity
+      attribute :device
+      attribute :instance
 
-  def initialize(client, uri, xml=nil)
-    super( client, uri, xml )
-  end
+      def initialize(client, uri, xml=nil)
+        super( client, uri, xml )
+      end
 
-  def load_payload(xml=nil)
-    super(xml)
-    unless xml.nil?
-      @created = xml.text( 'created' )
-      @state = xml.text( 'state' )
-      @capacity = xml.text( 'capacity' ).to_f
-      @device = xml.text( 'device' )
-      instances = xml.get_elements( 'instance' )
-      if ( ! instances.empty? )
-        instance = instances.first
-        instance_href = instance.attributes['href']
-        if ( instance_href ) 
-          @instance = Instance.new( @client, instance_href )
+      def load_payload(xml=nil)
+        super(xml)
+        unless xml.nil?
+          @created = xml.text( 'created' )
+          @state = xml.text( 'state' )
+          @capacity = xml.text( 'capacity' ).to_f
+          @device = xml.text( 'device' )
+          instances = xml.get_elements( 'instance' )
+          if ( ! instances.empty? )
+            instance = instances.first
+            instance_href = instance.attributes['href']
+            if ( instance_href ) 
+              @instance = Instance.new( @client, instance_href )
+            end
+          end
         end
       end
     end
-  end
 end

Modified: incubator/deltacloud/trunk/client-ruby/lib/models/transition.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client-ruby/lib/models/transition.rb?rev=962108&r1=962107&r2=962108&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client-ruby/lib/models/transition.rb (original)
+++ incubator/deltacloud/trunk/client-ruby/lib/models/transition.rb Thu Jul  8 23:23:20 2010
@@ -1,16 +1,18 @@
 
-class Transition
+module DCloud
+    class Transition
 
-  attr_accessor :to
-  attr_accessor :action
+      attr_accessor :to
+      attr_accessor :action
 
-  def initialize(to, action)
-    @to = to
-    @action = action
-  end
+      def initialize(to, action)
+        @to = to
+        @action = action
+      end
 
-  def auto?()
-    @action.nil?
-  end
+      def auto?()
+        @action.nil?
+      end
 
+    end
 end



Mime
View raw message