Skip to content

Commit

Permalink
default QuotaDefinition
Browse files Browse the repository at this point in the history
Change-Id: I62d01ab4ccbc754ca12bdcd263d392abed9e61f7
  • Loading branch information
pbozeman committed Dec 14, 2012
1 parent 7cb8eed commit 5bce6f6
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config/cloud_controller.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,5 @@ quota_definitions:
runaway:
non_basic_services_allowed: true
total_services: 500

default_quota_definition: free
4 changes: 3 additions & 1 deletion lib/cloud_controller/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions lib/cloud_controller/models/quota_definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
6 changes: 6 additions & 0 deletions spec/models/quota_definition_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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.