%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python3/dist-packages/cloudinit/config/__pycache__/
Upload File :
Create Path :
Current File : //lib/python3/dist-packages/cloudinit/config/__pycache__/cc_lxd.cpython-312.pyc

�

���f6�
��UdZddlZddlZddlmZmZddlZddlmZm	Z	ddl
mZddlm
Z
ddlmZddlmZej$e�Zd	Zd
dgedgd
�Zeed<d�Zdede
dededdf
d�Zd�Zd�Zd�Z	dd�Zde dedeefd�Z!y)z>LXD: configure lxd with ``lxd init`` and optionally lxd-bridge�N)�List�Tuple)�subp�util)�Cloud)�Config)�
MetaSchema)�PER_INSTANCE�lxdbr0�cc_lxd�ubuntu�lxd)�id�distros�	frequency�activate_by_schema_keys�metac��g}t|t�s(|jdt|�j�d��t|t�s(|jdt|�j�d��t|t
�s(|jdt|�j�d��|r8|s|r4|rdgng}||rdgngz
}|jddj
|����|rtd	j
|���y
)z�Validate user-provided lxd network and bridge config option values.

    @raises: ValueError describing invalid values provided.
    z/lxd.init config must be a dictionary. found a '�'z1lxd.bridge config must be a dictionary. found a 'z.lxd.preseed config must be a string. found a 'zlxd.initz
