(context, index)
return instance
Helper method to create the config for a single compute instance.
Helper method to create the config for a single compute instance.
Helper method to create the config for a single compute instance .
def GenerateInstanceConfig(context, index):
  """Helper method to create the config for a single compute instance."""
  name_prefix = ''.join([context.properties['namePrefix'], '-',
                         context.env['deployment'], '-', str(index)])
  machine_type = ''.join(['https://www.googleapis.com/compute/v1/projects/',
                          context.env['project'], '/zones/',
                          context.properties['zone'], '/machineTypes/',
                          context.properties['machineType']])
  boot_disk_config = GetBootDiskConfig(name_prefix + '-disk',
                                       context.properties['image'])
  network_config_url = ''.join(
      ['https://www.googleapis.com/compute/v1/projects/',
       context.env['project'], '/global/networks/default'])
  network_config = GetNetworkConfig(context.properties['hasExternalIp'],
                                    network_config_url)

  instance = {
      'type': 'compute.v1.instance',
      'name': name_prefix,
      'properties': {
          'zone': context.properties['zone'],
          'machineType': machine_type,
          'disks': [boot_disk_config],
          'networkInterfaces': [network_config]
      }
  }
  return instance
def GenerateInstanceConfig ( context , index ) : name_prefix = '' . join ( [ context . properties [ 'namePrefix' ] , '-' , context . env [ 'deployment' ] , '-' , str ( index ) ] ) machine_type = '' . join ( [ 'https://www.googleapis.com/compute/v1/projects/' , context . env [ 'project' ] , '/zones/' , context . properties [ 'zone' ] , '/machineTypes/' , context . properties [ 'machineType' ] ] ) boot_disk_config = GetBootDiskConfig ( name_prefix + '-disk' , context . properties [ 'image' ] ) network_config_url = '' . join ( [ 'https://www.googleapis.com/compute/v1/projects/' , context . env [ 'project' ] , '/global/networks/default' ] ) network_config = GetNetworkConfig ( context . properties [ 'hasExternalIp' ] , network_config_url ) instance = { 'type' : 'compute.v1.instance' , 'name' : name_prefix , 'properties' : { 'zone' : context . properties [ 'zone' ] , 'machineType' : machine_type , 'disks' : [ boot_disk_config ] , 'networkInterfaces' : [ network_config ] } } return instance