示例#1
0
 def setup_benchmark_env():
     """Prepare environment for benchmark.
     """
     lvm.lvcreate(volume=benchmark_lv,
                  group=vg_name,
                  size_in_bytes=utils.size_to_bytes(total_volume))
     fs_linux.blk_fs_create(device)
     fs_linux.mount_filesystem(device, base_path, fs_type='ext4')
示例#2
0
def _create_root_dir(container_dir, localdisk):
    """Prepares chrooted environment."""
    # Create root directory structure (chroot base).
    # container_dir/<subdir>
    root_dir = os.path.join(container_dir, 'root')

    already_initialized = fs_linux.blk_fs_test(localdisk['block_dev'])
    if not already_initialized:
        # Format the block device
        fs_linux.blk_fs_create(localdisk['block_dev'])

    _LOGGER.info('Creating container root directory: %s', root_dir)
    # Creates directory that will serve as new root.
    fs.mkdir_safe(fs.norm_safe(root_dir))
    # Unshare the mount namespace
    unshare.unshare(unshare.CLONE_NEWNS)
    # Mount the container root volume
    fs_linux.mount_filesystem(localdisk['block_dev'], root_dir)

    return root_dir