This repository has been archived by the owner on Jul 12, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
cloud_controller_worker.go
157 lines (151 loc) · 4.75 KB
/
cloud_controller_worker.go
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
package cloudfoundry
import (
"github.com/enaml-ops/enaml"
ccworkerlib "github.com/enaml-ops/omg-product-bundle/products/oss_cf/enaml-gen/cloud_controller_worker"
"github.com/enaml-ops/omg-product-bundle/products/oss_cf/plugin/config"
)
//CloudControllerWorkerPartition - Cloud Controller Worker Partition
type CloudControllerWorkerPartition struct {
Config *config.Config
Metron *Metron
ConsulAgent *ConsulAgent
}
//NewCloudControllerWorkerPartition - Creating a New Cloud Controller Partition
func NewCloudControllerWorkerPartition(config *config.Config) InstanceGroupCreator {
return &CloudControllerWorkerPartition{
Config: config,
Metron: NewMetron(config),
ConsulAgent: NewConsulAgent([]string{}, config),
}
}
//ToInstanceGroup - Convert CLoud Controller Partition to an Instance Group
func (s *CloudControllerWorkerPartition) ToInstanceGroup() (ig *enaml.InstanceGroup) {
ig = &enaml.InstanceGroup{
Name: "cloud_controller_worker-partition",
AZs: s.Config.AZs,
Instances: s.Config.CloudControllerWorkerInstances,
VMType: s.Config.CloudControllerWorkerVMType,
Stemcell: s.Config.StemcellName,
Networks: []enaml.Network{
enaml.Network{Name: s.Config.NetworkName},
},
Jobs: []enaml.InstanceJob{
newCloudControllerWorkerJob(s),
s.ConsulAgent.CreateJob(),
CreateNFSMounterJob(s.Config),
s.Metron.CreateJob(),
},
Update: enaml.Update{
MaxInFlight: 1,
Serial: true,
},
}
return
}
func newCloudControllerWorkerJob(c *CloudControllerWorkerPartition) enaml.InstanceJob {
return enaml.InstanceJob{
Name: "cloud_controller_worker",
Release: CFReleaseName,
Properties: &ccworkerlib.CloudControllerWorkerJob{
Domain: c.Config.SystemDomain,
SystemDomain: c.Config.SystemDomain,
AppDomains: c.Config.AppDomains,
SystemDomainOrganization: "system",
Ssl: &ccworkerlib.Ssl{
SkipCertVerify: c.Config.SkipSSLCertVerify,
},
Cc: &ccworkerlib.Cc{
AllowAppSshAccess: c.Config.AllowSSHAccess,
Buildpacks: &ccworkerlib.Buildpacks{
BlobstoreType: "fog",
FogConnection: map[string]string{
"provider": "Local",
"local_root": "/var/vcap/nfs/shared",
},
},
Droplets: &ccworkerlib.Droplets{
BlobstoreType: "fog",
FogConnection: map[string]string{
"provider": "Local",
"local_root": "/var/vcap/nfs/shared",
},
},
Packages: &ccworkerlib.Packages{
BlobstoreType: "fog",
FogConnection: map[string]string{
"provider": "Local",
"local_root": "/var/vcap/nfs/shared",
},
},
ResourcePool: &ccworkerlib.ResourcePool{
BlobstoreType: "fog",
FogConnection: map[string]string{
"provider": "Local",
"local_root": "/var/vcap/nfs/shared",
},
},
QuotaDefinitions: map[string]interface{}{
"default": map[string]interface{}{
"memory_limit": 10240,
"total_services": 100,
"non_basic_services_allowed": true,
"total_routes": 1000,
"trial_db_allowed": true,
},
"runaway": map[string]interface{}{
"memory_limit": 102400,
"total_services": -1,
"non_basic_services_allowed": true,
"total_routes": 1000,
},
},
SecurityGroupDefinitions: []map[string]interface{}{
map[string]interface{}{
"name": "all_open",
"rules": []map[string]interface{}{
map[string]interface{}{
"protocol": "all",
"destination": "0.0.0.0-255.255.255.255",
},
},
},
},
DefaultRunningSecurityGroups: []string{"all_open"},
DefaultStagingSecurityGroups: []string{"all_open"},
LoggingLevel: "debug",
MaximumHealthCheckTimeout: "600",
StagingUploadUser: c.Config.StagingUploadUser,
StagingUploadPassword: c.Config.StagingUploadPassword,
BulkApiPassword: c.Config.CCBulkAPIPassword,
InternalApiUser: c.Config.CCInternalAPIUser,
InternalApiPassword: c.Config.CCInternalAPIPassword,
DbEncryptionKey: c.Config.DbEncryptionKey,
},
Ccdb: &ccworkerlib.Ccdb{
Address: c.Config.MySQLProxyHost(),
Databases: []map[string]interface{}{
map[string]interface{}{
"citext": true,
"name": "ccdb",
"tag": "cc",
},
},
DbScheme: "mysql",
Port: 3306,
Roles: []map[string]interface{}{
{
"name": c.Config.CCDBUsername,
"password": c.Config.CCDBPassword,
"tag": "admin",
},
},
},
Nats: &ccworkerlib.Nats{
User: c.Config.NATSUser,
Port: c.Config.NATSPort,
Password: c.Config.NATSPassword,
Machines: c.Config.NATSMachines,
},
},
}
}