Permalink
Browse files

Move AccountCapacity out of models/

  This fixes the bug of Sequel Models loading before Migrations are
applied by
    - moving account_capacity.rb out of models dir, and
    - moving the corresponding class out of the Models namespace
  for two reasons:
    - It's not a Sequel model
    - We don't want to auto-load the models before migrations are applied.

Change-Id: Ib1bb28c1e6c4350613a942dee71a5bef128dab88
  • Loading branch information...
1 parent a5a2dad commit 23cdaff240e084f6e6c0480f6b6ef894ac9a8007 @d d committed Aug 9, 2012
@@ -1,7 +1,7 @@
# Copyright (c) 2009-2012 VMware, Inc.
# port of legacy acount capacity model
-module VCAP::CloudController::Models
+module VCAP::CloudController
class AccountCapacity
DEFAULT_MEM = 2*1024 # 8GB total
DEFAULT_URIS = 4 # per app
@@ -1,4 +1,5 @@
require "vcap/config"
+require "cloud_controller/account_capacity"
# Config template for cloud controller
class VCAP::CloudController::Config < VCAP::Config
@@ -77,7 +78,7 @@ def self.configure(config)
# method as there will be more along these lines.
VCAP::CloudController::MessageBus.configure(config)
VCAP::CloudController::RestController::QuotaManager.configure(config)
- VCAP::CloudController::Models::AccountCapacity.configure(config)
+ VCAP::CloudController::AccountCapacity.configure(config)
VCAP::CloudController::ResourcePool.configure(config)
VCAP::CloudController::FilesystemPool.configure(config)
VCAP::CloudController::AppPackage.configure(config)
@@ -48,9 +48,9 @@ def service_info
def account_capacity
if user.admin?
- Models::AccountCapacity.admin
+ AccountCapacity.admin
else
- Models::AccountCapacity.default
+ AccountCapacity.default
end
end
@@ -74,10 +74,10 @@
hash = Yajl::Parser.parse(last_response.body)
hash.should have_key("limits")
hash["limits"].should == {
- "memory" => Models::AccountCapacity::ADMIN_MEM,
- "app_uris" => Models::AccountCapacity::ADMIN_URIS,
- "services" => Models::AccountCapacity::ADMIN_SERVICES,
- "apps" => Models::AccountCapacity::ADMIN_APPS
+ "memory" => AccountCapacity::ADMIN_MEM,
+ "app_uris" => AccountCapacity::ADMIN_URIS,
+ "services" => AccountCapacity::ADMIN_SERVICES,
+ "apps" => AccountCapacity::ADMIN_APPS
}
end
end
@@ -91,10 +91,10 @@
hash = Yajl::Parser.parse(last_response.body)
hash.should have_key("limits")
hash["limits"].should == {
- "memory" => Models::AccountCapacity::DEFAULT_MEM,
- "app_uris" => Models::AccountCapacity::DEFAULT_URIS,
- "services" => Models::AccountCapacity::DEFAULT_SERVICES,
- "apps" => Models::AccountCapacity::DEFAULT_APPS
+ "memory" => AccountCapacity::DEFAULT_MEM,
+ "app_uris" => AccountCapacity::DEFAULT_URIS,
+ "services" => AccountCapacity::DEFAULT_SERVICES,
+ "apps" => AccountCapacity::DEFAULT_APPS
}
end

0 comments on commit 23cdaff

Please sign in to comment.