File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/genesis.cpython-310.pyc
Back
o ;jU � @ s^ d Z ddlZddlZddlZddlZddlZddlZddlZddl Zddl ZddlZddlZddl ZddlmZ e�e�Zdddd�ZdZd d � Zddddddddddddef d d�Zdd� Zd2dd�Zdd� Zdddefdd�Z d3dd�Z d4dd�Zdd� Zdd � Zd5d#d$�Zd6d&d'�Z d7d(d)�Z!d8d*d+�Z"d,d-� Z#d2d.d/�Z$d2d0d1�Z%dS )9zI Module for managing container and VM images .. versionadded:: 2014.7.0 � N)�SaltInvocationError)�yum�rpm)�debootstrap)�pacman)r �debr zMhttp://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpmc C s dS )zt By default, this will be available on all platforms; but not all distros will necessarily be supported T� r r r �H/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/genesis.py�__virtual__# s r �dir�ext2c C sD |dvrt d��|dkr:td |�s9ztd |� W n� ty8 } zdtjj�t�|��iW Y d}~S d}~ww ns|dkr�| sDt d ��| sMd t � � � �} td | ddd� td dd| |fdd� t|||| � td d�}t� d|� td d|� d|� �� td d�}t� d|� td�}td d|� d|� d|� �� td | |� t| || � | r�| }|du r�g }| du r�g } | dv r�t||| |d� n| dkr�t||||||| d� n| dkr�t|||| d� |dk�r td |�}td! | � d"�d#|| d$ � td% |� td d&|� �� td d&|� �� td' | � dS dS )(a� Create an image for a specific platform. Please note that this function *MUST* be run as root, as images that are created make files belonging to root. platform Which platform to use to create the image. Currently supported platforms are rpm, deb and pacman. root Local path to create the root of the image filesystem. img_format Which format to create the image in. By default, just copies files into a directory on the local filesystem (``dir``). Future support will exist for ``sparse``. fs_format When using a non-``dir`` ``img_format``, which filesystem to format the image to. By default, ``ext2``. fs_opts When using a non-``dir`` ``img_format``, a dict of opts may be specified. arch Architecture to install packages for, if supported by the underlying bootstrap tool. Currently only used for deb. flavor Which flavor of operating system to install. This correlates to a specific directory on the distribution repositories. For instance, ``wheezy`` on Debian. repo_url Mainly important for Debian-based repos. Base URL for the mirror to install from. (e.x.: http://ftp.debian.org/debian/) static_qemu Local path to the static qemu binary required for this arch. (e.x.: /usr/bin/qemu-amd64-static) pkg_confs The location of the conf files to copy into the image, to point the installer to the right repos and configuration. img_size If img_format is not ``dir``, then the size of the image must be specified. mount_dir If img_format is not ``dir``, then the image must be mounted somewhere. If the ``mount_dir`` is not specified, then it will be created at ``/opt/salt-genesis.<random_uuid>``. This directory will be unmounted and removed when the process is finished. pkg_cache This points to a directory containing a cache of package files to be copied to the image. It does not need to be specified. pkgs A list of packages to be installed on this image. For RedHat, this will include ``yum``, ``centos-release`` and ``iputils`` by default. exclude_pkgs A list of packages to be excluded. If you do not want to install the defaults, you need to include them in this list. epel_url The URL to download the EPEL release package from. CLI Examples: .. code-block:: bash salt myminion genesis.bootstrap pacman /root/arch salt myminion genesis.bootstrap rpm /root/redhat salt myminion genesis.bootstrap deb /root/wheezy arch=amd64 flavor=wheezy static_qemu=/usr/bin/qemu-x86_64-static )r �sparsez(The img_format must be "sparse" or "dir"r �file.directory_exists� file.mkdir�ErrorNr z/An img_size must be specified for a sparse filez/opt/salt-genesis.�root�755�cmd.runZ fallocatez-lF�Zpython_shell� losetup -f�First loop device is %s�losetup � �Second loop device is %s� @ �losetup -o �mount.mount)r r )�pkgs�exclude_pkgs�epel_urlr )�arch�flavor�repo_url�static_qemur r r )� img_formatr r z disk.blkidzfile.replacez/boot/grub/grub.cfgz$ad4103fa-d940-47ca-8506-301d8071d467ZUUID�mount.umount�losetup -d z file.rmdir)r �__salt__� Exception�salt�utils�stringutils� to_unicode�pprint�pformat�uuidZuuid4�_mkpart�log�debug�str�_populate_cache�_bootstrap_yum�_bootstrap_deb�_bootstrap_pacman)�platformr r$ � fs_format�fs_optsr r! r"