Current File : //usr/lib/python3/dist-packages/cloudinit/cmd/__pycache__/cloud_id.cpython-312.pyc
�

Ӈg�
���dZddlZddlZddlZddlmZddlmZmZddl	m
Z
ddlmZm
Z
dZdd�Zd	�Zd
�Zedk(re�yy)
zCCommandline utility to list the canonical cloud-id for an instance.�N)�read_cfg_paths)�
RunningStatus�get_status_details)�log_util)�METADATA_UNKNOWN�canonical_cloud_idzcloud-idc��t�jd�}|stjtd��}|jddddd�	�|jd
dddd�	�|jd
dt|d|����|S)a*Build or extend an arg parser for the cloud-id utility.

    @param parser: Optional existing ArgumentParser instance representing the
        query subcommand which will be extended to support the args of
        this utility.

    @returns: ArgumentParser with proper argument configuration.
    �
instance_dataz/Report the canonical cloud-id for this instance)�prog�descriptionz-jz--json�
store_trueFz5Report all standardized cloud-id information as json.)�action�default�helpz-lz--longz=Report extended cloud-id information as tab-delimited string.z-iz--instance-dataz,Path to instance-data.json file. Default is )�typerr)r�get_runpath�argparse�ArgumentParser�NAME�add_argument�str)�parser�default_instance_jsons  �8/usr/lib/python3/dist-packages/cloudinit/cmd/cloud_id.py�
get_parserrs���+�,�8�8��I����(�(��I�
���������
D����������
L��������
�%�
�/�0�
2�
�	��M�c���t�}|jtjk(rCtj
j
dj|jj��y|jtjk(rCtj
j
dj|jj��y	t|j�5}tj|�}ddd�j%di�}t'|j%d	t(�|j%d
t(�|j%dt(��}|jr>tj*j
d�||d
<tj,|ddd��}n*|j.r|�d|j%d
t(���}n|}tj
j
d|z�y#1swY��xYw#t$r%tj d|jz�cYSt"$r/}tj d|j�d|���cYd}~Sd}~wwxYw)z�Handle calls to 'cloud-id' cli.

    Print the canonical cloud-id on which the instance is running.

    @return: 0 on success, 1 on error, 2 on disabled, 3 on cloud-init not run.
    z{0}
��NzTFile not found '%s'. Provide a path to instance data json file using --instance-datazFile 'z' is not valid json. �v1�
cloud_name�region�platformz%DEPRECATED: Use: cloud-init query v1
�cloud_id�T)�,z: )�indent�	sort_keys�
separators�	z%s
r)r�running_statusr�DISABLED�sys�stdout�write�format�value�NOT_STARTED�openr
�json�load�IOErrorr�error�
ValueError�getrr�stderr�dumps�long)	�name�args�status_details�filer
�er r$�responses	         r�handle_argsrC=s���(�)�N��$�$�
�(>�(>�>��
�
�������(E�(E�(K�(K�L�M��	�	&�	&�-�*C�*C�	C��
�
�������(E�(E�(K�(K�L�M��
�
�$�$�$�
%�	,�� �I�I�d�O�M�	,�
�	�	�4��	$�B�!�
���|�-�.�
���x�)�*�
���z�+�,��H�
�y�y��
�
���A�B�!��:���:�:��q�D�[�
��
���'�����:J�)K�L�����J�J���V�h�&�'��9	,�	,���
��~�~�
%�'+�'9�'9�
:�
�	
��
��~�~�15�1C�1C�Q�G�
�	
��
�s<�G=�!G1�7G=�1G:�6G=�=+I!�*I!�2$I�I!�I!c�z�t�}tjtt|j���y)z,Tool to query specific instance-data values.N)rr-�exitrCr�
parse_args)rs r�mainrGls%��
�\�F��H�H�[��v�0�0�2�
3�4r�__main__)N)�__doc__rr4r-�cloudinit.cmd.develr�cloudinit.cmd.statusrr�
cloudinit.logr�cloudinit.sourcesrrrrrCrG�__name__�rr�<module>rPsJ��
J���
�.�B�"�B���'�T,
�^5��z���F�r