lxd.bridgezMUnable to configure LXD. lxd.preseed config can not be provided with key(s): z, z. N)�
isinstance�dict�append�type�__name__�str�join�
ValueError)�init_cfg�
bridge_cfg�preseed_str�errors�incompat_cfgs     �9/usr/lib/python3/dist-packages/cloudinit/config/cc_lxd.py�supplemental_schema_validationr$!s��
�F��h��%��
�
���h��(�(�)��
,�	
�
�j�$�'��
�
���j�!�*�*�+�1�
.�	
�
�k�3�'��
�
���k�"�+�+�,�A�
/�	
���J�'/�
�|�R���*���"�<���
�
�
�!�Y�Y�|�4�5�
7�	
������6�*�+�+���name�cfg�cloud�args�returnc
��|jd�}|stjd|�yt|t�s"tdt
|�j�d���tj|�|jdi�}|jdd�}|jdi�}t|||�tjd�s	tjgd	��t||�}	t!|	�r	|j"j%|	�tjgd��|rtjgd
�|��y|r�d}tj(�dd}|ddk(rat*j,j/d|�d��s>tj'd�tjgd��t1d�|D��}gd�}
|D]H}|j|�s�|
j3d|j5dd��dt7||���g��Jtj|
�d}|�r�|jdt8�}t*j,j/d �r�tj|�r�t;|�}	tjd!|�d"j=|j?�D��cgc]
\}}d#|�d$|����c}}�d"z}tjdg|��tjDd �tjd&�tjgd'��ytG|�\}}tI|tK|�tK|�tK|��(�|r0tjd)d$j=|��tM|�|r1tjd*d$j=|��tM|�yy|rtd+|z��y#tj$r}td
|z�|�d}~wwxYw#tj$r!}
tj'd|	|
�Yd}
~
yd}
~
wwxYwcc}}w#t@$r!tjBtd%|z�Y���wxYw),Nrz8Skipping module named %s, not present or disabled by cfgz*lxd config must be a dictionary. found a 'r�init�preseed��bridge)�snap�installrz#Failed to install lxd from snap: %sz!failed to install packages %s: %s)r�	waitreadyz
--timeout=300)rr,z	--preseed)�data)�network_address�network_port�storage_backend�storage_create_device�storage_create_loop�storage_pool�trust_password�uname�r6�lvmz
/lib/modules/z"/kernel/drivers/md/dm-thin-pool.kozqcloud-init doesn't use thinpool by default on Ubuntu due to LP #1982780. This behavior will change in the future.)�lxc�storage�create�defaultr=zlvm.use_thinpool=falsec3�,K�|]}|dk7s�	|���y�w)r6N�)�.0�keys  r#�	<genexpr>zhandle.<locals>.<genexpr>�s������C�3D�,D���s�
�)rr,z--autoz--�_�-�=zdebconf-communicater&z/etc/default/lxd-bridgezSetting lxd debconf via %s�
zset � zFailed to run '%s' for lxd withz Running dpkg-reconfigure for lxd)zdpkg-reconfigurerz--frontend=noninteractive)�net_name�did_initr@�attachzCreating lxd bridge: %sz!Setting up default lxd bridge: %sz*Unable to configure lxd bridge without %s.)'�get�LOG�debugrrrrrr�wait_for_snap_seededr$r�which�ProcessExecutionError�RuntimeError�get_required_packages�len�distro�install_packages�warning�system_info�os�path�exists�tuple�extend�replacer�_DEFAULT_NETWORK_NAME�bridge_to_debconfr�items�	Exception�logexc�del_file�
bridge_to_cmd�maybe_cleanup_default�bool�_lxc)r&r'r(r)�lxd_cfgrr r�e�packages�exc�	init_keys�kernel�cmd�k�
dconf_commrL�debconf�vr3�
cmd_create�
cmd_attachs                      r#�handleryDs����g�g�e�n�G���	�	�F��	
�	��g�t�$����g��'�'�(��
+�
�	
�
	���e�$��{�{�6�2�&�H��+�+�i��,�K����X�r�*�J�"�8�Z��E��:�:�e��	��I�I�0�1�
%�X�{�;�H�
�8�}�	��L�L�)�)�(�3�
	�I�I�3�4���	�	�.�[�A���&
�	��!�!�#�G�,�Q�/���%�&�%�/�������F�8�#E�F�9
�
�K�K�H�
�
�I�I��	
���(���I�(���	�A��|�|�A���
�
�"#�)�)�C��"5�s�8�A�;�7G�H�I��	�
	
�	�	�#��'�J���>�>�&�*?�@��
�7�7�>�>�3�4�����:
�
(�
�3�G�
��	�	�6�
�C��I�I�:A�-�-�/�J�$�!�Q��1�-�J������	�	�0�1��=�
�M�M�3�4�
�I�I�8�9��I�I�N�O�&3�:�%>�"�J�
�!�!��h���J�'��J�'�	
���	�	�3�S�X�X�j�5I�J��Z� ���	�	�7����*�9M���Z� �	�
��8�:�E�
�	
�
��i�)�)�	��5��9���
��	���)�)�	��K�K�;�X�s�K���	��RK��
�
�����:�Z�G��
�sT�O*�:P�4Q�Q
�#Q�*P�=P�P�Q�'Q�Q�Q�&Q;�:Q;c�x�i}|jd�dk(rd|d<d|d<|S|jd�dk(r d|d<d|d	<|jd
�|d<|S|jd�dk(�r3d|d<|jd
�r|jd
�|d<|jd�r~d|d
<|jd�|d<|jd�|d<|jd�|d<|jd�|d<|jd�|d<|jdd�|d<|jd�rBd|d<|jd�|d<|jd�|d<|jdd�|d<|jd �r|jd �|d!<|Std"|jd�z��)#N�mode�none�falsezlxd/setup-bridger.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-last�ipv4_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-domain�invalid bridge mode "%s")rOrU)rrus  r#rcrc�s����G��~�~�f���'�&-��"�#�%'��!�"�R�N�O
����	�:�	-�&-��"�#�-3��)�*�%/�^�^�F�%;��!�"�H�N�E
����	�5�	(�&,��"�#��>�>�&�!�)3����)?�G�%�&��>�>�.�)�)/�G�%�&�1;����1O�G�-�.�1;����1O�G�-�.�4>�N�N�!�5�G�0�1�4>�>�>� �4�G�/�0�6@�^�^�"�6�G�1�2�.8�^�^�J��-O�G�)�*��>�>�.�)�)/�G�%�&�1;����1O�G�-�.�1;����1O�G�-�.�-7�^�^��G�.�G�)�*��>�>�(�#�+5�>�>�(�+C�G�'�(�
�N��5�
���v�8N�N�O�Or%c��|jd�dk(ry|jdt�}g}dd|ddg}|jd�d	k(rd|fS|jd�d
k7rtd|jd�z��dd|g}|jd
�r�|jd�r�|jd|jd
��d|jd����|jdd�dk(r|jd�|jd�r\|jd�rK|jd��d|jd���}|jd|z�n|jd�|jd�rl|jd�r[|jd|jd��d|jd����|jd�dk(r#|jd�n|jd�|jd�r#|jd |jd�z�|jd!d"�}|d"k7r|jd#|���||fS)$Nr{r|)NNr&�networkzattach-profilerA�eth0r~r�r�r@r�r�z
ipv4.address=�/r�rz
ipv4.nat=truer�r�rHzipv4.dhcp.ranges=%szipv4.address=noner�r�z
ipv6.address=r�z
ipv6.nat=truezipv6.address=noner�z
dns.domain=%s�mtu���zbridge.mtu=)rOrbrUr)r�bridge_namerwrx�
dhcp_ranger�s      r#rhrhs-���~�~�f���'���.�.��)>�?�K��J��-�{�I�v�N�J��~�~�f���+��Z����~�~�f���&��5�
���v�8N�N�O�O��X�{�3�J��~�~�n�%�*�.�.��*H�����~�~�n�-�z�~�~�n�/M�
O�	
�
�>�>�*�f�-��7����o�.��>�>�+�,�����2
����0�1����/�0��J�
���3�j�@�A����-�.��~�~�n�%�*�.�.��*H�����~�~�n�-�z�~�~�n�/M�
O�	
�
�>�>�*�%��/����o�.�	���-�.��~�~�h�����/�J�N�N�8�,D�D�E��.�.���
#�C�
�b�y����K��u�-�.��z�!�!r%c���dtjjdd�tjjdd�d�}tjdgt	|�zdgz|�	�y)
N�C�HOMEz/root�USER�root)�LC_ALLr�r�r>z
--force-local)�
update_env)r\�environrOr�list)rr�envs  r#rkrkCsS����
�
���v�w�/��
�
���v�v�.��C�
	�I�I�u�g��S�	�!�_�$5�5�#�Fr%c�J�|tk7s|syd}d}|rQd}	tdd||g�tj||||�d}tdd|g�tj|||�|r,d
}	tddd
||g�tj||||�yy#tj
$r3}	|	jd	k7r|	�tj||||�Yd}	~	�pd}	~	wwxYw#tj
$r3}	|	jd	k7r|	�tj||||�Yd}	~	yd}	~	wwxYw)aNewer versions of lxc (3.0.1+) create a lxdbr0 network when
    'lxd init --auto' is run.  Older versions did not.

    By removing any that lxd-init created, we simply leave the add/attach
    code intact.

    https://github.com/canonical/lxd/issues/4649Nz"failed. Assuming it did not exist.z
