a '¡Dgá ã@s„dZddlZddlZddlZddlmZddlmZmZddl m Z ddl m Z m Z dZddd „Zd d „Zd d „Zedkr€eƒdS)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-idcCsdtƒ d¡}|stjtdd�}|jdddddd �|jd d ddd d �|jd dt|d|›�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 )Útyper r)rZ get_runpathÚargparseÚArgumentParserÚNAMEÚ add_argumentÚstr)ÚparserZdefault_instance_json©rú:/usr/lib/python3.9/site-packages/cloudinit/cmd/cloud_id.pyÚ get_parsers< þûûÿú rc Csztƒ}|jtjkr,tj d |jj¡¡dS|jtj krRtj d |jj¡¡dSz8t |j ƒ�}t   |¡}Wdƒn1s~0YWnXty¬t d|j ¡YStyâ}z t d|j |f¡WYd}~Sd}~00| di¡}t| dt¡| d t¡| d t¡ƒ}|j �rDtj d ¡||d <t j|d ddd�}n"|j�rbd|| d t¡f}n|}tj d|¡dS)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 '%s' is not valid json. %sÚv1Z cloud_nameZregionÚplatformz%DEPRECATED: Use: cloud-init query v1 Úcloud_idéT)ú,z: )ÚindentZ sort_keysZ separatorsz%s %sz%s r)rZrunning_statusrZDISABLEDÚsysÚstdoutÚwriteÚformatÚvalueZ NOT_STARTEDÚopenrÚjsonÚloadÚIOErrorrÚerrorÚ ValueErrorÚgetrrÚstderrÚdumpsZlong) ÚnameÚargsZstatus_detailsÚfilerÚerrZresponserrrÚ handle_args=sJ   , ÿÿ ÿ    ý ÿr3cCstƒ}t tt| ¡ƒ¡dS)z,Tool to query specific instance-data values.N)rr!Úexitr3rÚ parse_args)rrrrÚmainlsr6Ú__main__)N)Ú__doc__rr'r!Zcloudinit.cmd.develrZcloudinit.cmd.statusrrZ cloudinit.logrZcloudinit.sourcesrrrrr3r6Ú__name__rrrrÚs   */