Пример #1
0
def GenerateConfig(context):
    """Generate template config based on python objects."""
    compute_resource_util.SetContext(context)
    health_check = ComputeResource('hc', compute_constants.HEALTHCHECKS, {
        'type': 'TCP',
        'tcpHealthCheck': {
            'portName': 'hc-port',
            'port': 80
        }
    })
    backend_service = ComputeResource(
        'bs', compute_constants.BACKENDSERVICES, {
            'healthChecks': [health_check.SelfLink()],
            'protocol': 'TCP'
        })

    # Please don't normally do this, we have generated these keys/certs purely for
    # testing and they are not used anywhere else in the universe.
    ssl_certificate = ComputeResource(
        'crt', compute_constants.SSLCERTIFICATES, {
            'certificate':
            context.imports[context.properties['certificateFile']],
            'privateKey': context.imports[context.properties['privateKeyFile']]
        })
    ComputeResource(
        'tsp', compute_constants.TARGETSSLPROXIES, {
            'service': backend_service.SelfLink(),
            'sslCertificates': [ssl_certificate.SelfLink()]
        })

    return Resources()
Пример #2
0
def GenerateConfig(context):
    """Generate template config based on python objects."""
    compute_resource_util.SetContext(context)
    properties = context.properties
    assert ('region' in properties) ^ ('zone' in properties), (
        'Need to specify exactly only one from zone or region')
    if 'region' in properties:
        ComputeResource('ig', compute_constants.REGIONINSTANCEGROUPS,
                        {'region': properties['region']})
    else:
        ComputeResource('ig', compute_constants.INSTANCEGROUPS,
                        {'zone': properties['zone']})
    return Resources()
Пример #3
0
def GenerateConfig(context):
  """Generate template config based on python objects."""
  properties = context.properties
  region = properties['region']
  compute_resource_util.SetContext(context)

  network = ComputeResource('network', compute_constants.NETWORKS, {
      'autoCreateSubnetworks': False
  })
  ComputeResource('subnet', compute_constants.SUBNETWORKS, {
      'network': network.SelfLink(),
      'region': region,
      'ipCidrRange': properties['ipCidrRange']
  })

  return Resources()
Пример #4
0
def GenerateConfig(context):
    """Generate template config based on python objects."""
    properties = context.properties
    compute_resource_util.SetContext(context)

    ComputeResource(
        'hc', compute_constants.HEALTHCHECKS, {
            'type': 'TCP',
            'tcpHealthCheck': {
                'portName': 'hc-port',
                'port': properties['port']
            }
        })

    return Resources()
Пример #5
0
def GenerateConfig(context):
    """Generate template config based on python objects."""
    compute_resource_util.SetContext(context)
    health_check = ComputeResource('hc', compute_constants.HEALTHCHECKS, {
        'type': 'TCP',
        'tcpHealthCheck': {
            'portName': 'hc-port',
            'port': 80
        }
    })
    backend_service = ComputeResource(
        'bs', compute_constants.BACKENDSERVICES, {
            'healthChecks': [health_check.SelfLink()],
            'protocol': 'TCP'
        })
    ComputeResource('tcp', compute_constants.TARGETTCPPROXIES,
                    {'service': backend_service.SelfLink()})

    return Resources()
Пример #6
0
def GenerateConfig(context):
  """Generate template config based on python objects."""
  properties = context.properties
  region = properties['region']
  compute_resource_util.SetContext(context)

  network = ComputeResource('network', compute_constants.NETWORKS, {
    'autoCreateSubnetworks': True
  })
  vpn_gateway = ComputeResource('vpg', compute_constants.TARGETVPNGATEWAYS, {
      'network': network.SelfLink(),
      'region': region
  })
  ip = ComputeResource('static-ip', compute_constants.ADDRESSES,
                       {'region': region})
  esp_rule = ComputeResource(
      'esp-rule', compute_constants.FORWARDINGRULES, {
          'IPProtocol': 'ESP',
          'IPAddress': ip.Ref('address'),
          'region': region,
          'target': vpn_gateway.SelfLink()
      })
  udp4500_rule = ComputeResource(
      'udp-4500-rule', compute_constants.FORWARDINGRULES, {
          'IPProtocol': 'UDP',
          'IPAddress': ip.Ref('address'),
          'region': region,
          'target': vpn_gateway.SelfLink(),
          'portRange': 4500
      })
  udp500_rule = ComputeResource(
      'udp-500-rule', compute_constants.FORWARDINGRULES, {
          'IPProtocol': 'UDP',
          'IPAddress': ip.Ref('address'),
          'region': region,
          'target': vpn_gateway.SelfLink(),
          'portRange': 500
      })
  cloud_router = ComputeResource('cloud-router', compute_constants.ROUTERS, {
      'region': region,
      'network': network.SelfLink(),
      'asn': properties['asn']
  })
  ComputeResource(
      'vpn-tunnel', compute_constants.VPNTUNNELS, {
          'region':
              region,
          'ikeVersion':
              2,
          'sharedSecret':
              properties['sharedSecret'],
          'peerIp':
              properties['peerAddress'],
          'router':
              cloud_router.SelfLink(),
          'targetVpnGateway':
              vpn_gateway.SelfLink(),
          'description':
              'Must be deployed after ' + esp_rule.SelfLink() + ' ' +
              udp500_rule.SelfLink() + ' ' + udp4500_rule.SelfLink()
      })

  return Resources()
