Signed-off-by: Chris Lalancette clalance@redhat.com --- client/lib/deltacloud.rb | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/client/lib/deltacloud.rb b/client/lib/deltacloud.rb index c38eb97..37649dc 100644 --- a/client/lib/deltacloud.rb +++ b/client/lib/deltacloud.rb @@ -15,6 +15,7 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+require 'rubygems' require 'rest_client' require 'rexml/document' require 'logger'
Signed-off-by: Chris Lalancette clalance@redhat.com --- .../lib/deltacloud/drivers/mock/mock_driver.rb | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/server/libexec/lib/deltacloud/drivers/mock/mock_driver.rb b/server/libexec/lib/deltacloud/drivers/mock/mock_driver.rb index 73cdcc4..e22a615 100644 --- a/server/libexec/lib/deltacloud/drivers/mock/mock_driver.rb +++ b/server/libexec/lib/deltacloud/drivers/mock/mock_driver.rb @@ -25,7 +25,7 @@ class MockDriver < Deltacloud::BaseDriver
unless defined?(STORAGE_ROOT) STORAGE_ROOT = File::join(File::dirname(__FILE__), - "../../../../../../client/specs/data") + "../../../../../../client/specs/fixtures") end
#
On Wed, 2010-02-17 at 15:35 -0500, Chris Lalancette wrote:
Signed-off-by: Chris Lalancette clalance@redhat.com
.../lib/deltacloud/drivers/mock/mock_driver.rb | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/server/libexec/lib/deltacloud/drivers/mock/mock_driver.rb b/server/libexec/lib/deltacloud/drivers/mock/mock_driver.rb index 73cdcc4..e22a615 100644 --- a/server/libexec/lib/deltacloud/drivers/mock/mock_driver.rb +++ b/server/libexec/lib/deltacloud/drivers/mock/mock_driver.rb @@ -25,7 +25,7 @@ class MockDriver < Deltacloud::BaseDriver
unless defined?(STORAGE_ROOT) STORAGE_ROOT = File::join(File::dirname(__FILE__),
"../../../../../../client/specs/data")
"../../../../../../client/specs/fixtures"
Funny - that's the way I had it initially; but since fixtures is controlled by git, using that directory will pollute your status with info about added and changed files.
For now, the right way to use the Mock driver is to run 'rake fixtures' in the client dir first. That's still not right, since when you install the server as a rubygem, there's no client dir from which you can pull fixtures.
The real fix for this is to * copy the current data from fixtures into the mock driver dir (or a subdir) * when the mock driver starts, check if /var/tmp/deltacloud-mock-$USER or similar exists. If not, copy the local fixtures there. Use that dir in /var/tmp as the MOCK_STORAGE_ROOT
David
It's been ignored since aa35c0c3c11719fc47ec09170c72e162df66682b.
Signed-off-by: Chris Lalancette clalance@redhat.com --- server/libexec/config/environment.rb | 3 --- 1 files changed, 0 insertions(+), 3 deletions(-)
diff --git a/server/libexec/config/environment.rb b/server/libexec/config/environment.rb index 5d967f3..caf8f98 100644 --- a/server/libexec/config/environment.rb +++ b/server/libexec/config/environment.rb @@ -93,9 +93,6 @@ $: << DRIVER_ROOT+'/lib' case DRIVER when :mock DRIVER_CLASS_NAME = "Deltacloud::Drivers::Mock::MockDriver" - mock_storage_root = File.dirname( __FILE__ ) + "/../../client/specs/data" - puts "Using mock storage root of #{mock_storage_root}" - MOCK_STORAGE_ROOT = mock_storage_root when :ec2 DRIVER_CLASS_NAME = "Deltacloud::Drivers::EC2::EC2Driver" when :rackspace
On Wed, 2010-02-17 at 15:35 -0500, Chris Lalancette wrote:
It's been ignored since aa35c0c3c11719fc47ec09170c72e162df66682b.
Signed-off-by: Chris Lalancette clalance@redhat.com
Actually, that whole dir needs to be looked at, and most, if not all, of it is not needed anymore. These are all Rails specific files.
David
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 --- .../lib/deltacloud/drivers/mock/mock_driver.rb | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/server/libexec/lib/deltacloud/drivers/mock/mock_driver.rb b/server/libexec/lib/deltacloud/drivers/mock/mock_driver.rb index e22a615..1e16235 100644 --- a/server/libexec/lib/deltacloud/drivers/mock/mock_driver.rb +++ b/server/libexec/lib/deltacloud/drivers/mock/mock_driver.rb @@ -152,7 +152,15 @@ class MockDriver < Deltacloud::BaseDriver 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? )
On Wed, 2010-02-17 at 15:35 -0500, Chris Lalancette wrote:
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
.../lib/deltacloud/drivers/mock/mock_driver.rb | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-)
ACK.
David
On 02/18/2010 02:17 PM, David Lutterkort wrote:
On Wed, 2010-02-17 at 15:35 -0500, Chris Lalancette wrote:
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
.../lib/deltacloud/drivers/mock/mock_driver.rb | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-)
ACK.
Thanks, I've pushed this now.
On Thu, 2010-02-25 at 14:48 -0500, Chris Lalancette wrote:
On 02/18/2010 02:17 PM, David Lutterkort wrote:
On Wed, 2010-02-17 at 15:35 -0500, Chris Lalancette wrote:
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
.../lib/deltacloud/drivers/mock/mock_driver.rb | 10 +++++++++- 1 files changed, 9 insertions(+), 1 deletions(-)
ACK.
Thanks, I've pushed this now.
I just noticed that that causes the client tests to fail (since they expect a fixed instance name). Pushing this patch to fix that:
From 0517bc3032124757769e1d5712931539faa725fd Mon Sep 17 00:00:00 2001
From: David Lutterkort lutter@redhat.com Date: Fri, 26 Feb 2010 14:54:13 -0800 Subject: [PATCH core] * client/specs/instances_spec.rb: account for changing instance names
Fixes test breakage from 399ef311 --- client/specs/instances_spec.rb | 16 ++++++++-------- 1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/client/specs/instances_spec.rb b/client/specs/instances_spec.rb index b088f74..d5a7816 100644 --- a/client/specs/instances_spec.rb +++ b/client/specs/instances_spec.rb @@ -81,8 +81,8 @@ describe "instances" do DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client| 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.uri.should match( %r{#{API_URL}/instances/inst[0-9]+} ) + instance.id.should match( /inst[0-9]+/ ) instance.name.should eql( 'TestInstance' ) instance.image.id.should eql( 'img1' ) instance.flavor.id.should eql( 'm1-large' ) @@ -94,8 +94,8 @@ describe "instances" do DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client| instance = client.create_instance( 'img1', :realm=>'eu' ) instance.should_not be_nil - instance.uri.should eql( API_URL + '/instances/inst3' ) - instance.id.should eql( 'inst3' ) + instance.uri.should match( %r{#{API_URL}/instances/inst[0-9]+} ) + instance.id.should match( /inst[0-9]+/ ) instance.image.id.should eql( 'img1' ) instance.flavor.id.should eql( 'm1-large' ) instance.realm.id.should eql( 'eu' ) @@ -106,8 +106,8 @@ describe "instances" do DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client| instance = client.create_instance( 'img1', :flavor=>'m1-xlarge' ) instance.should_not be_nil - instance.uri.should eql( API_URL + '/instances/inst3' ) - instance.id.should eql( 'inst3' ) + instance.uri.should match( %r{#{API_URL}/instances/inst[0-9]+} ) + instance.id.should match( /inst[0-9]+/ ) instance.image.id.should eql( 'img1' ) instance.flavor.id.should eql( 'm1-xlarge' ) instance.realm.id.should eql( 'us' ) @@ -118,8 +118,8 @@ describe "instances" do DeltaCloud.new( API_NAME, API_PASSWORD, API_URL ) do |client| instance = client.create_instance( 'img1', :realm=>'eu', :flavor=>'m1-xlarge' ) instance.should_not be_nil - instance.uri.should eql( API_URL + '/instances/inst3' ) - instance.id.should eql( 'inst3' ) + instance.uri.should match( %r{#{API_URL}/instances/inst[0-9]+} ) + instance.id.should match( /inst[0-9]+/ ) instance.image.id.should eql( 'img1' ) instance.flavor.id.should eql( 'm1-xlarge' ) instance.realm.id.should eql( 'eu' )
I am going to say NACK, I don't think we need this. I was just reading about ruby lib packaging the other day, and came across these articles that were strongly against requiring rubygems in code:
* http://weblog.rubyonrails.org/2009/9/1/gem-packaging-best-practices (near bottom) * http://gist.github.com/54177 * http://yehudakatz.com/2009/07/24/rubygems-good-practice/
-j
On Wed, Feb 17, 2010 at 3:35 PM, Chris Lalancette clalance@redhat.com wrote:
Signed-off-by: Chris Lalancette clalance@redhat.com
client/lib/deltacloud.rb | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/client/lib/deltacloud.rb b/client/lib/deltacloud.rb index c38eb97..37649dc 100644 --- a/client/lib/deltacloud.rb +++ b/client/lib/deltacloud.rb @@ -15,6 +15,7 @@ # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+require 'rubygems' require 'rest_client' require 'rexml/document' require 'logger' -- 1.6.6
deltacloud-devel mailing list deltacloud-devel@lists.fedorahosted.org https://fedorahosted.org/mailman/listinfo/deltacloud-devel
deltacloud-devel@lists.fedorahosted.org