succeeded.z/Detach of lxd network '%s' from profile '%s' %sr�zdetach-profilezDeletion of lxd network '%s' %s�delete�z+Removal of device '%s' from profile '%s' %s�profile�device�remove)rbrkrPrQrrT�	exit_code)
rLrMr@rNr��nic_name�fail_assume_enoent�	succeeded�msgrms
          r#ririLs-���(�(���=���I�
�?��
	0��)�-�x��A�B��I�I�c�8�W�i�8�4�C��)�X�x�0�1��I�I�c�8�Y�/�
�;��	B��)�X�x��(�C�D��I�I�c�8�W�i�8�	���)�)�	B��{�{�a�����I�I�c�8�W�.@�A�A��	B���)�)�	B��{�{�a�����I�I�c�8�W�.@�A�A��	B�s/�'B�)(C�C�&)C�C�D"�/)D�D"rr c�b�g}g}i}d|vr|j|d�|rd|vr	tj|�}|jdg�D](}|jd�s�|j|d��*d|vr&tjd�s|jd�d|vr&tjd�s|jd	�d
|vr&tjd�s|jd�|S#tjtt
f$rtjd�Y��wxYw)
z&identify required packages for installr6�
storage_poolsz|lxd.preseed string value is not YAML.  Unable to determine required storage driver packages to support storage_pools config.�driver�zfszzfsutils-linuxr=�lvcreate�lvm2�btrfsz
mkfs.btrfszbtrfs-progs)r�yaml�	safe_load�	YAMLError�	TypeErrorrrPrZrOrrS)rr rn�storage_drivers�preseed_cfgr9s      r#rVrVts���H�"$�O��K��H�$����x�(9�:�;���+�5�	��.�.��5�K�$�����<�;�����H�%��"�"�<��#9�:�;�
����
�
�5�(9����(�)�����
�
�:�(>�������/�!�$�*�*�\�*B����
�&��O�����	�:�6�	��K�K�1�
�	�s�C8�83D.�-D.)rAr�)"�__doc__�loggingr\�typingrrr��	cloudinitrr�cloudinit.cloudr�cloudinit.configr�cloudinit.config.schemar	�cloudinit.settingsr
�	getLoggerrrPrbr�__annotations__r$rr�ryrcrhrkrirrVrCr%r#�<module>r�s���E��	��� �!�#�.�+��g����!�� ����z�� %�w�	��j�� ,�FO
��O
�6�O
�%�O
�t�O
��O
�d.�b9"�xG�EK�%B�P�D��s��t�C�y�r%

Zerion Mini Shell 1.0