Пример #7
0
def GenerateConfig(context):
  """Generate template config based on python objects."""
  compute_resource_util.SetContext(context)
  properties = context.properties
  disk_name = context.env['deployment'] + '-' + 'disk'
  image = 'projects/debian-cloud/global/images/debian-7-wheezy-v20140619'
  default_network = 'global/networks/default'
  assert ('region' in properties) ^ ('zone' in properties), (
      'Need to specify exactly only one from zone or region')
  template = ComputeResource(
      'template', compute_constants.INSTANCETEMPLATES, {
          'properties': {
              'machineType':
                  'f1-micro',
              'disks': [{
                  'deviceName': 'boot',
                  'boot': True,
                  'autoDelete': True,
                  'mode': 'READ_WRITE',
                  'initializeParams': {
                      'diskName': disk_name,
                      'sourceImage': image
                  },
                  'type': 'PERSISTENT'
              }],
              'networkInterfaces': [{
                  'network': default_network
              }]
          }
      })
  if 'region' in properties:
    igm = ComputeResource(
        'igm', compute_constants.REGIONINSTANCEGROUPMANAGERS, {
            'region': properties['region'],
            'size': properties['size'],
            'baseInstanceName': context.env['deployment'] + '-instance',
            'instanceTemplate': template.SelfLink(),
            'targetSize': 1
        })
    ComputeResource(
        'autoscaler', compute_constants.REGIONAUTOSCALERS, {
            'region':
                properties['region'],
            'autoscalingPolicy': {
                'coolDownPeriodSec': 60,
                'cpuUtilization': {
                    'utilizationTarget': 0.8
                },
                'maxNumReplicas': 3,
                'minNumReplicas': 1
            },
            'description':
                'Autoscaler created for cloud config testing purposes',
            'target':
                igm.SelfLink()
        })
  else:
    igm = ComputeResource(
        'igm', compute_constants.INSTANCEGROUPMANAGERS, {
            'zone': properties['zone'],
            'size': properties['size'],
            'baseInstanceName': context.env['deployment'] + '-instance',
            'instanceTemplate': template.SelfLink(),
            'targetSize': 1
        })
    ComputeResource(
        'autoscaler', compute_constants.AUTOSCALERS, {
            'zone':
                properties['zone'],
            'autoscalingPolicy': {
                'coolDownPeriodSec': 60,
                'cpuUtilization': {
                    'utilizationTarget': 0.8
                },
                'maxNumReplicas': 3,
                'minNumReplicas': 1
            },
            'description':
                'Autoscaler created for cloud config testing purposes',
            'target':
                igm.SelfLink()
        })
  return Resources()
def GenerateConfig(context):
  """Generate template config based on python objects."""
  compute_resource_util.SetContext(context)

  health_check = ComputeResource('hc', compute_constants.HTTPSHEALTHCHECKS, {
      'type': 'tcp',
      'tcpHealthCheck': {
          'host': 'localhost',
          'requestPath': '/path/to/my/service',
          'description': 'Integration test http health check',
          'portName': 'hc-port',
          'port': 8080,
          'checkIntervalSec': 3,
          'unhealthyThreshold': 5,
          'healthyThreshold': 2
      }
  })
  bs1 = ComputeResource('bs1', compute_constants.BACKENDSERVICES, {
      'healthChecks': [health_check.SelfLink()],
      'port': 80,
      'portName': 'http',
      'protocol': 'HTTPS',
      'timeoutSec': 30
  })
  bs2 = ComputeResource('bs2', compute_constants.BACKENDSERVICES, {
      'healthChecks': [health_check.SelfLink()],
      'port': 80,
      'portName': 'http',
      'protocol': 'HTTPS',
      'timeoutSec': 30
  })
  url_map = ComputeResource('url-map', compute_constants.URLMAPS, {
      'pathMatchers': [{
          'defaultService': bs1.SelfLink(),
          'description': 'URL Map Description',
          'name': 'url-set-' + context.env['deployment']
      }],
      'defaultService': bs2.SelfLink(),
      'hostRules': [{
          'description': 'test host rule',
          'hosts': ['*'],
          'pathMatcher': 'url-set-' + context.env['deployment']
      }]

  })
  # Please don't normally do this, we have generated these keys/certs purely for
  # testing and they are not used anywhere else in the universe.
  ssl_certificate = ComputeResource('crt', compute_constants.SSLCERTIFICATES, {
      'certificate': context.imports[context.properties['certificateFile']],
      'privateKey': context.imports[context.properties['privateKeyFile']]
  })
  ComputeResource('thttps', compute_constants.TARGETHTTPSPROXIES, {
      'urlMap': url_map.SelfLink(),
      'sslCertificates': [ssl_certificate.SelfLink()]
  })
  return Resources()