name : DataSourceCloudSigma.cpython-39.pyc
a

'�Dgt�@s�ddlZddlZddlmZddlmZmZddlmZddl	m
Z
mZe�e
�ZGdd�dej�ZeZeejffgZdd	�ZdS)
�N)�	b64decode)�dmi�sources)�DataSourceHostname)�SERIAL_PORT�Cepkoc@sReZdZdZdZdd�Zedd��Zdd�Zd	d
�Z	ddd
�Z
dd�Zdd�ZdS)�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
    Z
CloudSigmacCs$t�|_d|_tj�||||�dS)N�)r�cepko�ssh_public_keyr�
DataSource�__init__)�selfZsys_cfgZdistro�paths�r�J/usr/lib/python3.9/site-packages/cloudinit/sources/DataSourceCloudSigma.pyr
szDataSourceCloudSigma.__init__cCs>t�d�t�d�}|s&t�d�dSt�d|�d|��vS)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 %sZ
cloudsigma)�LOG�debugrZ
read_dmi_data�lower)Zsys_product_namerrr�	ds_detect!s


zDataSourceCloudSigma.ds_detectcCs�d}z|j��j}|d}Wnty:t�d�YdS0|�|�d�g�|_|t	j
kr^dS|�dd��d�}|�d	d�|_d	|vr�t
|j�|_d
|�di�vr�|dd
|_||_|d|_d
S)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�	cloudinitZvendor_datarT)r
�all�result�	ExceptionrrZ_determine_dsmode�get�dsmoderZDSMODE_DISABLED�splitZuserdata_rawrZvendordata_raw�metadatar)rrZserver_contextZserver_metarrrr�	_get_data0s*

�

zDataSourceCloudSigma._get_datacCsdtS)z/Return the subplatform metadata source details.z
cepko (%s))r�rrrr�_get_subplatformRsz%DataSourceCloudSigma._get_subplatformFcCsDt�d|jd�r&|jddd�}n|jd�d�d}t|d�S)	z�
        Cleans up and uses the server's name if the latter is set. Otherwise
        the first part from uuid is being used.
        z^[A-Za-z0-9 -_\.]+$�nameN�=�uuid�-rF)�re�matchr rr)rZfqdnZ
resolve_ipZ
metadata_only�retrrr�get_hostnameVsz!DataSourceCloudSigma.get_hostnamecCs|jgS)N)rr"rrr�get_public_ssh_keysasz(DataSourceCloudSigma.get_public_ssh_keyscCs
|jdS)Nr&)r r"rrr�get_instance_iddsz$DataSourceCloudSigma.get_instance_idN)FFF)
�__name__�
__module__�__qualname__�__doc__Zdsnamer
�staticmethodrr!r#r+r,r-rrrrrs
"
rcCst�|t�S)zK
    Return a list of data sources that match this set of dependencies
    )rZlist_from_depends�datasources)Zdependsrrr�get_datasource_listrsr4)Zloggingr(�base64rrrrZcloudinit.sourcesrZ$cloudinit.sources.helpers.cloudsigmarrZ	getLoggerr.rrrZDataSourceCloudSigmaNetZDEP_FILESYSTEMr3r4rrrr�<module>s
W
�

© 2025 Cubjrnet7