This repository has been archived by the owner on Jul 12, 2018. It is now read-only.
/
mysql_proxy.go
71 lines (66 loc) · 1.75 KB
/
mysql_proxy.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
package cloudfoundry
import (
"github.com/enaml-ops/enaml"
"github.com/enaml-ops/omg-product-bundle/products/oss_cf/enaml-gen/proxy"
"github.com/enaml-ops/omg-product-bundle/products/oss_cf/plugin/config"
)
//MySQLProxy -
type MySQLProxy struct {
Config *config.Config
}
//NewMySQLProxyPartition -
func NewMySQLProxyPartition(config *config.Config) InstanceGroupCreator {
return &MySQLProxy{
Config: config,
}
}
//ToInstanceGroup -
func (s *MySQLProxy) ToInstanceGroup() (ig *enaml.InstanceGroup) {
ig = &enaml.InstanceGroup{
Name: "mysql_proxy-partition",
Instances: len(s.Config.MySQLProxyIPs),
VMType: s.Config.MySQLProxyVMType,
AZs: s.Config.AZs,
Stemcell: s.Config.StemcellName,
Jobs: []enaml.InstanceJob{
s.newMySQLProxyJob(),
},
Networks: []enaml.Network{
enaml.Network{Name: s.Config.NetworkName, StaticIPs: s.Config.MySQLProxyIPs},
},
Update: enaml.Update{
MaxInFlight: 1,
},
}
return
}
func (s *MySQLProxy) newMySQLProxyJob() enaml.InstanceJob {
return enaml.InstanceJob{
Name: "proxy",
Release: "cf-mysql",
Properties: &proxy.ProxyJob{
CfMysql: &proxy.CfMysql{
ExternalHost: s.Config.MySQLProxyExternalHost,
Proxy: &proxy.Proxy{
ApiUsername: s.Config.MySQLProxyAPIUsername,
ApiPassword: s.Config.MySQLProxyAPIPassword,
ProxyIps: s.Config.MySQLProxyIPs,
},
Mysql: &proxy.Mysql{
ClusterIps: s.Config.MySQLIPs,
},
},
SyslogAggregator: &proxy.SyslogAggregator{
Address: s.Config.SyslogAddress,
Port: s.Config.SyslogPort,
Transport: s.Config.SyslogTransport,
},
Nats: &proxy.Nats{
User: s.Config.NATSUser,
Password: s.Config.NATSPassword,
Machines: s.Config.NATSMachines,
Port: s.Config.NATSPort,
},
},
}
}