܍~c dZddlZddlZddlZdZdZdZejdkrdZGdd ZGd d Z dS) 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/ttyS1WindowsCOM2c4eZdZdZdZd dZdZd dZd dZdS) Cepkozb One instance of that object could be use for one or more queries to the serial port. z< {} >NcX||j}t||SN)request_pattern CepkoResultformatselfkeyr s F/usr/lib/python3/dist-packages/cloudinit/sources/helpers/cloudsigma.pygetz Cepko.get,s,  ""2O?11#66777c*|Sr )rrs rallz Cepko.all1sxxzzrcb|jd}|||S)Nz/meta/{}r rrrs rmetaz Cepko.meta4s,.55jAAxx_---rcb|jd}|||S)Nz/global_context/{}rrs rglobal_contextzCepko.global_context8s-.556JKKxx_---r)r N)r ) __name__ __module__ __qualname____doc__r rrrrrrrr$sp !O8888 ..........rrc<eZdZdZdZdZdZdZdZdZ dZ d S) 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|_dSr )request_execute raw_result_marshalresult)rr$s r__init__zCepkoResult.__init__Ds1 --//mmDO44 rctjttt}||jd| d dS)N)porttimeout writeTimeoutasciis ) serialSerial SERIAL_PORT READ_TIMEOUT WRITE_TIMEOUTwriter$encodereadlinestripdecode)r connections rr%zCepkoResult._executeIss]l    ,,W55666""$$**955< :j)) )       s  %%c4|jSr )r(__len__rs rr?zCepkoResult.__len__Vs{""$$$rc6|j|Sr )r( __getitem__)rrs rrAzCepkoResult.__getitem__Ys{&&s+++rc6|j|Sr )r( __contains__)ritems rrCzCepkoResult.__contains__\s{''---rc4|jSr )r(__iter__rs rrFzCepkoResult.__iter___s{##%%%rN) rrrr r)r%r'r?rArCrFr!rrr r =s 555 FFF %%%,,,...&&&&&rr ) r r;platformr/r2r3r1systemrr r!rrrIs     8? !!K........2#&#&#&#&#&#&#&#&#&#&r