def Prepare(benchmark_spec):
  """Install docker. Pull images. Create datasets. Start master and workers.

  Args:
    benchmark_spec: The benchmark specification. Contains all data that is
        required to run the benchmark.
  """
  master = benchmark_spec.vm_groups['master'][0]
  workers = benchmark_spec.vm_groups['workers']

  def PrepareCommon(vm):
    if not docker.IsInstalled(vm):
      vm.Install('docker')
    vm.RemoteCommand('sudo docker pull cloudsuite/spark')
    vm.RemoteCommand('sudo docker pull cloudsuite/movielens-dataset')
    vm.RemoteCommand('sudo docker create --name data '
                     'cloudsuite/movielens-dataset')

  def PrepareMaster(vm):
    PrepareCommon(vm)
    vm.RemoteCommand('sudo docker pull cloudsuite/in-memory-analytics')
    start_master_cmd = ('sudo docker run -d --net host -e SPARK_MASTER_IP=%s '
                        '--name spark-master cloudsuite/spark master' %
                        master.internal_ip)
    vm.RemoteCommand(start_master_cmd)

  def PrepareWorker(vm):
    PrepareCommon(vm)
    start_worker_cmd = ('sudo docker run -d --net host --volumes-from data '
                        '--name spark-worker cloudsuite/spark worker '
                        'spark://%s:7077' % master.internal_ip)
    vm.RemoteCommand(start_worker_cmd)

  target_arg_tuples = ([(PrepareWorker, [vm], {}) for vm in workers] +
                       [(PrepareMaster, [master], {})])
  vm_util.RunParallelThreads(target_arg_tuples, len(target_arg_tuples))
dataset/ETHPy150Open GoogleCloudPlatform/PerfKitBenchmarker/perfkitbenchmarker/linux_benchmarks/cloudsuite_in_memory_analytics_benchmark.py/Prepare/original