403Webshell
Server IP : 23.254.227.96  /  Your IP : 216.73.216.7
Web Server : Apache/2.4.62 (Unix) OpenSSL/1.1.1k
System : Linux hwsrv-1277026.hostwindsdns.com 4.18.0-477.13.1.el8_8.x86_64 #1 SMP Tue May 30 14:53:41 EDT 2023 x86_64
User : viralblo ( 1001)
PHP Version : 8.1.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3.6/site-packages/cloudinit/config/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/lib/python3.6/site-packages/cloudinit/config/__pycache__/cc_lxd.cpython-36.pyc
3

��bf*�@sjdZddlZddlmZddlmZmZdgZeje	�Z
dZdd�Zd	d
�Z
dd�Zd
d�Zddd�ZdS)a�
LXD
---
**Summary:** configure lxd with ``lxd init`` and optionally lxd-bridge

This module configures lxd with user specified options using ``lxd init``.
If lxd is not present on the system but lxd configuration is provided, then
lxd will be installed. If the selected storage backend is zfs, then zfs will
be installed if missing. If network bridge configuration is provided, then
lxd-bridge will be configured accordingly.

**Internal name:** ``cc_lxd``

**Module frequency:** per instance

**Supported distros:** ubuntu

**Config keys**::

    lxd:
        init:
            network_address: <ip addr>
            network_port: <port>
            storage_backend: <zfs/dir>
            storage_create_device: <dev>
            storage_create_loop: <size>
            storage_pool: <name>
            trust_password: <password>
        bridge:
            mode: <new, existing or none>
            name: <name>
            ipv4_address: <ip addr>
            ipv4_netmask: <cidr>
            ipv4_dhcp_first: <ip addr>
            ipv4_dhcp_last: <ip addr>
            ipv4_dhcp_leases: <size>
            ipv4_nat: <bool>
            ipv6_address: <ip addr>
            ipv6_netmask: <cidr>
            ipv6_nat: <bool>
            domain: <domain>
�N)�log)�subp�utilZubuntuZlxdbr0cCs�|jd�}|s|jd|�dSt|t�s<|jdt|��dS|jd�}t|t�sd|jdt|��i}|jdi�}t|t�s�|jdt|��i}g}tjd�s�|jd�|jd�d	kr�tjd	�r�|jd
�t	|��ry|j
j|�Wn2tjk
�r}	z|jd||	�dSd}	~	XnX|�r�d(}
tjdddg�dddg}x>|
D]6}|j|��rB|j
d|jdd�t||�fg��qBWtj|�d}
|�r�|jdt�}tjjd��rHtj|
��rHt|�}y<|jd|
�djdd�|j�D��d}tjdg|�Wn&tk
�r tj|d|
�YnXtjd�|jd �tjd!dd"g�nlt|�\}}t|t|�t|�t|�d#�|�r�|jd$d%j|��t|�|�r�|jd&d%j|��t|�n|�r�td'|
��dS))NZlxdz8Skipping module named %s, not present or disabled by cfgz-lxd config must be a dictionary. found a '%s'Zinitz2lxd/init config must be a dictionary. found a '%s'Zbridgez4lxd/bridge config must be a dictionary. found a '%s'�storage_backendZzfszzfsutils-linuxz!failed to install packages %s: %s�network_address�network_port�storage_create_device�storage_create_loop�storage_pool�trust_passwordZ	waitreadyz
--timeout=300z--autoz--%s=%s�_�-zdebconf-communicate�namez/etc/default/lxd-bridgezSetting lxd debconf via �
cSsg|]\}}d||f�qS)z	set %s %s�)�.0�k�vrr�/usr/lib/python3.6/cc_lxd.py�
<listcomp>�szhandle.<locals>.<listcomp>zFailed to run '%s' for lxd withz Running dpkg-reconfigure for lxdzdpkg-reconfigurez--frontend=noninteractive)�net_name�did_init�create�attachzCreating lxd bridge: %s� z!Setting up default lxd bridge: %sz*Unable to configure lxd bridge without %s.)rrrrr	r
r) �get�debug�
isinstance�dictZwarning�typerZwhich�append�lenZdistroZinstall_packages�ProcessExecutionError�extend�replace�str�_DEFAULT_NETWORK_NAME�os�path�exists�bridge_to_debconf�join�items�	ExceptionrZlogexcZdel_file�
bridge_to_cmd�maybe_cleanup_default�bool�_lxc�RuntimeError)rZcfgZcloudr�argsZlxd_cfgZinit_cfg�
bridge_cfgZpackages�excZ	init_keys�cmdrZ
dconf_commr�debconf�data�
cmd_create�
cmd_attachrrr�handle>s�












