f dZddlZddlZddlZddlmZddlmZmZddl m Z m Z ddl m Z dZd dZd Zd Zed k(reyy) zCCommandline utility to list the canonical cloud-id for an instance.N)read_cfg_paths) RunningStatusget_status_details)METADATA_UNKNOWNcanonical_cloud_id)errorzcloud-idctjd}|stjtd}|j ddddd |j d d ddd |j d 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.)actiondefaulthelpz-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_runpathargparseArgumentParserNAME add_argumentstr)parserdefault_instance_jsons 8/usr/lib/python3/dist-packages/cloudinit/cmd/cloud_id.py get_parserrs+,88I ((I    D    L    % /0 2   Mct}|jtjk(rCtj j dj|jjy|jtjk(rCtj j dj|jjy t|j5}tj|}dddj#di}t%|j#d t&|j#d t&|j#d t&}|jr>tj(j d ||d <tj*|ddd}n*|j,r|d|j#d t&}n|}tj j d|zy#1swYxYw#t$rtd|jzcYSt $r%}td|jd|cYd}~Sd}~wwxYw)zHandle 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_nameregionplatformz%DEPRECATED: Use: cloud-init query v1 cloud_idT),z: )indent sort_keys separators z%s r)rrunning_statusrDISABLEDsysstdoutwriteformatvalue NOT_STARTEDopenr jsonloadIOErrorr ValueErrorgetrrstderrdumpslong) nameargsstatus_detailsfiler er r$responses r handle_argsrB=s()N$$ (>(>> (E(E(K(KLM  & &-*C*C C (E(E(K(KLM  $$$ % , IIdOM ,   4 $B! |-. x)* z+,H  yy AB!::: qD[  ':J)KLJJVh&' 9 , ,   %'+'9'9 :    151C1CQ G   s< G=!G17G=1G:6G==!I  I (II I czt}tjtt|j y)z,Tool to query specific instance-data values.N)rr-exitrBr parse_args)rs rmainrFls% \FHH[v002 34r__main__)N)__doc__rr4r-cloudinit.cmd.develrcloudinit.cmd.statusrrcloudinit.sourcesrrcloudinit.utilrrrrBrF__name__rrrOsJ J .BB 'T, ^5  zFr