(context, disk_list, new_disks)
return sourced_disks, new_disks
Generates as many disks as passed in the disk_list.
Generates as many disks as passed in the disk_list.
Generates as many disks as passed in the disk_list .
def GenerateDisks(context, disk_list, new_disks):
  """Generates as many disks as passed in the disk_list."""
  prop = context.properties
  zone = prop.setdefault(ZONE, DEFAULT_ZONE)
  sourced_disks = []
  disk_names = []
  for disk in disk_list:
    if default.DISK_SOURCE in disk or disk[default.TYPE] == SCRATCH:
      # These disks do not need to be created as separate resources
      sourced_disks.append(disk)
    else:
      # Extract disk parameters and create as separate resource
      disk_init = disk[default.INITIALIZEP]
      if default.DEVICE_NAME in disk:
        d_name = disk[default.DEVICE_NAME]
      elif default.DISK_NAME in disk_init:
        d_name = disk_init[default.DISK_NAME]
      else:
        raise common.Error('deviceName or diskName is needed for each disk in '
                           'this module implemention of multiple disks per vm.')
      new_disks.append({
          'name': d_name,
          'type': default.DISK,
          'properties': {
              'type': disk_init[default.DISKTYPE],
              'sizeGb': disk_init[default.DISK_SIZE],
              'zone': zone
          }
      })
      disk_names.append(d_name)
      source = common.Ref(d_name)
      sourced_disks.append({
          'deviceName': d_name,
          'autoDelete': disk[default.AUTO_DELETE],
          'boot': False,
          'source': source,
          'type': disk[default.TYPE],
      })
  items = prop[METADATA].setdefault('items', list())
  items.append({'key': ATTACHED_DISKS, 'value': ','.join(disk_names)})
  return sourced_disks, new_disks
def GenerateDisks ( context , disk_list , new_disks ) : prop = context . properties zone = prop . setdefault ( ZONE , DEFAULT_ZONE ) sourced_disks = [ ] disk_names = [ ] for disk in disk_list : if default . DISK_SOURCE in disk or disk [ default . TYPE ] == SCRATCH : # These disks do not need to be created as separate resources sourced_disks . append ( disk ) else : # Extract disk parameters and create as separate resource disk_init = disk [ default . INITIALIZEP ] if default . DEVICE_NAME in disk : d_name = disk [ default . DEVICE_NAME ] elif default . DISK_NAME in disk_init : d_name = disk_init [ default . DISK_NAME ] else : raise common . Error ( 'deviceName or diskName is needed for each disk in ' 'this module implemention of multiple disks per vm.' ) new_disks . append ( { 'name' : d_name , 'type' : default . DISK , 'properties' : { 'type' : disk_init [ default . DISKTYPE ] , 'sizeGb' : disk_init [ default . DISK_SIZE ] , 'zone' : zone } } ) disk_names . append ( d_name ) source = common . Ref ( d_name ) sourced_disks . append ( { 'deviceName' : d_name , 'autoDelete' : disk [ default . AUTO_DELETE ] , 'boot' : False , 'source' : source , 'type' : disk [ default . TYPE ] , } ) items = prop [ METADATA ] . setdefault ( 'items' , list ( ) ) items . append ( { 'key' : ATTACHED_DISKS , 'value' : ',' . join ( disk_names ) } ) return sourced_disks , new_disks