ó oBú]c@s‹dZddlZddlZddlmZdZdZdZejƒdkr[dZnd e fd „ƒYZ d e fd „ƒYZ dS( 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_patternt CepkoResulttformat(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__RRR R 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 ( RtSerialt SERIAL_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.pyts