# -*- coding: utf-8 -*- # Authors: Radostin Stoyanov # # Copyright (C) 2017 Radostin Stoyanov # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program. If not, see . """ VirtBuilderSource aim is to extract the root file system from VM image build with virt-builder from template. """ import os import logging import subprocess import tempfile import guestfs from virtBootstrap import utils # pylint: disable=invalid-name # Create logger logger = logging.getLogger(__name__) class VirtBuilderSource(object): """ Extract root file system from image build with virt-builder. """ def __init__(self, **kwargs): """ Create container rootfs by building VM from virt-builder template and extract the rootfs. @param uri: Template name @param fmt: Format used to store the output [dir, qcow2] @param uid_map: Mappings for UID of files in rootfs @param gid_map: Mappings for GID of files in rootfs @param root_password: Root password to set in rootfs @param progress: Instance of the progress module """ # Parsed URIs: # - "virt-builder:///