&



r;cCs`i}|jd�dkr&d|d<d|d<�n6|jd�dkrVd|d<d|d	<|jd
�|d<�n|jd�dk�rJd|d<|jd
�r�|jd
�|d<|jd�r�d|d
<|jd�|d<|jd�|d<|jd�|d<|jd�|d<|jd�|d<|jdd�|d<|jd��r.d|d<|jd�|d<|jd�|d<|jdd�|d<|jd ��r\|jd �|d!<ntd"|jd���|S)#N�mode�none�falsezlxd/setup-bridge�zlxd/bridge-name�existing�truezlxd/use-existing-bridger�new�ipv4_addresszlxd/bridge-ipv4zlxd/bridge-ipv4-address�ipv4_netmaskzlxd/bridge-ipv4-netmask�ipv4_dhcp_firstzlxd/bridge-ipv4-dhcp-first�ipv4_dhcp_lastzlxd/bridge-ipv4-dhcp-lastZipv4_dhcp_leaseszlxd/bridge-ipv4-dhcp-leases�ipv4_natzlxd/bridge-ipv4-nat�ipv6_addresszlxd/bridge-ipv6zlxd/bridge-ipv6-address�ipv6_netmaskzlxd/bridge-ipv6-netmask�ipv6_natzlxd/bridge-ipv6-nat�domainzlxd/bridge-domainzinvalid bridge mode "%s")rr-)r4r7rrrr*�sB




r*cCs�|jd�dkrd S|jdt�}g}dd|ddg}|jd�dkrFd|fS|jd�d	krftd
|jd���dd|g}|jd�r�|jd
�r�|jd|jd�|jd
�f�|jdd�dkr�|jd�|jd�r�|jd�r�d|jd�|jd�f}|jd|�n
|jd�|jd��rV|jd��rV|jd|jd�|jd�f�|jdd�dk�r`|jd�n
|jd�|jd��r�|jd|jd��||fS)!Nr<r=r�networkzattach-profile�default�eth0r@rBzinvalid bridge mode "%s"rrCrDzipv4.address=%s/%srGrAz
ipv4.nat=truerErFz%s-%szipv4.dhcp.ranges=%szipv4.address=nonerHrIzipv6.address=%s/%srJr>z
ipv6.nat=truezipv6.address=nonerKz
dns.domain=%s)NN)rr&r-r )r4Zbridge_namer9r:Z
dhcp_rangerrrr.�sB



r.cCsBdtjjdd�tjjdd�d�}tjdgt|�dg|d	�dS)
N�C�HOMEz/root�USER�root)�LC_ALLrPrQZlxcz
--force-local)Z
update_env)r'�environrr�list)r6�envrrrr1 sr1rMrNc
Cs$|tks|rdSd}d}|r�d}y$tdd||g�tj||||�WnBtjk
r�}	z$|	jdkrh|	�tj||||�WYdd}	~	Xn"Xd}tdd	|g�tj|||�|�r d
}y&tddd
||g�tj||||�WnDtjk
�r}	z$|	jdkr�|	�tj||||�WYdd}	~	XnXdS)z�Newer versions of lxc (3.0.1+) create a lxdbr0 network when
    'lxd init --auto' is run.  Older versions did not.

    By removing ay that lxd-init created, we simply leave the add/attach
    code in-tact.

    https://github.com/lxc/lxd/issues/4649Nz"failed. Assuming it did not exist.z
succeeded.z/Detach of lxd network '%s' from profile '%s' %srLzdetach-profile�zDeletion of lxd network '%s' %s�deletez+Removal of device '%s' from profile '%s' %s�profileZdevice�remove)r&r1�LOGrrr"Z	exit_code)
rrrrrYZnic_nameZfail_assume_enoentZ	succeeded�msg�errrr/)s2

"
r/)rMrN)�__doc__r'Z	cloudinitrZloggingrrZdistrosZ	getLogger�__name__r[r&r;r*r.r1r/rrrr�<module>0s
{16

Youez - 2016 - github.com/yon3zu
LinuXploit