3 \me @ s d Z ddlZddlZddlZddlmZ ddlmZmZ ddl m Z mZ ddlm Z dZddd Zd d Zdd Zedkre dS )zCCommandline utility to list the canonical cloud-id for an instance. N)read_cfg_paths)UXAppStatusget_status_details)METADATA_UNKNOWNcanonical_cloud_id)errorzcloud-idc C sd t jd}| stjtdd} | jdddddd | jd ddddd | 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)progdescriptionz-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 )typer r )r Zget_runpathargparseArgumentParserNAMEadd_argumentstr)parserZdefault_instance_json r /usr/lib/python3.6/cloud_id.py get_parser s0 r c C sX t }|jtjkr,tjjdj|jj dS |jtj krRtjjdj|jj dS y$t |j}tj |}W dQ R X W nJ tk r td|j S tk r } ztd|j|f S d}~X nX |jdi }t|jdt|jd t|jd t}|jr"tjjd ||d<