/usr/lib/python3.6/site-packages/cloudinit/cmd/__pycache__
Edit: /usr/lib/python3.6/site-packages/cloudinit/cmd/__pycache__/query.cpython-36.pyc (7521B)
3
\me@+ @ s d Z ddlZddlZddlZddlZddlmZ ddlmZm Z ddl
mZ ddlm
Z
mZmZ ddlmZ dZejeZdd d
Zdd Zed
ddZeeeedddZdd Zdd Zedkre dS )aT Query standardized instance metadata provided to machine, returning a JSON
structure.
Some instance-data values may be binary on some platforms, such as userdata and
vendordata. Attempt to decompress and decode UTF-8 any binary values.
Any binary values in the instance metadata will be base64-encoded and prefixed
with "ci-b64:" in the output. userdata and, where applicable, vendordata may
be provided to the machine gzip-compressed (and therefore as binary data).
query will attempt to decompress these to a string before emitting the JSON
output; if this fails, they are treated as binary.
N)EACCES)
atomic_helperutil)read_cfg_paths)convert_jinja_instance_dataget_jinja_variable_aliasrender_jinja_payload)REDACT_SENSITIVE_VALUEZqueryc C s | st jttd} | jdddddd | jdd td
t jd d | jd
ddddd | jddtdd | jddtdd | jdtddd | jddddddd | jdd td!d"d# | S )$a# Build or extend an arg parser for query 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.
)progdescriptionz-dz--debug
store_trueFz+Add verbose messages during template render)actiondefaulthelpz-iz--instance-dataz,Path to instance-data.json file. Default is
instance_data)typer z-lz--list-keyszBList query keys available at the provided instance-data
.z-uz--user-datazHPath to user-data file. Default is /var/lib/cloud/instance/user-data.txtz-vz
--vendor-datazLPath to vendor-data file. Default is /var/lib/cloud/instance/vendor-data.txtvarname?zA dot-delimited specific variable to query from instance-data. For example: v1.local_hostname. If the value is not JSON serializable, it will be base64-encoded and will contain the prefix "ci-b64:". )r nargsr z-az--alldump_allz Dump all available instance-data)r
r destr z-fz--formatformatzOptionally specify a custom output format string. Any instance-data variable can be specified between double-curly braces. For example -f "{{ v2.cloud_name }}")r r r )argparseArgumentParserNAME__doc__add_argumentstrr get_runpath)parser r /usr/lib/python3.6/query.py
get_parser% s` r" c C s> t j| dd}y
|jdS tk
r8 t j|dddS X dS )zAttempt to return a string of user-data from ud_file_path
Attempt to decode or decompress if needed.
If unable to decode the content, raw bytes will be returned.
@returns: String of uncompressed userdata if possible, otherwise bytes.
F)decodezutf-8T)quietr# N)r load_filer# UnicodeDecodeErrorZdecomp_gzip)Zud_file_pathZbdatar r r!
load_userdata} s
r' )returnc C s t j }t }| r| }nF|jd}|dkrZ|jd}t jj|rF|}q^tjd|| |}n|}|rh|}nt jj|j d}|r|} nt jj|j d} |jd}
yt
j|}W nL tt
fk
r } z,|jtkrtjd| ntjd | W Y d
d
}~X nX t
j|} yt
jt
j|
}
W n tt
fk
r4 d
}
Y nX |dkrrdt|f | d<