forked from cloudfoundry/cloud_controller_ng
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.rb
183 lines (148 loc) · 5.76 KB
/
config.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
require "vcap/config"
require "cloud_controller/account_capacity"
require "uri"
# Config template for cloud controller
class VCAP::CloudController::Config < VCAP::Config
DEFAULT_CONFIG_PATH = File.expand_path("../../../../config/dev.yml", __FILE__)
define_schema do
{
:port => Integer,
:info => {
:name => String,
:build => String,
:version => Fixnum,
:support_address => String,
:description => String,
},
:system_domain => String,
:system_domain_organization => enum(String, NilClass),
:app_domains => [ String ],
optional(:allow_debug) => bool,
optional(:login) => {
:url => String
},
:uaa => {
:url => String,
:resource_id => String,
optional(:symmetric_secret) => String
},
:logging => {
:level => String, # debug, info, etc.
optional(:file) => String, # Log file to use
optional(:syslog) => String, # Name to associate with syslog messages (should start with 'vcap.')
},
:nats_uri => String, # NATS uri of the form nats://<user>:<pass>@<host>:<port>
:pid_filename => String, # Pid filename to use
optional(:directories) => {
optional(:tmpdir) => String,
optional(:droplets) => String,
optional(:staging_manifests) => String,
},
optional(:stacks_file) => String,
:db => {
:database => String, # db connection string for sequel
optional(:log_level) => String, # debug, info, etc.
optional(:max_connections) => Integer, # max connections in the connection pool
optional(:pool_timeout) => Integer # timeout before raising an error when connection can't be established to the db
},
:bulk_api => {
:auth_user => String,
:auth_password => String,
},
:cc_partition => String,
# TODO: use new defaults to set these defaults
optional(:default_account_capacity) => {
:memory => Fixnum, #:default => 2048,
:app_uris => Fixnum, #:default => 4,
:services => Fixnum, #:default => 16,
:apps => Fixnum, #:default => 20
},
# TODO: use new defaults to set these defaults
optional(:admin_account_capacity) => {
:memory => Fixnum, #:default => 2048,
:app_uris => Fixnum, #:default => 4,
:services => Fixnum, #:default => 16,
:apps => Fixnum, #:default => 20
},
optional(:index) => Integer, # Component index (cc-0, cc-1, etc)
optional(:local_route) => String, # If set, use this to determine the IP address that is returned in discovery messages
:nginx => {
:use_nginx => bool,
:instance_socket => String,
},
:quota_definitions => Hash,
:default_quota_definition => String,
:resource_pool => {
optional(:maximum_size) => Integer,
optional(:minimum_size) => Integer,
optional(:resource_directory_key) => String,
:fog_connection => {
:provider => String,
optional(:aws_access_key_id) => String,
optional(:aws_secret_access_key) => String,
optional(:local_root) => String
}
},
:packages => {
optional(:max_droplet_size) => Integer,
optional(:app_package_directory_key) => String,
:fog_connection => {
:provider => String,
optional(:aws_access_key_id) => String,
optional(:aws_secret_access_key) => String,
optional(:local_root) => String
}
},
:droplets => {
optional(:max_droplet_size) => Integer,
optional(:droplet_directory_key) => String,
:fog_connection => {
:provider => String,
optional(:aws_access_key_id) => String,
optional(:aws_secret_access_key) => String,
optional(:local_root) => String
}
},
:db_encryption_key => String,
optional(:trial_db) => {
:guid => String,
},
}
end
def self.from_file(file_name)
config = super(file_name)
merge_defaults(config)
end
def self.configure(config)
mbus = VCAP::CloudController::MessageBus.new(config)
VCAP::CloudController::MessageBus.instance = mbus
VCAP::CloudController::Config.db_encryption_key = config[:db_encryption_key]
VCAP::CloudController::AccountCapacity.configure(config)
VCAP::CloudController::ResourcePool.instance =
VCAP::CloudController::ResourcePool.new(config)
VCAP::CloudController::AppPackage.configure(config)
stager_pool = VCAP::CloudController::StagerPool.new(config, mbus)
VCAP::CloudController::AppStager.configure(config, mbus, stager_pool)
VCAP::CloudController::Staging.configure(config)
dea_pool = VCAP::CloudController::DeaPool.new(config, mbus)
VCAP::CloudController::DeaClient.configure(config, mbus, dea_pool)
VCAP::CloudController::LegacyBulk.configure(config, mbus)
VCAP::CloudController::HealthManagerClient.configure(mbus)
VCAP::CloudController::Models::QuotaDefinition.configure(config)
VCAP::CloudController::Models::Stack.configure(config[:stacks_file])
VCAP::CloudController::Models::ServicePlan.configure(config[:trial_db])
end
class << self
attr_accessor :db_encryption_key
def config_dir
@config_dir ||= File.expand_path("../../../config", __FILE__)
end
private
def merge_defaults(config)
config[:stacks_file] ||= File.join(config_dir, "stacks.yml")
config[:directories] ||= {}
config[:directories][:staging_manifests] ||= File.join(config_dir, "frameworks")
config
end
end
end