HOME


Mini Shell 1.0
Redirecting to https://devs.lapieza.net/iniciar-sesion Redirecting to https://devs.lapieza.net/iniciar-sesion.
DIR: /proc/self/root/usr/lib/python3/dist-packages/cloudinit/config/__pycache__/
Upload File :
Current File : //proc/self/root/usr/lib/python3/dist-packages/cloudinit/config/__pycache__/cc_snap.cpython-311.pyc
�

܍~c����UdZddlZddlZddlmZddlmZddlmZddlm	Z	m
Z
ddlmZddl
mZdd	lmZmZdd
lmZddlmZdgZeZeje��Zd
dded��eed��ed��ed��ed��gedgd�Zeed<ee��ZdZd�Zd�Zde dededede!ddfd �Z"dS)!z<Snap: Install, configure and manage snapd and snap packages.�N)�Logger)�dedent)�log)�subp�util)�Cloud)�Config)�
MetaSchema�get_meta_doc)�PER_INSTANCE)�prepend_base_command�ubuntu�cc_snap�Snapz5Install, configure and manage snapd and snap packagesah        This module provides a simple configuration namespace in cloud-init to
        both setup snapd and install snaps.

        .. note::
            Both ``assertions`` and ``commands`` values can be either a
            dictionary or a list. If these configs are provided as a
            dictionary, the keys are only used to order the execution of the
            assertions or commands and the dictionary is merged with any
            vendor-data snap configuration provided. If a list is provided by
            the user instead of a dict, any vendor-data snap configuration is
            ignored.

        The ``assertions`` configuration option is a dictionary or list of
        properly-signed snap assertions which will run before any snap
        ``commands``. They will be added to snapd's assertion database by
        invoking ``snap ack <aggregate_assertion_file>``.

        Snap ``commands`` is a dictionary or list of individual snap
        commands to run on the target system. These commands can be used to
        create snap users, install snaps and provide snap configuration.

        .. note::
            If 'side-loading' private/unpublished snaps on an instance, it is
            best to create a snap seed directory and seed.yaml manifest in
            **/var/lib/snapd/seed/** which snapd automatically installs on
            startup.
        ax        snap:
            assertions:
              00: |
                signed_assertion_blob_here
              02: |
                signed_assertion_blob_here
            commands:
              00: snap create-user --sudoer --known <snap-user>@mydomain.com
              01: snap install canonical-livepatch
              02: canonical-livepatch enable <AUTH_TOKEN>
    ay        # Convenience: the snap command can be omitted when specifying commands
        # as a list and 'snap' will automatically be prepended.
        # The following commands are equivalent:
        snap:
          commands:
            00: ['install', 'vlc']
            01: ['snap', 'install', 'vlc']
            02: snap install vlc
            03: 'snap install vlc'
    z�        # You can use a list of commands
        snap:
          commands:
            - ['install', 'vlc']
            - ['snap', 'install', 'vlc']
            - snap install vlc
            - 'snap install vlc'
    z�        # You can use a list of assertions
        snap:
          assertions:
            - signed_assertion_blob_here
            - |
              signed_assertion_blob_here
    �snap)�id�name�title�description�distros�examples�	frequency�activate_by_schema_keys�metac�6�|sdSt�d��t|t��r|���}n8t|t
��s#t
d�|������td|g}d�	|��}|D]8}t�d|�
d��dd	����9tj||�
d
����tj|d���dS)
aImport list of assertions.

    Import assertions by concatenating each assertion into a
    string separated by a '
'.  Write this string to a instance file and
    then invoke `snap ack /path/to/file` and check for errors.
    If snap exits 0, then all assertions are imported.
    Nz'Importing user-provided snap assertionsz8assertion parameter was not a list or dict: {assertions})�
assertions�ack�
zSnap acking: %sr�zutf-8T)�capture)�LOG�debug�
isinstance�dict�values�list�	TypeError�format�SNAP_CMD�join�splitr�
write_file�encoder)r�assertions_file�snap_cmd�combined�asrts     �:/usr/lib/python3/dist-packages/cloudinit/config/cc_snap.py�add_assertionsr3xs�������I�I�7�8�8�8��*�d�#�#�
��&�&�(�(�
�
�
�
�D�
)�
)�
��F�M�M�%�
N�
�
�
�
�	
��%��1�H��y�y��$�$�H��<�<���	�	�#�T�Z�Z��%5�%5�a��c�%:�;�;�;�;��O�O�X�_�_�W�%=�%=�>�>�>��I�h��%�%�%�%�%�%�c���|sdSt�d��t|t��r,d�t	|�����D��}n8t|t��s#td�|������td|��}g}|D]|}t|t��}	tj||tj
j����?#tj$r,}|�t|����Yd}~�ud}~wwxYw|r?d�|�	��}t#jt|��t'|���dS)
aHRun the provided commands provided in snap:commands configuration.

    Commands are run individually. Any errors are collected and reported
    after attempting all commands.

    @param commands: A list or dict containing commands to run. Keys of a
        dict will be used to order the commands provided as dict values.
    Nz#Running user-provided snap commandsc��g|]\}}|��S�r7)�.0�_�vs   r2�
<listcomp>z run_commands.<locals>.<listcomp>�s��;�;�;�$�!�Q�A�;�;�;r4z5commands parameter was not a list or dict: {commands})�commandsr)�shell�	status_cbz.Failures running snap commands:
{cmd_failures})�cmd_failures)r!r"r#r$�sorted�itemsr&r'r(r
�strr�sys�stderr�write�ProcessExecutionError�appendr�logexc�RuntimeError)r<�fixed_snap_commandsr?�commandr=�e�msgs       r2�run_commandsrN�s��������I�I�3�4�4�4��(�D�!�!�
�;�;�&����)9�)9�":�":�;�;�;���
��$�
'�
'�
��C�J�J�!�
K�
�
�
�
�	
�/�v�x�@�@���L�&�(�(���7�C�(�(��	(��I�g�U�c�j�6F�G�G�G�G�G���)�	(�	(�	(�����A���'�'�'�'�'�'�'�'�����	(����� �?�F�F�%�G�
�
��	
��C������3���� � s�&C+�+D&�:"D!�!D&r�cfg�cloudr�args�returnc�h�|�di��}|st�d|��dSt|�dg��tj�|j���d����t|�dg����dS)Nrz8Skipping module named %s, no 'snap' key in configurationrzsnapd.assertionsr<)
�getr!r"r3�os�pathr*�paths�
get_ipath_currN)rrOrPrrQ�cfgins      r2�handlerZ�s���
�G�G�F�B���E����	�	�F��	
�	
�	
�	���
�	�	�,��#�#�
����U�[�.�.�0�0�2D�E�E��������:�r�*�*�+�+�+�+�+r4)#�__doc__rUrC�loggingr�textwrapr�	cloudinitrrr�cloudinit.cloudr�cloudinit.configr	�cloudinit.config.schemar
r�cloudinit.settingsr�cloudinit.subpr
rr�	getLogger�__name__r!r�__annotations__r)r3rNrBr&rZr7r4r2�<module>rgs!��
C�B�B�	�	�	�	�
�
�
�
�������������$�$�$�$�$�$� � � � � � � � �!�!�!�!�!�!�#�#�#�#�#�#�<�<�<�<�<�<�<�<�+�+�+�+�+�+�/�/�/�/�/�/��*���	��g���!�!����
D��6�	���<���
�
	
�
	
�	��

�	
�	
�	��
�
	
�
	
�	��
�		
�		
�O1�d� &�x�mW�W��j�W�W�W�t�,�t�
�
����&�&�&�<$ �$ �$ �N,�

�,��,�#(�,�/5�,�=A�,�	�,�,�,�,�,�,r4