403Webshell
Server IP : 3.96.16.70  /  Your IP : 216.73.216.15
Web Server : Apache
System : Linux ip-172-31-26-103.ca-central-1.compute.internal 6.1.163-186.299.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Feb 24 16:35:42 UTC 2026 x86_64
User : ec2-user ( 1000)
PHP Version : 8.4.18
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3.9/site-packages/cloudinit/sources/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3.9/site-packages/cloudinit/sources/__pycache__/DataSourceOracle.cpython-39.opt-1.pyc
a

�½b�5�@s^dZddlZddlmZddlmZddlmZddl	m
Z
ddl	mZddl	m
Z
mZmZdd	lmZmZmZmZdd
lmZmZe�e�ZddiZd
ZdZedZdZddiZ edd�Z!dd�Z"Gdd�dej#�Z$dd�Z%dd�Z&dd�Z'dd�e(d�d d!�Z)e$ej*ffgZ+d"d#�Z,ed$k�rZddl-Z-d%Z.e-j/e.d&�Z0e0�1�e2e�3e)�e&�d'���dS)(a3Datasource 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)�suppress)�Tuple)�dmi)�log)�net�sources�util)�cmdline�dhcp�get_interfaces_by_mac�is_netfail_master)�UrlError�readurl�configure_secondary_nicsFzOracleCloud.comz&http://169.254.169.254/opc/v{version}/z{path}/i(#Z
Authorizationz
Bearer Oracle�OpcMetadataz version instance_data vnics_datacCsd|vrdS|ddvr,t�d|d�dSt�}|ddkr�dd�|dD�D]@}|d	d
krPd|vrP|d}|�|�}|s�qPqPt|�rP|d=qPn||ddk�r|�d
i���D]\\}}d|vr�|�di��d�}|r�|�|�}|s�q�q�t|�r�|dd=|d=||dd<q�dS)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: %srcSsg|]}d|vr|�qS)�type�)�.0�crr�F/usr/lib/python3.9/site-packages/cloudinit/sources/DataSourceOracle.py�
<listcomp>M�z,_ensure_netfailover_safe.<locals>.<listcomp>�configr�physical�mac_addressr�	ethernets�match�
macaddresszset-name�name)�LOG�debugr�getr
�items)�network_configZmac_to_nameZcfgZmacZcur_name�_Zmacaddrrrr�_ensure_netfailover_safe1s>�



r)cs�eZdZUdZdZdZejjejj	ejj
ejjfZe
ejdfed<ejZ�fdd�Zdd�Zd	d
�Zdd�Zd
d�Zedd��Zdd�Z�ZS)�DataSourceOracleZOracleN.�network_config_sourcescsHtt|�j|g|�Ri|��d|_t�t�|d|jgi�tg�|_	dS)NZ
datasource)
�superr*�__init__�_vnics_datar	Z
mergemanydictZget_cfg_by_path�dsname�BUILTIN_DS_CONFIG�ds_cfg)�self�sys_cfg�args�kwargs��	__class__rrr-ss��zDataSourceOracle.__init__cCst�S)z@Check platform environment to report if this datasource may run.)�_is_platform_viable�r2rrrr8~sz$DataSourceOracle._is_platform_viablecCs|��sdSt�|_|j�dtd�}t�}t�sTtj	t
��tj
ddd�td�d�}|�t|d�}Wd�n1sx0Y|j}|_tj
|jd	�|_|j|_|d
|dd|d
|dd�|_d|v�r|d�d�}|r�t�|�|_|d�d�|jd<dS)NFrr�instance�r�path)�url�headers)ZifaceZconnectivity_url_data��fetch_vnics_data)rZ	ociAdName�idr�hostnameZdisplayName)zavailability-zonezinstance-idzlaunch-indexzlocal-hostnamer"�metadata�	user_dataZssh_authorized_keys�public_keysT)r8�_read_system_uuid�system_uuidr1r%r0�noop�_is_iscsi_rootrZEphemeralDHCPv4rZfind_fallback_nic�METADATA_PATTERN�format�
V2_HEADERS�read_opc_metadata�
instance_dataZ_crawled_metadata�
METADATA_ROOTrZmetadata_address�
vnics_datar.rC�base64Z	b64decodeZuserdata_raw)r2r@Znetwork_contextZfetched_metadata�datarDrrr�	_get_data�sL����$��
�
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.)rZinstance_id_matches_system_uuidrG)r2r3rrr�check_instance_id�sz"DataSourceOracle.check_instance_idcCst�|j�d��S)NrE)rZnormalize_pubkey_datarCr%r9rrr�get_public_ssh_keys�sz$DataSourceOracle.get_public_ssh_keyscCsv|jtjkrpt��|_|js(|j��|_|j�dt	d�rfz|�
�Wntydt�
td�Yn0t|j�|jS)z�Network config is read from initramfs provided files

        If none is present, then we fall back to fallback configuration.
        rz0Failed to parse secondary network configuration!)�_network_configr�UNSETr
