original_docstring: Prepare act config file at remote VM.
docstring: Prepare act config file at remote VM.
docstring_tokens: Prepare act config file at remote VM .
code: def PrepActConfig(vm, index=None):
    """Prepare act config file at remote VM."""
    if index is None:
      disk_lst = vm.scratch_disks
      # Treat first few partitions as reserved.
      disk_lst = disk_lst[FLAGS.act_reserved_partitions:]
      config_file = 'actconfig.txt'
    else:
      disk_lst = [vm.scratch_disks[index]]
      config_file = 'actconfig_{0}.txt'.format(index)
    devices = ','.join([d.GetDevicePath() for d in disk_lst])
    num_disk = len(disk_lst)
    # render template:
    content = ACT_CONFIG_TEMPLATE.format(
        devices=devices,
        duration=FLAGS.act_duration,
        read_iops=_CalculateReadIops(num_disk, FLAGS.act_load),
        write_iops=_CalculateWriteIops(num_disk, FLAGS.act_load))
    logging.info('ACT config: %s', content)
    with tempfile.NamedTemporaryFile(delete=False) as tf:
      tf.write(content)
      tf.close()
      vm.PushDataFile(tf.name, config_file)
code_tokens: def PrepActConfig ( vm , index = None ) : if index is None : disk_lst = vm . scratch_disks disk_lst = disk_lst [ FLAGS . act_reserved_partitions : ] config_file = 'actconfig.txt' else : disk_lst = [ vm . scratch_disks [ index ] ] config_file = 'actconfig_{0}.txt' . format ( index ) devices = ',' . join ( [ d . GetDevicePath ( ) for d in disk_lst ] ) num_disk = len ( disk_lst ) content = ACT_CONFIG_TEMPLATE . format ( devices = devices , duration = FLAGS . act_duration , read_iops = _CalculateReadIops ( num_disk , FLAGS . act_load ) , write_iops = _CalculateWriteIops ( num_disk , FLAGS . act_load ) ) logging . info ( 'ACT config: %s' , content ) with tempfile . NamedTemporaryFile ( delete = False ) as tf : tf . write ( content ) tf . close ( ) vm . PushDataFile ( tf . name , config_file )
short_docstring: Prepare act config file at remote VM.
short_docstring_tokens: Prepare act config file at remote VM .
comment: """Prepare act config file at remote VM."""$SEP$# Treat first few partitions as reserved.$SEP$# render template: