def InstallPreprovisionedBenchmarkData(self, benchmark_name, filenames,
                                         install_path):
    """Installs preprovisioned benchmark data on this VM.

    Some benchmarks require importing many bytes of data into the virtual
    machine. This data can be staged in a particular cloud and the virtual
    machine implementation can override how the preprovisioned data is
    installed in the VM by overriding DownloadPreprovisionedBenchmarkData.

    For example, for GCP VMs, benchmark data can be preprovisioned in a GCS
    bucket that the VMs may access. For a benchmark that requires
    preprovisioned data, follow the instructions for that benchmark to download
    and store the data so that it may be accessed by a VM via this method.

    Before installing from preprovisioned data in the cloud, this function looks
    for files in the local data directory. If found, they are pushed to the VM.
    Otherwise, this function attempts to download them from their preprovisioned
    location onto the VM.

    Args:
      benchmark_name: The name of the benchmark defining the preprovisioned
          data. The benchmark's module must define the dict BENCHMARK_DATA
          mapping filenames to md5sum hashes.
      filenames: An iterable of preprovisioned data filenames for a particular
          benchmark.
      install_path: The path to download the data file.

    Raises:
      errors.Setup.BadPreProvisionedDataError: If the benchmark or filename are
          not defined with preprovisioned data, or if the md5sum hash in the
          code does not match the md5sum of the file.
    """
    benchmark_module = benchmark_lookup.BenchmarkModule(benchmark_name)
    if not benchmark_module:
      raise errors.Setup.BadPreprovisionedDataError(
          'Cannot install preprovisioned data for undefined benchmark %s.' %
          benchmark_name)
    try:
      benchmark_data = benchmark_module.BENCHMARK_DATA
    except AttributeError:
      raise errors.Setup.BadPreprovisionedDataError(
          'Benchmark %s does not define a BENCHMARK_DATA dict with '
          'preprovisioned data.' % benchmark_name)
    for filename in filenames:
      if data.ResourceExists(filename):
        local_tar_file_path = data.ResourcePath(filename)
        self.PushFile(local_tar_file_path, install_path)
        continue
      md5sum = benchmark_data.get(filename)
      if md5sum:
        self.DownloadPreprovisionedBenchmarkData(install_path, benchmark_name,
                                                 filename)
        self.CheckPreprovisionedBenchmarkData(install_path, benchmark_name,
                                              filename, md5sum)
        continue
      raise errors.Setup.BadPreprovisionedDataError(
          'Cannot find md5sum hash for file %s in benchmark %s. See README.md '
          'for information about preprovisioned data. '
          'Cannot find file in /data directory either, fail to upload from '
          'local directory.' % (filename, benchmark_name))
Exemplo n.º 2
0
    def InstallPreprovisionedBenchmarkData(self, benchmark_name, filenames,
                                           install_path):
        """Installs preprovisioned benchmark data on this VM.

    Some benchmarks require importing many bytes of data into the virtual
    machine. This data can be staged in a particular cloud and the virtual
    machine implementation can override how the preprovisioned data is
    installed in the VM by overriding DownloadPreprovisionedBenchmarkData.

    For example, for GCP VMs, benchmark data can be preprovisioned in a GCS
    bucket that the VMs may access. For a benchmark that requires
    preprovisioned data, follow the instructions for that benchmark to download
    and store the data so that it may be accessed by a VM via this method.

    Args:
      benchmark_name: The name of the benchmark defining the preprovisioned
          data. The benchmark's module must define the dict BENCHMARK_DATA
          mapping filenames to md5sum hashes.
      filenames: An iterable of preprovisioned data filenames for a particular
          benchmark.
      install_path: The path to download the data file.

    Raises:
      errors.Setup.BadPreProvisionedDataError: If the benchmark or filename are
          not defined with preprovisioned data, or if the md5sum hash in the
          code does not match the md5sum of the file.
    """
        benchmark_module = benchmark_lookup.BenchmarkModule(benchmark_name)
        if not benchmark_module:
            raise errors.Setup.BadPreprovisionedDataError(
                'Cannot install preprovisioned data for undefined benchmark %s.'
                % benchmark_name)
        try:
            benchmark_data = benchmark_module.BENCHMARK_DATA
        except AttributeError:
            raise errors.Setup.BadPreprovisionedDataError(
                'Benchmark %s does not define a BENCHMARK_DATA dict with '
                'preprovisioned data.' % benchmark_name)
        for filename in filenames:
            md5sum = benchmark_data.get(filename)
            if not md5sum:
                raise errors.Setup.BadPreprovisionedDataError(
                    'Cannot find md5sum hash for file %s in benchmark %s.' %
                    (filename, benchmark_name))
            self.DownloadPreprovisionedBenchmarkData(install_path,
                                                     benchmark_name, filename)
            self.CheckPreprovisionedBenchmarkData(install_path, benchmark_name,
                                                  filename, md5sum)
Exemplo n.º 3
0
    def InstallPreprovisionedBenchmarkData(self, benchmark_name, filenames,
                                           install_path):
        """Installs preprovisioned benchmark data on this VM.

    Some benchmarks require importing many bytes of data into the virtual
    machine. This data can be staged in a particular cloud and the virtual
    machine implementation can override how the preprovisioned data is
    installed in the VM by overriding DownloadPreprovisionedData.

    For example, for GCP VMs, benchmark data can be preprovisioned in a GCS
    bucket that the VMs may access. For a benchmark that requires
    preprovisioned data, follow the instructions for that benchmark to download
    and store the data so that it may be accessed by a VM via this method.

    Before installing from preprovisioned data in the cloud, this function looks
    for files in the local data directory. If found, they are pushed to the VM.
    Otherwise, this function attempts to download them from their preprovisioned
    location onto the VM.

    Args:
      benchmark_name: The name of the benchmark defining the preprovisioned
          data. The benchmark's module must define the dict BENCHMARK_DATA
          mapping filenames to sha256sum hashes.
      filenames: An iterable of preprovisioned data filenames for a particular
          benchmark.
      install_path: The path to download the data file.

    Raises:
      errors.Setup.BadPreprovisionedDataError: If the benchmark or filename are
          not defined with preprovisioned data, or if the sha256sum hash in the
          code does not match the sha256sum of the file.
    """
        benchmark_module = benchmark_lookup.BenchmarkModule(benchmark_name)
        if not benchmark_module:
            raise errors.Setup.BadPreprovisionedDataError(
                'Cannot install preprovisioned data for undefined benchmark %s.'
                % benchmark_name)
        try:
            # TODO(yanfeiren): Change BENCHMARK_DATA to PREPROVISIONED_DATA.
            preprovisioned_data = benchmark_module.BENCHMARK_DATA
        except AttributeError:
            raise errors.Setup.BadPreprovisionedDataError(
                'Benchmark %s does not define a BENCHMARK_DATA dict with '
                'preprovisioned data.' % benchmark_name)
        fallback_url = getattr(benchmark_module, 'BENCHMARK_DATA_URL', {})
        self._InstallData(preprovisioned_data, benchmark_name, filenames,
                          install_path, fallback_url)