incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject svn commit: r962112 - in /incubator/deltacloud/trunk/client-ruby: lib/dcloud/instance.rb lib/deltacloud.rb specs/fixtures/instances/inst1.yml specs/fixtures/instances/inst2.yml specs/instance_states_spec.rb specs/instances_spec.rb
Date Thu, 08 Jul 2010 23:23:40 GMT
Author: lutter
Date: Thu Jul  8 23:23:39 2010
New Revision: 962112

URL: http://svn.apache.org/viewvc?rev=962112&view=rev
Log:
Add name to instance objects.
Add :name to create_instance.

Modified:
    incubator/deltacloud/trunk/client-ruby/lib/dcloud/instance.rb
    incubator/deltacloud/trunk/client-ruby/lib/deltacloud.rb
    incubator/deltacloud/trunk/client-ruby/specs/fixtures/instances/inst1.yml
    incubator/deltacloud/trunk/client-ruby/specs/fixtures/instances/inst2.yml
    incubator/deltacloud/trunk/client-ruby/specs/instance_states_spec.rb
    incubator/deltacloud/trunk/client-ruby/specs/instances_spec.rb

Modified: incubator/deltacloud/trunk/client-ruby/lib/dcloud/instance.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client-ruby/lib/dcloud/instance.rb?rev=962112&r1=962111&r2=962112&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client-ruby/lib/dcloud/instance.rb (original)
+++ incubator/deltacloud/trunk/client-ruby/lib/dcloud/instance.rb Thu Jul  8 23:23:39 2010
@@ -6,6 +6,7 @@ module DCloud
 
       xml_tag_name :instance
 
+      attribute :name
       attribute :owner_id
       attribute :public_addresses
       attribute :private_addresses
@@ -46,6 +47,7 @@ module DCloud
         super(xml)
         unless xml.nil?
           @owner_id = xml.text('owner_id')
+          @name     = xml.text('name')
           @public_addresses = []
           xml.get_elements( 'public-addresses/address' ).each do |address|
             @public_addresses << address.text

Modified: incubator/deltacloud/trunk/client-ruby/lib/deltacloud.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client-ruby/lib/deltacloud.rb?rev=962112&r1=962111&r2=962112&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client-ruby/lib/deltacloud.rb (original)
+++ incubator/deltacloud/trunk/client-ruby/lib/deltacloud.rb Thu Jul  8 23:23:39 2010
@@ -175,7 +175,7 @@ class DeltaCloud
         doc = REXML::Document.new( response.body )
         doc.get_elements( 'instances/instance' ).each do |instance|
           uri = instance.attributes['href']
-          instances << Instance.new( self, uri, instance )
+          instances << DCloud::Instance.new( self, uri, instance )
         end
       end
     end
@@ -206,17 +206,19 @@ class DeltaCloud
 
   def fetch_instance(uri)
     xml = fetch_resource( :instance, uri )
-    return Instance.new( self, uri, xml ) if xml
+    return DCloud::Instance.new( self, uri, xml ) if xml
     nil
   end
 
   def create_instance(image_id, opts={})
+    name = opts[:name]
     realm_id = opts[:realm]
     flavor_id = opts[:flavor]
 
     params = {}
     ( params[:realm_id] = realm_id ) if realm_id
     ( params[:flavor_id] = flavor_id ) if flavor_id
+    ( params[:name] = name ) if name
 
     params[:image_id] = image_id
     request( entry_points[:instances], :post, {}, params ) do |response|
@@ -291,7 +293,7 @@ class DeltaCloud
 
   def fetch_storage_snapshot(uri)
     xml = fetch_resource( :storage_snapshot, uri ) 
-    return StorageSnapshot.new( self, uri, xml ) if xml
+    return DCloud::StorageSnapshot.new( self, uri, xml ) if xml
     nil
   end
 

