MOON
Server: Apache
System: Linux server.cny.com.sg 4.18.0-477.21.1.el8_8.x86_64 #1 SMP Thu Aug 10 13:51:50 EDT 2023 x86_64
User: tissuegurucom (1020)
PHP: 8.1.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //lib/python3.6/site-packages/cloudinit/sources/__pycache__/DataSourceCloudSigma.cpython-36.pyc
3

��b��@s�ddlZddlmZddlmZddlmZddlmZddlm	Z	m
Z
eje�Z
Gdd�dej�ZeZeejffgZd	d
�ZdS)�N)�	b64decode)�dmi)�log)�sources)�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
    Z
CloudSigmacCs$t�|_d|_tjj||||�dS)N�)r�cepko�ssh_public_keyr�
DataSource�__init__)�selfZsys_cfgZdistro�paths�r�*/usr/lib/python3.6/DataSourceCloudSigma.pyr
szDataSourceCloudSigma.__init__cCs>tjd�tjd�}|s&tjd�dStjd|�d|j�kS)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)rZsys_product_namerrr�is_running_in_cloudsigma!s


z-DataSourceCloudSigma.is_running_in_cloudsigmacCs�d}|j�sdSy|jj�j}|d}Wntk
rFtjd�dSX|j|jd�g�|_	|t
jkrjdS|jdd�jd�}|jd	d�|_
d	|kr�t|j
�|_
d
|jdi�kr�|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�	cloudinitZvendor_datarT)rr
�all�result�	ExceptionrrZ_determine_dsmode�get�dsmoderZDSMODE_DISABLED�splitZuserdata_rawrZvendordata_raw�metadatar)rrZserver_contextZserver_metarrrr�	_get_data/s,


zDataSourceCloudSigma._get_datacCsdtS)z/Return the subplatform metadata source details.z
cepko (%s))r)rrrr�_get_subplatformSsz%DataSourceCloudSigma._get_subplatformFcCs<tjd|jd�r$|jddd�S|jdjd�dSdS)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�-r)�re�matchr r)rZfqdnZ
resolve_ipZ
metadata_onlyrrr�get_hostnameWsz!DataSourceCloudSigma.get_hostnamecCs|jgS)N)r)rrrr�get_public_ssh_keysasz(DataSourceCloudSigma.get_public_ssh_keyscCs
|jdS)Nr%)r )rrrr�get_instance_iddsz$DataSourceCloudSigma.get_instance_idN)FFF)�__name__�
__module__�__qualname__�__doc__Zdsnamer
rr!r"r)r*r+rrrrrs$

rcCstj|t�S)zK
    Return a list of data sources that match this set of dependencies
    )rZlist_from_depends�datasources)Zdependsrrr�get_datasource_listrsr1)r'�base64rrrrZloggingrZcloudinit.cs_utilsrrZ	getLoggerr,rrrZDataSourceCloudSigmaNetZDEP_FILESYSTEMr0r1rrrr�<module>s
W