
    x[h                         d Z ddlZddlZddlZddlmZ ddlmZmZ ddl	m
Z
 ddlmZmZ dZddZd	 Zd
 Zedk(  r e        yy)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_idzcloud-idc                    t               j                  d      }| st        j                  t        d      } | j                  ddddd	       | j                  d
dddd	       | j                  ddt        |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   )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_parserr      s     +,88I((I
 D   L   %/02  	 M    c                    t               }|j                  t        j                  k(  rCt        j
                  j                  dj                  |j                  j                               y|j                  t        j                  k(  rCt        j
                  j                  dj                  |j                  j                               y	 t        |j                        5 }t        j                  |      }ddd       j%                  di       }t'        |j%                  d	t(              |j%                  d
t(              |j%                  dt(                    }|j                  r>t        j*                  j                  d       ||d<   t        j,                  |ddd      }n*|j.                  r|d|j%                  d
t(              }n|}t        j
                  j                  d|z         y# 1 sw Y   xY w# t        $ r% t        j                   d|j                  z        cY S t"        $ r/}t        j                   d|j                  d|      cY d}~S d}~ww xY w)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-datazFile '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getr   r   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
$$$% 	, IIdOM	, 
		4	$B!
|-.
x)*
z+,H
 yy

AB!:::qD[
 
':J)KLJJVh&'9	, 	, 
~~%'+'9'9:
 	
  
~~151C1CQG
 	

s<   G= !G17G= 1G:6G= =+I!*I!2$II!I!c                  z    t               } t        j                  t        t        | j                                      y)z,Tool to query specific instance-data values.N)r   r-   exitrC   r   
parse_args)r   s    r   mainrG   l   s%    \FHH[v00234r   __main__)N)__doc__r   r4   r-   cloudinit.cmd.develr   cloudinit.cmd.statusr   r   cloudinit.logr   cloudinit.sourcesr   r   r   r   rC   rG   __name__ r   r   <module>rP      sJ   
 J   
 . B " B'T,^5 zF r   