a '¡Dg‡ ã@sPdZddlZddlZdZdZdZe ¡dkr0dZGdd „d ƒZGd d „d ƒZdS) a 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 éNé<é z /dev/ttyS1ZWindowsZCOM2c@s0eZdZdZdZd dd„Zdd„Zd d d „ZdS) ÚCepkozb One instance of that object could be use for one or more queries to the serial port. z< {} >ÚNcCs|dur|j}t| |¡ƒS©N)Úrequest_patternÚ CepkoResultÚformat©ÚselfÚkeyr©r úH/usr/lib/python3.9/site-packages/cloudinit/sources/helpers/cloudsigma.pyÚget*sz Cepko.getcCs| ¡Sr)r©r r r rÚall/sz Cepko.allcCs|j d¡}| ||¡S)Nz/meta/{})rr rr r r rÚmeta2s z Cepko.meta)rN)r)Ú__name__Ú __module__Ú __qualname__Ú__doc__rrrrr r r rr"s  rc@sHeZdZdZdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dS)rz­ 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. cCs"||_| ¡|_| |j¡|_dSr)ÚrequestÚ_executeÚ raw_resultÚ_marshalÚresult)r rr r rÚ__init__>s zCepkoResult.__init__c Csrz ddl}Wn.ty:}ztdƒ|‚WYd}~n d}~00|jtttd}| |j  d¡¡|  ¡  d¡  d¡S)Nrzserial support is not available)ÚportÚtimeoutZ writeTimeoutÚasciis ) ÚserialÚ ImportErrorÚNotImplementedErrorZSerialÚ SERIAL_PORTÚ READ_TIMEOUTÚ WRITE_TIMEOUTÚwriterÚencodeÚreadlineÚstripÚdecode)r r ÚeZ connectionr r rrCs  ÿzCepkoResult._executecCs(z t |¡WSty"|YS0dSr)ÚjsonÚloadsÚ ValueError)r rr r rrOs  zCepkoResult._marshalcCs |j ¡Sr)rÚ__len__rr r rr/UszCepkoResult.__len__cCs |j |¡Sr)rÚ __getitem__)r r r r rr0XszCepkoResult.__getitem__cCs |j |¡Sr)rÚ __contains__)r Úitemr r rr1[szCepkoResult.__contains__cCs |j ¡Sr)rÚ__iter__rr r rr3^szCepkoResult.__iter__N) rrrrrrrr/r0r1r3r r r rr7s r) rr,Úplatformr$r%r#Úsystemrrr r r rÚs