�read_initramfs_configZdistroZgenerate_fallback_configr1r%r0�!_add_network_config_from_opc_imds�	Exceptionr	�logexcr#r)r9rrrr'�s 
��

zDataSourceOracle.network_configc	Cs�|jdurt�d�dSd|jdvr4t�d�dSt�}|jdd�D]�}|d��}||vrnt�d|�qH||}|jd	dkr�d
|dd�}|jd
�|d|t|gd��qH|jd	dkrH|dgtddd|id�|jd|<qHdS)avGenerate secondary NIC config from IMDS and merge it.

        The primary NIC configuration should not be modified based on the IMDS
        values, as it should continue to be configured for DHCP.  As such, this
        uses the instance's network config dict which is expected to have the
        primary NIC configuration already present.
        It will mutate the network config to include the secondary VNICs.

        :raises:
            Exceptions are not handled within this function.  Likely
            exceptions are KeyError/IndexError
            (if the IMDS returns valid JSON with unexpected contents).
        Nz-Secondary NIC data is UNSET but should not beZnicIndexrz\VNIC metadata indicates this is a bare metal machine; skipping secondary VNIC configuration.rZmacAddrz)Interface with MAC %s not found; skippingrZstaticZ	privateIp)r�addressrr)r"rr�mtu�subnetsrFr!)�	addressesr]Zdhcp4Zdhcp6r r)	r.r#Zwarningr�lowerr$rV�append�MTU)r2Zinterfaces_by_macZ	vnic_dictrr"ZsubnetrrrrY�sH

���
��	�z2DataSourceOracle._add_network_config_from_opc_imds)�__name__�
__module__�__qualname__r/rGZvendordata_purerZNetworkConfigSourceZCMD_LINEZDSZ	INITRAMFSZ
SYSTEM_CFGr+r�__annotations__rWrVr-r8rSrTrU�propertyr'rY�
__classcell__rrr6rr*es"
�2
!r*cCst�d�}|durdS|��S)Nzsystem-uuid)r�
read_dmi_datar`)Zsys_uuidrrrrF&s
rFcCst�d�}|tkS)Nzchassis-asset-tag)rri�CHASSIS_ASSET_TAG)Z	asset_tagrrrr8+s
r8cCstt���S�N)�boolr
rXrrrrrI0srIr?cs�d�tttd��fdd�}d}z||dd�}Wn"tyPd}||dd�}Yn0d}|r�z||d	d�}Wnty�t�td
�Yn0t|||�S)aCFetch 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

    r)�metadata_versionr<�returncs*ttj||d�|dkrtnd�d�j��S)Nr;r)r=r>�retries)rrJrKrLZ	_responseZjson)rmr<�rorr�_fetchDs
�z!read_opc_metadata.<locals>._fetchr:)r<rNZvnicsz0Failed to fetch secondary network configuration!)�int�str�dictrr	r[r#r)r@rqrmrNrPrrprrM4s"�
rMcCst�|t�Srk)rZlist_from_depends�datasources)Zdependsrrr�get_datasource_listdsrv�__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)rMr8)4�__doc__rQ�collectionsr�
contextlibrrH�typingrZ	cloudinitrrZloggingrrr	Z
cloudinit.netr
rrr
Zcloudinit.url_helperrrZ	getLoggerrcr#r0rjrOrJrbrLrr)Z
DataSourcer*rFr8rIrlrMZDEP_FILESYSTEMrurv�argparserx�ArgumentParser�parser�
parse_args�printZ
json_dumpsrrrr�<module>sP
�
4B+
�
���

Youez - 2016 - github.com/yon3zu
LinuXploit