Modified: incubator/deltacloud/trunk/client-ruby/specs/fixtures/instances/inst1.yml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client-ruby/specs/fixtures/instances/inst1.yml?rev=962112&r1=962111&r2=962112&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client-ruby/specs/fixtures/instances/inst1.yml (original)
+++ incubator/deltacloud/trunk/client-ruby/specs/fixtures/instances/inst1.yml Thu Jul  8 23:23:39
2010
@@ -1,3 +1,4 @@
+:name: MockUserInstance
 :state: RUNNING
 :image_id: img3
 :owner_id: mockuser

Modified: incubator/deltacloud/trunk/client-ruby/specs/fixtures/instances/inst2.yml
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client-ruby/specs/fixtures/instances/inst2.yml?rev=962112&r1=962111&r2=962112&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client-ruby/specs/fixtures/instances/inst2.yml (original)
+++ incubator/deltacloud/trunk/client-ruby/specs/fixtures/instances/inst2.yml Thu Jul  8 23:23:39
2010
@@ -1,3 +1,4 @@
+:name: AnotherInstance
 :state: RUNNING
 :image_id: img1
 :owner_id: anotheruser

Modified: incubator/deltacloud/trunk/client-ruby/specs/instance_states_spec.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client-ruby/specs/instance_states_spec.rb?rev=962112&r1=962111&r2=962112&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client-ruby/specs/instance_states_spec.rb (original)
+++ incubator/deltacloud/trunk/client-ruby/specs/instance_states_spec.rb Thu Jul  8 23:23:39
2010
@@ -22,7 +22,7 @@ describe "instance-states" do
 
       instance_states[0].name.should eql( 'begin' )
       instance_states[0].transitions.size.should eql( 1 )
-      instance_states[0].transitions[0].should be_auto
+      instance_states[0].transitions[0].should_not be_auto
 
       instance_states[1].name.should eql( 'pending' )
       instance_states[1].transitions.size.should eql( 1 )

Modified: incubator/deltacloud/trunk/client-ruby/specs/instances_spec.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/client-ruby/specs/instances_spec.rb?rev=962112&r1=962111&r2=962112&view=diff
==============================================================================
--- incubator/deltacloud/trunk/client-ruby/specs/instances_spec.rb (original)
+++ incubator/deltacloud/trunk/client-ruby/specs/instances_spec.rb Thu Jul  8 23:23:39 2010
@@ -15,9 +15,9 @@ describe "instances" do
         instance.owner_id.should_not be_nil
         instance.owner_id.should be_a( String )
         instance.image.should_not be_nil
-        instance.image.should be_a( Image )
+        instance.image.should be_a( DCloud::Image )
         instance.flavor.should_not be_nil
-        instance.flavor.should be_a( Flavor )
+        instance.flavor.should be_a( DCloud::Flavor )
         instance.state.should_not be_nil
         instance.state.should be_a( String )
         instance.public_addresses.should_not be_nil
@@ -45,6 +45,8 @@ describe "instances" do
     DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
       instance = client.instance( "inst1" )
       instance.should_not be_nil
+      instance.name.should_not be_nil
+      instance.name.should eql( 'MockUserInstance' )
       instance.uri.should_not be_nil
       instance.uri.should be_a( String )
       instance.owner_id.should eql( "mockuser" )
@@ -60,10 +62,11 @@ describe "instances" do
 
   it "should allow creation of new instances with reasonable defaults" do
     DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client|
-      instance = client.create_instance( 'img1' )
+      instance = client.create_instance( 'img1', :name=>'TestInstance' )
       instance.should_not be_nil
       instance.uri.should eql( API_URL + '/instances/inst3' )
       instance.id.should eql( 'inst3' )
+      instance.name.should eql( 'TestInstance' )
       instance.image.id.should eql( 'img1' )
       instance.flavor.id.should eql( 'm1-large' )
       instance.realm.id.should eql( 'us' )



Mime
View raw message