x[h xdZddlZddlZdZdZdZej dk(rdZGdd ZGd d Zy) 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/ttyS1WindowsCOM2c*eZdZdZdZddZdZddZy) Cepkozb One instance of that object could be use for one or more queries to the serial port. z< {} >NcR| |j}t|j|SN)request_pattern CepkoResultformatselfkeyr s F/usr/lib/python3/dist-packages/cloudinit/sources/helpers/cloudsigma.pygetz Cepko.get*s)  ""22O?11#677c"|jSr )rrs rallz Cepko.all/sxxzrc\|jjd}|j||S)Nz/meta/{})r r rrs rmetaz Cepko.meta2s)..55jAxx_--r)N)r)__name__ __module__ __qualname____doc__r rrrrrrr"s !O8 .rrc:eZdZdZdZdZdZdZdZdZ dZ y ) r z 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. c|||_|j|_|j|j|_yr )request_execute raw_result_marshalresult)rr!s r__init__zCepkoResult.__init__>s* --/mmDOO4 rc6 ddl}|jtt t }|j|jjd|jjdjdS#t$r}td|d}~wwxYw)Nrzserial support is not available)porttimeout writeTimeoutasciis ) serial ImportErrorNotImplementedErrorSerial SERIAL_PORT READ_TIMEOUT WRITE_TIMEOUTwriter!encodereadlinestripdecode)rr,e connections rr"zCepkoResult._executeCs P ]]l#  ,,W56""$**95<> B BBcP tj|S#t$r|cYSwxYwr )jsonloads ValueError)rr#s rr$zCepkoResult._marshalOs+ ::j) )   s  %%c6|jjSr )r%__len__rs rr?zCepkoResult.__len__Us{{""$$rc8|jj|Sr )r% __getitem__)rrs rrAzCepkoResult.__getitem__Xs{{&&s++rc8|jj|Sr )r% __contains__)ritems rrCzCepkoResult.__contains__[s{{''--rc6|jjSr )r%__iter__rs rrFzCepkoResult.__iter__^s{{##%%rN) rrrrr&r"r$r?rArCrFrrrr r 7s+ 5 F %,.&rr ) rr;platformr1r2r0systemrr rrrrIsM    8?? !K..*(&(&r