Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/cloudinit/sources/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/cloudinit/sources/__pycache__/DataSourceOracle.cpython-310.pyc
o

}��f�B�@s�dZddlZddlZddlZddlZddlZddlmZddlm	Z	m
Z
mZddlm
Z
mZmZmZmZddlmZddlmZmZmZmZddlmZe�e�Zd	d
iZdZdZ e d
Z!dZ"ddiZ#edd�Z$Gdd�dej%�Z&deddfdd�Z'Gdd�dej(�Z)Gdd�de)�Z*de
e+fdd�Z,de-fdd �Z.d!e+de/fd"d#�Z0d!e+de
e	e+e+ffd$d%�Z1d
e)j2e)j3d&�d'e-de
e$fd(d)�Z4e)ej5ffe*ej5ej6ffgZ7d*d+�Z8ed,kr�ddl9Z9d-Z:e9j;e:d.�Z<e<�=�e>e
�?e4�e.�d/���dSdS)0a3Datasource for Oracle (OCI/Oracle Cloud Infrastructure)

Notes:
 * This datasource does not support OCI Classic. OCI Classic provides an EC2
   lookalike metadata service.
 * The UUID provided in DMI data is not the same as the meta-data provided
   instance-id, but has an equivalent lifespan.
 * We do need to support upgrade from an instance that cloud-init
   identified as OpenStack.
 * Bare metal instances use iSCSI root, virtual machine instances do not.
 * Both bare metal and virtual machine instances provide a chassis-asset-tag of
   OracleCloud.com.
�N)�
namedtuple)�Dict�Optional�Tuple)�
atomic_helper�dmi�net�sources�util)�
NetworkConfig)�cmdline�	ephemeral�get_interfaces_by_mac�is_netfail_master)�wait_for_url�configure_secondary_nicsFzOracleCloud.comz&http://169.254.169.254/opc/v{version}/z{path}/i(#�
Authorizationz
Bearer Oracle�OpcMetadataz version instance_data vnics_datac@seZdZdZdefdd�ZdS)�KlibcOracleNetworkConfigSourcez�Override super class to lower the applicability conditions.

    If any `/run/net-*.cfg` files exist, then it is applicable. Even if
    `/run/initramfs/open-iscsi.interface` does not exist.
    �returncCs
t|j�S)zOverride is_applicable)�bool�_files��self�r�D/usr/lib/python3/dist-packages/cloudinit/sources/DataSourceOracle.py�
is_applicable:�
z,KlibcOracleNetworkConfigSource.is_applicableN)�__name__�
__module__�__qualname__�__doc__rrrrrrr3sr�network_configrcCsd|vrdS|ddvrt�d|d�dSt�}|ddkrJdd�|dD�D]}|d	d
krGd|vrG|d}|�|�}|s@q(t|�rG|d=q(dS|ddkr�|�d
i���D]/\}}d|vr�|�di��d�}|r�|�|�}|ssqXt|�r�|dd=|d=||dd<qXdSdS)aP
    Search network config physical interfaces to see if any of them are
    a netfailover master.  If found, we prevent matching by MAC as the other
    failover devices have the same MAC but need to be ignored.

    Note: we rely on cloudinit.net changes which prevent netfailover devices
    from being present in the provided network config.  For more details about
    netfailover devices, refer to cloudinit.net module.

    :param network_config
       A v1 or v2 network config dict with the primary NIC, and possibly
       secondary nic configured.  This dict will be mutated.

    �versionN)��z+Ignoring unknown network config version: %sr$cSsg|]}d|vr|�qS)�typer)�.0�crrr�
<listcomp>[sz,_ensure_netfailover_safe.<locals>.<listcomp>�configr&�physical�mac_addressr%�	ethernets�match�
macaddresszset-name�name)�LOG�debugr�getr�items)r"�mac_to_name�cfg�mac�cur_name�_�macaddrrrr�_ensure_netfailover_safe?sH�
��


