incubator-deltacloud-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lut...@apache.org
Subject svn commit: r962218 - /incubator/deltacloud/trunk/server/libexec/lib/deltacloud/drivers/mock/mock_driver.rb
Date Thu, 08 Jul 2010 23:37:25 GMT
Author: lutter
Date: Thu Jul  8 23:37:25 2010
New Revision: 962218

URL: http://svn.apache.org/viewvc?rev=962218&view=rev
Log:
Fix an increment bug in the mock driver.

While using the mock driver for a while I noticed that my
instances started having weird names.  I eventually figured
out that the mock driver is auto-assigning instance names
based on the instances that already exist.  However, it does
this using the string "succ" method, which means that after
you get to inst9, the next instance is actually insu0.  Fix
it so that we only increment the number part of the name.

Signed-off-by: Chris Lalancette <clalance@redhat.com>

Modified:
    incubator/deltacloud/trunk/server/libexec/lib/deltacloud/drivers/mock/mock_driver.rb

Modified: incubator/deltacloud/trunk/server/libexec/lib/deltacloud/drivers/mock/mock_driver.rb
URL: http://svn.apache.org/viewvc/incubator/deltacloud/trunk/server/libexec/lib/deltacloud/drivers/mock/mock_driver.rb?rev=962218&r1=962217&r2=962218&view=diff
==============================================================================
--- incubator/deltacloud/trunk/server/libexec/lib/deltacloud/drivers/mock/mock_driver.rb (original)
+++ incubator/deltacloud/trunk/server/libexec/lib/deltacloud/drivers/mock/mock_driver.rb Thu
Jul  8 23:37:25 2010
@@ -154,7 +154,15 @@ class MockDriver < Deltacloud::BaseDrive
   def create_instance(credentials, image_id, opts)
     check_credentials( credentials )
     ids = Dir[ "#{STORAGE_ROOT}/instances/*.yml" ].collect{|e| File.basename( e, ".yml" )}
-    next_id = ids.sort.last.succ
+
+    count = 0
+    while true
+      next_id = "inst" + count.to_s
+      if not ids.include?(next_id)
+        break
+      end
+      count = count + 1
+    end
 
     realm_id = opts[:realm_id]
     if ( realm_id.nil? )



Mime
View raw message