Esempio n. 1
0
def GenerateConfig(context):
    config = {}
    config['resources'] = []
    config['outputs'] = []

    runtimeconfigName = naming.RuntimeConfigName(context)
    runtimeconfig = {
        'name': runtimeconfigName,
        'type': 'runtimeconfig.v1beta1.config',
        'properties': {
            'config': runtimeconfigName
        }
    }
    config['resources'].append(runtimeconfig)

    for cluster in context.properties['clusters']:
        clusterName = cluster['cluster']
        clusterResourceName = naming.ClusterName(context, clusterName)

        clusterJSON = {
            'name': clusterResourceName,
            'type': 'cluster.py',
            'properties': {
                'runtimeconfigName':
                runtimeconfigName,
                'syncGatewayVersion':
                context.properties['syncGatewayVersion'],
                'couchbaseUsername':
                context.properties['couchbaseUsername'],
                'couchbasePassword':
                context.properties['couchbasePassword'],
                'couchbaseConnectionstring':
                context.properties['couchbaseConnectionstring'],
                'couchbaseBucketName':
                context.properties['couchbaseBucketName'],
                'license':
                context.properties['license'],
                'cluster':
                cluster['cluster'],
                'region':
                cluster['region'],
                'groups':
                cluster['groups'],
            }
        }
        config['resources'].append(clusterJSON)

        for group in cluster['groups']:
            groupName = group['group']
            outputName = naming.ExternalIpOutputName(clusterName, groupName)

            readActionName = naming.ExternalIpVariableReadActionName(
                context, clusterName, groupName)

            config['outputs'].append({
                'name': outputName,
                'value': '$(ref.%s.text)' % readActionName
            })

    firewall = {
        'name': naming.FirewallName(context),
        'type': 'compute.v1.firewall',
        'properties': {
            'sourceRanges': ['0.0.0.0/0'],
            'allowed': [{
                'IPProtocol':
                'tcp',
                'ports': [
                    '8091', '8092', '8093', '8094', '8095', '8096', '18091',
                    '18092', '18093', '18094', '18095', '18096', '4984',
                    '4985', '11210', '9130'
                ]
            }]
        }
    }
    config['resources'].append(firewall)

    return config
Esempio n. 2
0
def GenerateConfig(context):
    config = {}
    config['resources'] = []
    config['outputs'] = []

    runtimeconfigName = naming.RuntimeConfigName(context)
    runtimeconfig = {
        'name': runtimeconfigName,
        'type': 'runtimeconfig.v1beta1.config',
        'properties': {
            'config': runtimeconfigName
        }
    }
    config['resources'].append(runtimeconfig)
    config['resources'].append(
        GenerateCouchbaseUserPasswordVariable(
            context, runtimeconfigName,
            context.properties['couchbasePassword']))
    config['resources'].append(
        GenerateCouchbaseUserUsernameVariable(
            context, runtimeconfigName,
            context.properties['couchbaseUsername']))
    for cluster in context.properties['clusters']:
        clusterName = cluster['cluster']
        clusterResourceName = naming.ClusterName(context, clusterName)

        clusterJSON = {
            'name': clusterResourceName,
            'type': 'cluster.py',
            'properties': {
                'runtimeconfigName': runtimeconfigName,
                'serverVersion': context.properties['serverVersion'],
                'syncGatewayVersion': context.properties['syncGatewayVersion'],
                'couchbaseUsername': context.properties['couchbaseUsername'],
                'couchbasePassword': context.properties['couchbasePassword'],
                'license': context.properties['license'],
                'cluster': cluster['cluster'],
                'region': cluster['region'],
                'groups': cluster['groups'],
            }
        }
        config['resources'].append(clusterJSON)

        for group in cluster['groups']:
            groupName = group['group']
            outputName = naming.ExternalIpOutputName(context, clusterName,
                                                     groupName)

            createActionName = naming.ExternalIpVariableCreateActionName(
                context, clusterName, groupName)

            config['outputs'].append({
                'name':
                outputName,
                'value':
                '$(ref.%s.text)' % createActionName
            })

    firewall = {
        'name': naming.FirewallName(context),
        'type': 'compute.v1.firewall',
        'properties': {
            'sourceRanges': ['0.0.0.0/0'],
            'allowed': [{
                'IPProtocol':
                'tcp',
                'ports': [
                    '4369', '8091-8096', '9100-9105', '9110-9118', '9120-9122',
                    '9130', '9140', '9999', '11207', '11209-11211', '11207',
                    '21100', '11206-11207', '18091-18096', '19130', '21150'
                ]
            }]
        }
    }
    config['resources'].append(firewall)

    return config