��r;cs�eZdZUdZdZejjejjejj	ejj
fZeejdfe
d<dZdZdZ�fdd	�Zd
eddf�fdd
�Zdefdd�Zedefdd��Zdd�Zdefdd�Zdd�Zdefdd�Zdefdd�Zedd��Zd"defd d!�Z �Z!S)#�DataSourceOracle�OracleN.�network_config_sourcesT��csttt|�j|g|�Ri|��d|_t�t�|d|jgi�tg�|_	t
�|_gdd�|_|�
�}|j|_|j|_dS)N�
datasourcer$�r*r#)�superr<�__init__�_vnics_datar
�
mergemanydict�get_cfg_by_path�dsname�BUILTIN_DS_CONFIG�ds_cfgr�_network_config_source�_network_config�get_url_params�max_wait_seconds�url_max_wait�timeout_seconds�url_timeout)r�sys_cfg�args�kwargs�
url_params��	__class__rrrD�s��zDataSourceOracle.__init__�ci_pkl_versionrcsXt��|�t|d�st|dd�t|d�st|dt��t|d�s*gdd�|_dSdS)NrErKrLr$rB)rC�	_unpickle�hasattr�setattrrrL)rrXrVrrrY�s

�
�zDataSourceOracle._unpicklecCst|j�dg��S)Nr*)rrLr3rrrr�_has_network_config��z$DataSourceOracle._has_network_configcCst�S)z@Check platform environment to report if this datasource may run.)�_is_platform_viablerrrr�	ds_detect�szDataSourceOracle.ds_detectcCs t�|_|jrtj|jt��tj	ddd�t
d�d�}nt��}|�
�}|j�dtd�}|�t|p4||j|jd�}Wd�n1sEwY|sNdS|j}|_tj	|jd	�|_|j|_|d
|dd|d
|dd�|_d|vr�|d�d�}|r�t�|�|_|d�d�|jd<dS)Nr%�instance�r#�path)�url�headers)�iface�connectivity_url_datar��fetch_vnics_data�max_wait�timeoutF)r#�	ociAdName�idr�hostname�displayName)zavailability-zonezinstance-idzlaunch-indexzlocal-hostnamer0�metadata�	user_data�ssh_authorized_keys�public_keysT)�_read_system_uuid�system_uuid�perform_dhcp_setupr
�EphemeralDHCPv4�distror�find_fallback_nic�METADATA_PATTERN�format�
V2_HEADERSr
�nullcontext�_is_iscsi_rootrJr3rI�read_opc_metadatarOrQ�
instance_data�_crawled_metadata�
METADATA_ROOTr#�metadata_address�
vnics_datarEro�base64�	b64decode�userdata_raw)r�network_context�fetch_primary_nic�fetch_secondary_nics�fetched_metadata�datarprrr�	_get_data�sV��	
�����
�zDataSourceOracle._get_datacCst�|j�S)z�quickly check (local only) if self.instance_id is still valid

        On Oracle, the dmi-provided system uuid differs from the instance-id
        but has the same life-span.)r	�instance_id_matches_system_uuidrt)rrRrrr�check_instance_id�sz"DataSourceOracle.check_instance_idcCst�|j�d��S)Nrr)r	�normalize_pubkey_dataror3rrrr�get_public_ssh_keys�r]z$DataSourceOracle.get_public_ssh_keyscC�
|j��S)z)Return whether we are on a iscsi machine.)rKrrrrrr}�rzDataSourceOracle._is_iscsi_rootcCr��N)rK�
render_configrrrr�_get_iscsi_config�s
z"DataSourceOracle._get_iscsi_configcCs�|��r|jSd}|��r|��|_|��st�d�d}|j�dtd�}|s*|rAz|�	|�Wnt
y@t�td�Ynwt
|j�|jS)z�Network config is read from initramfs provided files

        Priority for primary network_config selection:
        - iscsi
        - imds

        If none is present, then we fall back to fallback configuration.
        FzLCould not obtain network configuration from initramfs. Falling back to IMDS.Trz+Failed to parse IMDS network configuration!)r\rLr}r�r1�warningrJr3rI�!_add_network_config_from_opc_imds�	Exceptionr
�logexcr;)r�set_primary�
set_secondaryrrrr"�s2

����
	zDataSourceOracle.network_configFr�cCsV|jdurt�d�dS|sd|jdvrt�d�dSt�}|r$|jn|jdd�}t|�D]y\}}|o8|dk}|d��}||vrJt�d|�q/||}t�|d	�}	|jd
