generated from lisa1976/google-deployment-manager-couchbase
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cluster.py
52 lines (47 loc) · 1.88 KB
/
cluster.py
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
def GenerateConfig(context):
config={}
config['resources'] = []
runtimeconfigName = context.env['deployment'] + '-' + context.properties['cluster'] + '-runtimeconfig'
runtimeconfig = {
'name': runtimeconfigName,
'type': 'runtimeconfig.v1beta1.config',
'properties': {
'config': runtimeconfigName
}
}
config['resources'].append(runtimeconfig)
nodeCount = {
'name': context.env['deployment'] + '-' + context.properties['cluster'] + '-nodeCount',
'type': 'runtimeconfig.v1beta1.variable',
'properties': {
'parent': '$(ref.' + runtimeconfigName + '.name)',
'variable': 'nodeCount',
'text': str(getNodeCount(context))
}
}
config['resources'].append(nodeCount)
for group in context.properties['groups']:
groupJSON = {
'name': context.env['deployment'] + '-' + context.properties['cluster'] + '-' + group['group'],
'type': 'group.py',
'properties': {
'couchbaseUsername': context.properties['couchbaseUsername'],
'couchbasePassword': context.properties['couchbasePassword'],
'cluster': context.properties['cluster'],
'region': context.properties['region'],
'group': group['group'],
'diskSize': group['diskSize'],
'nodeCount': group['nodeCount'],
'nodeType': group['nodeType'],
'services': group['services']
}
}
config['resources'].append(groupJSON)
return config
def getNodeCount(context):
nodeCount = 0
for group in context.properties['groups']:
services = group['services']
if 'data' in services or 'query' in services or 'index' in services or 'fts' in services:
nodeCount += group['nodeCount']
return nodeCount