(context, disks, add_blank_src_img=False)
Set properties on each disk to required format.

  Sets default values, and moves properties passed directly into
  initializeParams where required.

  Args:
    context: Template context dictionary.
    disks: List of disks to set properties on.
    add_blank_src_img: When true, link to blank source image is added for new
    disks where a source image is not specified.
Set properties on each disk to required format.
Set properties on each disk to required format .
def SetDiskProperties(context, disks, add_blank_src_img=False):
  """Set properties on each disk to required format.

  Sets default values, and moves properties passed directly into
  initializeParams where required.

  Args:
    context: Template context dictionary.
    disks: List of disks to set properties on.
    add_blank_src_img: When true, link to blank source image is added for new
    disks where a source image is not specified.
  """

  project = context.env[default.PROJECT]
  zone = context.properties.setdefault(ZONE, DEFAULT_ZONE)

  for disk in disks:
    disk.setdefault(default.AUTO_DELETE, True)
    disk.setdefault('boot', False)
    disk.setdefault(default.TYPE, DEFAULT_PERSISTENT)

    # If disk already exists, no properties to change.
    if default.DISK_SOURCE in disk:
      continue

    else:
      disk_init = disk.setdefault(default.INITIALIZEP, dict())
      if disk[default.TYPE] == SCRATCH:
        disk_init.setdefault(DISKTYPE, 'local-ssd')
      else:
        # In the Instance API reference, size and type are within this property
        if disk_init:
          disk_init.setdefault(default.DISK_SIZE, DEFAULT_DATADISKSIZE)
          disk_init.setdefault(default.DISKTYPE, DEFAULT_DISKTYPE)
        # You can also simply pass the size and type properties directly
        else:
          disk_init[default.DISK_SIZE] = disk.pop(default.DISK_SIZE,
                                                  DEFAULT_DATADISKSIZE)
          disk_init[default.DISKTYPE] = disk.pop(default.DISKTYPE,
                                                 DEFAULT_DISKTYPE)

        # If disk name was given as a direct property, move to initializeParams
        if default.DISK_NAME in disk:
          disk_init[default.DISK_NAME] = disk.pop(default.DISK_NAME)

        # Add link to a blank source image where non-specified
        if add_blank_src_img and default.SRCIMAGE not in disk_init:
          disk_init[default.SRCIMAGE] = common.MakeC2DImageLink(BLANK_IMAGE)

      # Change disk type names into URLs
      disk_init[default.DISKTYPE] = common.LocalComputeLink(
          project, zone, 'diskTypes', disk_init[default.DISKTYPE])
def SetDiskProperties ( context , disks , add_blank_src_img = False ) : project = context . env [ default . PROJECT ] zone = context . properties . setdefault ( ZONE , DEFAULT_ZONE ) for disk in disks : disk . setdefault ( default . AUTO_DELETE , True ) disk . setdefault ( 'boot' , False ) disk . setdefault ( default . TYPE , DEFAULT_PERSISTENT ) # If disk already exists, no properties to change. if default . DISK_SOURCE in disk : continue else : disk_init = disk . setdefault ( default . INITIALIZEP , dict ( ) ) if disk [ default . TYPE ] == SCRATCH : disk_init . setdefault ( DISKTYPE , 'local-ssd' ) else : # In the Instance API reference, size and type are within this property if disk_init : disk_init . setdefault ( default . DISK_SIZE , DEFAULT_DATADISKSIZE ) disk_init . setdefault ( default . DISKTYPE , DEFAULT_DISKTYPE ) # You can also simply pass the size and type properties directly else : disk_init [ default . DISK_SIZE ] = disk . pop ( default . DISK_SIZE , DEFAULT_DATADISKSIZE ) disk_init [ default . DISKTYPE ] = disk . pop ( default . DISKTYPE , DEFAULT_DISKTYPE ) # If disk name was given as a direct property, move to initializeParams if default . DISK_NAME in disk : disk_init [ default . DISK_NAME ] = disk . pop ( default . DISK_NAME ) # Add link to a blank source image where non-specified if add_blank_src_img and default . SRCIMAGE not in disk_init : disk_init [ default . SRCIMAGE ] = common . MakeC2DImageLink ( BLANK_IMAGE ) # Change disk type names into URLs disk_init [ default . DISKTYPE ] = common . LocalComputeLink ( project , zone , 'diskTypes' , disk_init [ default . DISKTYPE ] )