dkr�|rcddi}
n
d
|d�d|	j	��d�}
|d|t
|
gd�}|jd�|�q/|jd
dkr�t
d|id|d�}|s�|d�d|	j	��g|d<||jd|<q/dS)a�Generate primary and/or secondary NIC config from IMDS and merge it.

        It will mutate the network config to include the secondary VNICs.

        :param set_primary: If True set primary interface.
        :raises:
            Exceptions are not handled within this function.  Likely
            exceptions are KeyError/IndexError
            (if the IMDS returns valid JSON with unexpected contents).
        Nz#NIC data is UNSET but should not be�nicIndexrz\VNIC metadata indicates this is a bare metal machine; skipping secondary VNIC configuration.r$�macAddrz)Interface with MAC %s not found; skipping�subnetCidrBlockr#r&�dhcp�static�	privateIp�/)r&�addressr+)r0r&r,�mtu�subnetsr*r%r/F)r�r.�dhcp6�dhcp4�	addressesr-)rEr1r�r�	enumerate�lower�	ipaddress�
ip_networkrL�	prefixlen�MTU�append)rr��interfaces_by_macr��index�	vnic_dict�
is_primaryr,r0�network�subnet�interface_configrrrr�s\

��
������z2DataSourceOracle._add_network_config_from_opc_imds)F)"rrr rHrtr	�NetworkConfigSource�CMD_LINE�
SYSTEM_CFG�DS�	INITRAMFSr>r�__annotations__rurOrQrD�intrYrr\�staticmethodr_r�r�r�r}�dictr��propertyr"r��
__classcell__rrrVrr<ss0
�
6
-r<c@seZdZdZdS)�DataSourceOracleNetFN)rrr rurrrrr�nsr�cCst�d�}|durdS|��S)Nzsystem-uuid)r�
read_dmi_datar�)�sys_uuidrrrrsrs
rscCst�d�}|tkS)Nzchassis-asset-tag)rr��CHASSIS_ASSET_TAG)�	asset_tagrrrr^ws
r^rccCs|�d�rdSdS)Nzhttp://169.254.169.254/opc/v2r%r$)�
startswith�rcrrr�_url_version|r]r�cCst|�dkrtSdS)Nr%)r�r{r�rrr�_headers_cb�sr�rgrhcCs�tjddd�tjddd�g}t��}t|||tdd�\}}|s&t�d�dSt�	|�
d	��}t|�}d}	|r]ttj|d
d�g|t��||tdd�\}
}|
rXt�	|�
d	��}	nt�d�t|||	�S)aoFetch metadata from the /opc/ routes.

    :return:
        A namedtuple containing:
          The metadata version as an integer
          The JSON-decoded value of the instance data endpoint on the IMDS
          The JSON-decoded value of the vnics data endpoint if
            `fetch_vnics_data` is True, else None
        or None if fetching metadata failed

    r%r`rar$r)rirj�
headers_cb�
sleep_timezFailed to fetch IMDS metadata!Nzutf-8�vnicsz+Failed to fetch IMDS network configuration!)
ryrz�time�	monotonicrr�r1r��json�loads�decoder�r)rhrirj�urls�
start_time�instance_url�instance_responser�metadata_versionr��	vnics_url�vnics_responserrrr~�s:�
�

�
r~cCst�|t�Sr�)r	�list_from_depends�datasources)�dependsrrr�get_datasource_list�sr��__main__z�
        Query Oracle Cloud metadata and emit a JSON object with two keys:
        `read_opc_metadata` and `_is_platform_viable`.  The values of each are
        the return values of the corresponding functions defined in
        DataSourceOracle.py.)�description)r~r^)@r!r�r�r��loggingr��collectionsr�typingrrr�	cloudinitrrrr	r
�cloudinit.distros.networkingr�
cloudinit.netrr
rr�cloudinit.url_helperr�	getLoggerrr1rIr�r�ryr�r{r�KlibcNetworkConfigSourcerr;�
DataSourcer<r��strrsrr^r�r�r�rOrQr~�DEP_FILESYSTEM�DEP_NETWORKr�r��argparser��ArgumentParser�parser�
parse_args�print�
json_dumpsrrrr�<module>sv
�
4|��
�
<���
����

Spamworldpro Mini