Current File : //usr/lib/python2.7/site-packages/cloudinit/cs_utils.pyc
�
oB�]c@s�dZddlZddlZddlmZdZdZdZej�dkr[dZnd	e	fd
��YZ
de	fd��YZdS(
s
cepko implements easy-to-use communication with CloudSigma's VMs through
a virtual serial port without bothering with formatting the messages
properly nor parsing the output with the specific and sometimes
confusing shell tools for that purpose.

Having the server definition accessible by the VM can ve useful in various
ways. For example it is possible to easily determine from within the VM,
which network interfaces are connected to public and which to private network.
Another use is to pass some data to initial VM setup scripts, like setting the
hostname to the VM name or passing ssh public keys through server meta.

For more information take a look at the Server Context section of CloudSigma
API Docs: http://cloudsigma-docs.readthedocs.org/en/latest/server_context.html
i����N(tseriali<i
s
/dev/ttyS1tWindowstCOM2tCepkocBsDeZdZdZddd�Zd�Zdd�Zdd�ZRS(sb
    One instance of that object could be use for one or more
    queries to the serial port.
    s<
{}
>tcCs+|dkr|j}nt|j|��S(N(tNonetrequest_patterntCepkoResulttformat(tselftkeyR((s6/usr/lib/python2.7/site-packages/cloudinit/cs_utils.pytget,scCs
|j�S(N(R(R	((s6/usr/lib/python2.7/site-packages/cloudinit/cs_utils.pytall1scCs"|jjd�}|j||�S(Ns/meta/{}(RRR(R	R
R((s6/usr/lib/python2.7/site-packages/cloudinit/cs_utils.pytmeta4scCs"|jjd�}|j||�S(Ns/global_context/{}(RRR(R	R
R((s6/usr/lib/python2.7/site-packages/cloudinit/cs_utils.pytglobal_context8sN(	t__name__t
__module__t__doc__RRRRR
R(((s6/usr/lib/python2.7/site-packages/cloudinit/cs_utils.pyR%s	RcBsMeZdZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	RS(s�
    CepkoResult executes the request to the virtual serial port as soon
    as the instance is initialized and stores the result in both raw and
    marshalled format.
    cCs1||_|j�|_|j|j�|_dS(N(trequestt_executet
raw_resultt_marshaltresult(R	R((s6/usr/lib/python2.7/site-packages/cloudinit/cs_utils.pyt__init__Cs	cCsStjdtdtdt�}|j|jjd��|j�j	d�j
d�S(NtportttimeouttwriteTimeouttasciis
(RtSerialtSERIAL_PORTtREAD_TIMEOUTt
WRITE_TIMEOUTtwriteRtencodetreadlinetstriptdecode(R	t
connection((s6/usr/lib/python2.7/site-packages/cloudinit/cs_utils.pyRHs
	cCs*ytj|�SWntk
r%|SXdS(N(tjsontloadst
ValueError(R	R((s6/usr/lib/python2.7/site-packages/cloudinit/cs_utils.pyROs
cCs
|jj�S(N(Rt__len__(R	((s6/usr/lib/python2.7/site-packages/cloudinit/cs_utils.pyR)UscCs|jj|�S(N(Rt__getitem__(R	R
((s6/usr/lib/python2.7/site-packages/cloudinit/cs_utils.pyR*XscCs|jj|�S(N(Rt__contains__(R	titem((s6/usr/lib/python2.7/site-packages/cloudinit/cs_utils.pyR+[scCs
|jj�S(N(Rt__iter__(R	((s6/usr/lib/python2.7/site-packages/cloudinit/cs_utils.pyR-^s(
RRRRRRR)R*R+R-(((s6/usr/lib/python2.7/site-packages/cloudinit/cs_utils.pyR=s						(RR&tplatformt	cloudinitRRRRtsystemtobjectRR(((s6/usr/lib/python2.7/site-packages/cloudinit/cs_utils.pyt<module>s