�
�ft � �� � d dl Z d dlZd dlmZ d dlmZmZ d dlmZ d dl m
Z
mZ e j e
� Z G d� dej � ZeZeej$ ffgZd� Zy) � N)� b64decode)�dmi�sources)�DataSourceHostname)�SERIAL_PORT�Cepkoc �J � e Zd ZdZdZd� Zed� � Zd� Zd� Z dd�Z
d� Zd � Zy
)�DataSourceCloudSigmaz�
Uses cepko in order to gather the server context from the VM.
For more information about CloudSigma's Server Context:
http://cloudsigma-docs.readthedocs.org/en/latest/server_context.html
�
CloudSigmac �t � t � | _ d| _ t j j | |||� y )N� )r �cepko�ssh_public_keyr �
DataSource�__init__)�self�sys_cfg�distro�pathss �H/usr/lib/python3/dist-packages/cloudinit/sources/DataSourceCloudSigma.pyr zDataSourceCloudSigma.__init__ s- � ��W��
� ������#�#�D�'�6�5�A� c �� � t j d� t j d� } | st j d� yt j d| � d| j � v S )z
Uses dmi data to detect if this instance of cloud-init is running
in the CloudSigma's infrastructure.
z0determining hypervisor product name via dmi datazsystem-product-namez-system-product-name not available in dmi dataFzdetected hypervisor as %s�
cloudsigma)�LOG�debugr �
read_dmi_data�lower)�sys_product_names r � ds_detectzDataSourceCloudSigma.ds_detect! s[ � � � � �D�E��,�,�-B�C����I�I�E�F��� � �-�/?�@��/�5�5�7�7�7r c �( � d} | j j � j }|d }| j
|j d� g� | _ |t j k( ry|j dd� j d� }|j d d� | _ d |v rt | j � | _ d
|j di � v r
|d d
| _ || _ |d | _ y
# t $ r t j d� Y yw xY w)zj
Metadata is the whole server context and /meta/cloud-config is used
as userdata.
N�metaz+CloudSigma: Unable to read from serial portFzcloudinit-dsmode�
base64_fieldsr
�,zcloudinit-user-data� cloudinit�vendor_datar T)r �all�result� Exceptionr r �_determine_dsmode�get�dsmoder �DSMODE_DISABLED�split�userdata_rawr �vendordata_raw�metadatar )r r+ �server_context�server_metar" |