(context)
return config
Generate YAML resource configuration.
Generate YAML resource configuration.
Generate YAML resource configuration .
def GenerateConfig(context):
  """Generate YAML resource configuration."""

  name = context.env['name']
  igm_name = name + '-igm'
  curr_it_name = name + '-it-' + context.properties['currVersion']['name']
  machine_type = context.properties['machineType']
  zone = context.properties['zone']

  config = {'resources': []}

  # The instance template.
  current_it = {
      'name': curr_it_name,
      'type': 'instance-template.py',
      'properties': {
          'machineType': machine_type,
          'zone': zone,
          'itName': curr_it_name,
          'image': context.properties['currVersion']['image']
      }
  }
  config['resources'].append(current_it)

  # The instance group manager.
  igm = {
      'name': igm_name,
      'type': 'compute.beta.instanceGroupManager',
      'properties': {
          'baseInstanceName': igm_name + '-instance',
          'instanceTemplate': '$(ref.' + curr_it_name + '.selfLink)',
          'zone': zone,
          'targetSize': 1,
          'targetPools': [
              '$(ref.' + context.properties['targetPool'] + '.selfLink)',
          ],
          'updatePolicy': {
              'minimalAction': 'REPLACE',
              'type': 'PROACTIVE',
          }
      }
  }
  config['resources'].append(igm)

  # The autoscaler.
  autoscaler = {
      'name': name + '-as',
      'type': 'compute.v1.autoscaler',
      'properties': {
          'autoscalingPolicy': {
              'minNumReplicas': context.properties['minSize'],
              'maxNumReplicas': context.properties['maxSize']
          },
          'target': '$(ref.' + igm_name + '.selfLink)',
          'zone': zone
      }
  }
  config['resources'].append(autoscaler)

  return config
def GenerateConfig ( context ) : name = context . env [ 'name' ] igm_name = name + '-igm' curr_it_name = name + '-it-' + context . properties [ 'currVersion' ] [ 'name' ] machine_type = context . properties [ 'machineType' ] zone = context . properties [ 'zone' ] config = { 'resources' : [ ] } # The instance template. current_it = { 'name' : curr_it_name , 'type' : 'instance-template.py' , 'properties' : { 'machineType' : machine_type , 'zone' : zone , 'itName' : curr_it_name , 'image' : context . properties [ 'currVersion' ] [ 'image' ] } } config [ 'resources' ] . append ( current_it ) # The instance group manager. igm = { 'name' : igm_name , 'type' : 'compute.beta.instanceGroupManager' , 'properties' : { 'baseInstanceName' : igm_name + '-instance' , 'instanceTemplate' : '$(ref.' + curr_it_name + '.selfLink)' , 'zone' : zone , 'targetSize' : 1 , 'targetPools' : [ '$(ref.' + context . properties [ 'targetPool' ] + '.selfLink)' , ] , 'updatePolicy' : { 'minimalAction' : 'REPLACE' , 'type' : 'PROACTIVE' , } } } config [ 'resources' ] . append ( igm ) # The autoscaler. autoscaler = { 'name' : name + '-as' , 'type' : 'compute.v1.autoscaler' , 'properties' : { 'autoscalingPolicy' : { 'minNumReplicas' : context . properties [ 'minSize' ] , 'maxNumReplicas' : context . properties [ 'maxSize' ] } , 'target' : '$(ref.' + igm_name + '.selfLink)' , 'zone' : zone } } config [ 'resources' ] . append ( autoscaler ) return config