HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux ip-10-0-8-47 6.8.0-1021-aws #23~22.04.1-Ubuntu SMP Tue Dec 10 16:31:58 UTC 2024 aarch64
User: ubuntu (1000)
PHP: 8.1.2-1ubuntu2.22
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/cloudinit/sources/__pycache__/DataSourceCloudSigma.cpython-310.pyc
o

�Ad�@s�ddlZddlmZddlmZddlmZddlmZddlm	Z	ddl
mZmZe�
e�ZGdd	�d	ej�ZeZeejffgZd
d�ZdS)�N)�	b64decode)�dmi)�log)�sources)�DataSourceHostname)�SERIAL_PORT�Cepkoc@sNeZdZdZdZdd�Zdd�Zdd�Zd	d
�Zddd
�Z	dd�Z
dd�ZdS)�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
    �
CloudSigmacCs$t�|_d|_tj�||||�dS)N�)r�cepko�ssh_public_keyr�
DataSource�__init__)�self�sys_cfg�distro�paths�r�H/usr/lib/python3/dist-packages/cloudinit/sources/DataSourceCloudSigma.pyrszDataSourceCloudSigma.__init__cCs>t�d�t�d�}|st�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 %s�
cloudsigma)�LOG�debugr�
read_dmi_data�lower)r�sys_product_namerrr�is_running_in_cloudsigma"s


z-DataSourceCloudSigma.is_running_in_cloudsigmacCs�d}|��sdSz|j��j}|d}Wnty#t�d�YdSw|�|�d�g�|_	|t
jkr5dS|�dd��d�}|�d	d�|_
d	|vrOt|j
�|_
d
|�di�vr^|dd
|_||_|d|_d
S)zj
        Metadata is the whole server context and /meta/cloud-config is used
        as userdata.
        NF�metaz+CloudSigma: Unable to read from serial portzcloudinit-dsmode�
base64_fieldsr�,zcloudinit-user-data�	cloudinit�vendor_datar
T)rr�all�result�	Exceptionrr�_determine_dsmode�get�dsmoder�DSMODE_DISABLED�split�userdata_rawr�vendordata_raw�metadatar
)rr'�server_context�server_metarrrr�	_get_data0s0
�
�

zDataSourceCloudSigma._get_datacCsdtS)z/Return the subplatform metadata source details.z
cepko (%s))r�rrrr�_get_subplatformTsz%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,r)r)r�fqdn�
resolve_ip�
metadata_only�retrrr�get_hostnameXs
z!DataSourceCloudSigma.get_hostnamecCs|jgS)N)r
r0rrr�get_public_ssh_keyscsz(DataSourceCloudSigma.get_public_ssh_keyscCs
|jdS)Nr4)r,r0rrr�get_instance_idfs
z$DataSourceCloudSigma.get_instance_idN)FFF)�__name__�
__module__�__qualname__�__doc__�dsnamerrr/r1r<r=r>rrrrr	s$
r	cCst�|t�S)zK
    Return a list of data sources that match this set of dependencies
    )r�list_from_depends�datasources)�dependsrrr�get_datasource_listtsrG)r6�base64rr rr�loggingr�cloudinit.sourcesr�$cloudinit.sources.helpers.cloudsigmarr�	getLoggerr?rrr	�DataSourceCloudSigmaNet�DEP_FILESYSTEMrErGrrrr�<module>s
X
