Permalink
Browse files

default QuotaDefinition

Change-Id: I62d01ab4ccbc754ca12bdcd263d392abed9e61f7
  • Loading branch information...
1 parent 7cb8eed commit 5bce6f64f8785d5843cd27f38a95432f747fa2fc @pbozeman pbozeman committed Dec 13, 2012
@@ -72,3 +72,5 @@ quota_definitions:
runaway:
non_basic_services_allowed: true
total_services: 500
+
+default_quota_definition: free
@@ -91,7 +91,8 @@ class VCAP::CloudController::Config < VCAP::Config
:serialization_data_server => [URI.regexp(["http", "https"])],
},
- optional(:quota_definitions) => Hash,
+ :quota_definitions => Hash,
+ :default_quota_definition => String,
}
end
@@ -123,6 +124,7 @@ def self.configure(config)
VCAP::CloudController::DeaClient.configure(config)
VCAP::CloudController::HealthManagerClient.configure
VCAP::CloudController::LegacyBulk.configure(config)
+ VCAP::CloudController::Models::QuotaDefinition.configure(config)
end
def self.config_dir
@@ -2,6 +2,7 @@
module VCAP::CloudController::Models
class QuotaDefinition < Sequel::Model
+
export_attributes :name, :non_basic_services_allowed, :total_services
import_attributes :name, :non_basic_services_allowed, :total_services
@@ -19,5 +20,13 @@ def self.populate_from_config(config)
end
end
end
+
+ def self.configure(config)
+ @default_quota_name = config[:default_quota_definition]
+ end
+
+ def self.default
+ @default ||= QuotaDefinition[:name => @default_quota_name]
+ end
end
end
@@ -22,5 +22,11 @@ module VCAP::CloudController
runaway.total_services.should == 500
end
end
+
+ describe ".default" do
+ it "should return the default quota" do
+ Models::QuotaDefinition.default.name.should == "free"
+ end
+ end
end
end

0 comments on commit 5bce6f6

Please sign in to comment.