def _GeneratePayloads(self, image_name, **kwargs): """Generate and upload payloads for |image_name|. Args: image_name: The image to use. **kwargs: Keyword arguments to pass to commands.GeneratePayloads. """ with osutils.TempDir(prefix='cbuildbot-payloads') as tempdir: with self.ArtifactUploader() as queue: image_path = os.path.join(self.GetImageDirSymlink(), image_name) commands.GeneratePayloads(self._build_root, image_path, tempdir, **kwargs) for payload in os.listdir(tempdir): queue.put([os.path.join(tempdir, payload)])
def _GenerateTestArtifactsInMoblabDisk(self, vms): """Generates test artifacts into devserver cache directory in moblab's disk. Args: vms: A moblab_vm.MoblabVm instance that has been Createed but not Started. Returns: The absolute path inside moblab VM where the image cache is located. """ with vms.MountedMoblabDiskContext() as disk_dir: # If by any chance this path exists, the permission bits are surely # nonsense, since 'moblab' user doesn't exist on the host system. osutils.RmDir(os.path.join(disk_dir, _MOBLAB_PAYLOAD_CACHE_DIR), ignore_missing=True, sudo=True) payloads_dir = os.path.join(disk_dir, _MOBLAB_PAYLOAD_CACHE_DIR, self._SubDutTargetImage()) # moblab VM will chown this folder upon boot, so once again permission # bits from the host don't matter. osutils.SafeMakedirsNonRoot(payloads_dir) target_image_path = os.path.join(self.GetImageDirSymlink(), constants.TEST_IMAGE_BIN) commands.GeneratePayloads(target_image_path=target_image_path, archive_dir=payloads_dir, full=True, delta=False, stateful=True, dlc=False) commands.GenerateQuickProvisionPayloads( target_image_path=target_image_path, archive_dir=payloads_dir) cwd = os.path.abspath( os.path.join(self._build_root, 'chroot', 'build', self._current_board, constants.AUTOTEST_BUILD_PATH, '..')) logging.debug( 'Running BuildAutotestTarballsForHWTest root %s cwd %s target %s', self._build_root, cwd, payloads_dir) commands.BuildAutotestTarballsForHWTest(self._build_root, cwd, payloads_dir) return os.path.join(_MOBLAB_STATIC_MOUNT_PATH, _MOBLAB_PAYLOAD_CACHE_DIR)