404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@3.12.153.240: ~ $
3

\�meX:�@s�dZddlZddlZddlZddlmZddlmZmZddl	m
Z
mZmZm
Z
mZddlmZddlmZmZmZmZddlmZmZeje�Zd	d
iZdZdZed
ZdZ ddiZ!edd�Z"Gdd�dej#�Z$edd�dd�Z%Gdd�de
j&�Z'ee(d�dd�Z)e*d�dd�Z+d-e,e(e,e-d �d!d"�Z.d
d#�e*e"d$�d%d&�Z/e'e
j0ffgZ1d'd(�Z2ed)k�r�ddl3Z3d*Z4e3j5e4d+�Z6e6j7�e8e
j9e/�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)�Optional�Tuple)�
atomic_helper�dmi�net�sources�util)�
NetworkConfig)�cmdline�	ephemeral�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_datac@seZdZdZed�dd�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�&/usr/lib/python3.6/DataSourceOracle.py�
is_applicable8sz,KlibcOracleNetworkConfigSource.is_applicableN)�__name__�
__module__�__qualname__�__doc__rrrrrrr1sr)�network_configrcCsd|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)�typer)�.0�crrr�
<listcomp>Ysz,_ensure_netfailover_safe.<locals>.<listcomp>�configr#�physical�mac_address�	ethernets�match�
macaddresszset-name�name)r!r")�LOG�debugr
�getr�items)rZmac_to_nameZcfgZmacZcur_name�_Zmacaddrrrr�_ensure_netfailover_safe=s<



r3cs�eZdZUdZdZdZejjejj	ejj
ejjfZe
ejdfgdd�Ze�fdd�Zed�d	d
�Zeed�dd��Zd
d�Zed�dd�Zdd�Zed�dd�Zed�dd�Zedd��Zded�dd�Z�ZS)�DataSourceOracleZOracleN.r!)r'r csJtt|�j|f|�|�d|_tjtj|d|jgi�tg�|_	t
�|_dS)NZ
datasource)�superr4�__init__�_vnics_datar	Z
mergemanydictZget_cfg_by_path�dsname�BUILTIN_DS_CONFIG�ds_cfgr�_network_config_source)r�sys_cfg�args�kwargs)�	__class__rrr6s
zDataSourceOracle.__init__)rcCst|jjdg��S)Nr')r�_network_configr0)rrrr�_has_network_config�sz$DataSourceOracle._has_network_configcCst�S)z@Check platform environment to report if this datasource may run.)�_is_platform_viablerrrr�	ds_detect�szDataSourceOracle.ds_detectc
Cs�t�|_tj|jtj�tjddd�t	d�d�}|j
�}|jjdt
d�}|�t|pX|d�}WdQRX|j}|_tj|jd�|_|j|_|d	|d
d|d|d
d�|_d|kr�|djd�}|r�tj|�|_|djd�|jd<dS)Nr"�instance)r �path)�url�headers)ZifaceZconnectivity_url_datar)�fetch_vnics_data)r Z	ociAdName�idrZhostnameZdisplayName)zavailability-zonezinstance-idzlaunch-indexzlocal-hostnamer-�metadata�	user_dataZssh_authorized_keys�public_keysT)�_read_system_uuid�system_uuidrZEphemeralDHCPv4ZdistrorZfind_fallback_nic�METADATA_PATTERN�format�
V2_HEADERS�_is_iscsi_rootr:r0r9�read_opc_metadata�
instance_dataZ_crawled_metadata�
METADATA_ROOTr Zmetadata_address�
vnics_datar7rJ�base64Z	b64decodeZuserdata_raw)rZnetwork_contextZfetch_primary_nicZfetch_secondary_nicsZfetched_metadata�datarKrrr�	_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_uuidrN)rr<rrr�check_instance_id�sz"DataSourceOracle.check_instance_idcCstj|jjd��S)NrL)rZnormalize_pubkey_datarJr0)rrrr�get_public_ssh_keys�sz$DataSourceOracle.get_public_ssh_keyscCs
|jj�S)z)Return whether we are on a iscsi machine.)r;r)rrrrrR�szDataSourceOracle._is_iscsi_rootcCs
|jj�S)N)r;Z
render_config)rrrr�_get_iscsi_config�sz"DataSourceOracle._get_iscsi_configcCs�|j�r|jSd}|j�r$|j�|_|j�s:tjd�d}|jjdtd�}|sT|r�y|j	|�Wn t
k
r�tjtd�YnXt
|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!)rAr@rRr\r.�warningr:r0r9�!_add_network_config_from_opc_imds�	Exceptionr	�logexcr3)r�set_primaryZ
set_secondaryrrrr�s*



zDataSourceOracle.network_configF)racCsb|jdkrtjd�dS|r:d|jdkr:tjd�dSt�}|rJ|jn|jdd�}�xt|�D]�\}}|ov|dk}|dj�}||kr�tjd|�qd||}tj|d	�}	|jd
dk�r|r�ddi}
nd
|d�d|	j	��d�}
|d|t
|
gd�}|jdj|�qd|jd
dkrdt
d|id|d�}|�sL|d�d|	j	��g|d<||jd|<qdWdS)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 beZnicIndexrz\VNIC metadata indicates this is a bare metal machine; skipping secondary VNIC configuration.r!ZmacAddrz)Interface with MAC %s not found; skippingZsubnetCidrBlockr r#ZdhcpZstaticZ	privateIp�/)r#Zaddressr()r-r#r)�mtuZsubnetsr'r"r,F)rcr+Zdhcp6Zdhcp4Z	addressesr*)r7r.r]r
�	enumerate�lower�	ipaddressZ
ip_networkr@Z	prefixlen�MTU�append)rraZinterfaces_by_macrV�indexZ	vnic_dictZ
is_primaryr)r-ZnetworkZsubnetZinterface_configrrrr^sL



z2DataSourceOracle._add_network_config_from_opc_imds)F)rrrr8rNZvendordata_purerZNetworkConfigSourceZCMD_LINEZ
SYSTEM_CFGZDSZ	INITRAMFSZnetwork_config_sourcesrr@�dictr6rrA�staticmethodrCrYrZr[rRr\�propertyrr^�
__classcell__rr)r?rr4qs&
..r4)rcCstjd�}|dkrdS|j�S)Nzsystem-uuid)r�
read_dmi_datare)Zsys_uuidrrrrMOs
rMcCstjd�}|tkS)Nzchassis-asset-tag)rrn�CHASSIS_ASSET_TAG)Z	asset_tagrrrrBTs
rBr")�metadata_versionrE�retriesrcCs*ttj||d�|dkrtnd|d�jj�S)N)r rEr!)rFrGrq)rrOrPrQZ	_responseZjson)rprErqrrr�_fetchYsrr)rH)rHrcCs�d}yt|dd�}Wn$tk
r8d}t|dd�}YnXd}|rtyt|dd�}Wn tk
rrtjtd�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"rD)rEr!NZvnicsz+Failed to fetch IMDS network configuration!)rrrr	r`r.r)rHrprTrVrrrrSasrScCstj|t�S)N)rZlist_from_depends�datasources)Zdependsrrr�get_datasource_list�srt�__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)rSrB)r"):rrWrfZlogging�collectionsrZtypingrrZ	cloudinitrrrrr	Zcloudinit.distros.networkingr
Z
cloudinit.netrrr
rZcloudinit.url_helperrrZ	getLoggerrr.r9rorUrOrgrQrZKlibcNetworkConfigSourcerr3Z
DataSourcer4�strrMrrB�intrjrrrSZDEP_FILESYSTEMrsrt�argparserv�ArgumentParser�parser�
parse_args�printZ
json_dumpsrrrr�<module>sH

4_ 


Filemanager

Name Type Size Permission Actions
DataSourceAkamai.cpython-36.opt-1.pyc File 8.18 KB 0644
DataSourceAkamai.cpython-36.pyc File 8.18 KB 0644
DataSourceAliYun.cpython-36.opt-1.pyc File 3.22 KB 0644
DataSourceAliYun.cpython-36.pyc File 3.22 KB 0644
DataSourceAltCloud.cpython-36.opt-1.pyc File 6.74 KB 0644
DataSourceAltCloud.cpython-36.pyc File 6.74 KB 0644
DataSourceAzure.cpython-36.opt-1.pyc File 47.95 KB 0644
DataSourceAzure.cpython-36.pyc File 47.95 KB 0644
DataSourceBigstep.cpython-36.opt-1.pyc File 1.84 KB 0644
DataSourceBigstep.cpython-36.pyc File 1.84 KB 0644
DataSourceCloudSigma.cpython-36.opt-1.pyc File 3.62 KB 0644
DataSourceCloudSigma.cpython-36.pyc File 3.62 KB 0644
DataSourceCloudStack.cpython-36.opt-1.pyc File 5.97 KB 0644
DataSourceCloudStack.cpython-36.pyc File 5.97 KB 0644
DataSourceConfigDrive.cpython-36.opt-1.pyc File 8.18 KB 0644
DataSourceConfigDrive.cpython-36.pyc File 8.18 KB 0644
DataSourceDigitalOcean.cpython-36.opt-1.pyc File 3.65 KB 0644
DataSourceDigitalOcean.cpython-36.pyc File 3.65 KB 0644
DataSourceEc2.cpython-36.opt-1.pyc File 23.49 KB 0644
DataSourceEc2.cpython-36.pyc File 23.49 KB 0644
DataSourceExoscale.cpython-36.opt-1.pyc File 5.92 KB 0644
DataSourceExoscale.cpython-36.pyc File 5.92 KB 0644
DataSourceGCE.cpython-36.opt-1.pyc File 9.83 KB 0644
DataSourceGCE.cpython-36.pyc File 9.93 KB 0644
DataSourceHetzner.cpython-36.opt-1.pyc File 3.78 KB 0644
DataSourceHetzner.cpython-36.pyc File 3.78 KB 0644
DataSourceIBMCloud.cpython-36.opt-1.pyc File 12.44 KB 0644
DataSourceIBMCloud.cpython-36.pyc File 12.44 KB 0644
DataSourceLXD.cpython-36.opt-1.pyc File 13.31 KB 0644
DataSourceLXD.cpython-36.pyc File 13.31 KB 0644
DataSourceMAAS.cpython-36.opt-1.pyc File 11.86 KB 0644
DataSourceMAAS.cpython-36.pyc File 11.86 KB 0644
DataSourceNWCS.cpython-36.opt-1.pyc File 3.77 KB 0644
DataSourceNWCS.cpython-36.pyc File 3.77 KB 0644
DataSourceNoCloud.cpython-36.opt-1.pyc File 7.97 KB 0644
DataSourceNoCloud.cpython-36.pyc File 7.97 KB 0644
DataSourceNone.cpython-36.opt-1.pyc File 1.47 KB 0644
DataSourceNone.cpython-36.pyc File 1.47 KB 0644
DataSourceOVF.cpython-36.opt-1.pyc File 9.15 KB 0644
DataSourceOVF.cpython-36.pyc File 9.15 KB 0644
DataSourceOpenNebula.cpython-36.opt-1.pyc File 11.75 KB 0644
DataSourceOpenNebula.cpython-36.pyc File 11.75 KB 0644
DataSourceOpenStack.cpython-36.opt-1.pyc File 7.91 KB 0644
DataSourceOpenStack.cpython-36.pyc File 7.91 KB 0644
DataSourceOracle.cpython-36.opt-1.pyc File 10.99 KB 0644
DataSourceOracle.cpython-36.pyc File 10.99 KB 0644
DataSourceRbxCloud.cpython-36.opt-1.pyc File 7.19 KB 0644
DataSourceRbxCloud.cpython-36.pyc File 7.19 KB 0644
DataSourceScaleway.cpython-36.opt-1.pyc File 10.84 KB 0644
DataSourceScaleway.cpython-36.pyc File 10.84 KB 0644
DataSourceSmartOS.cpython-36.opt-1.pyc File 24.51 KB 0644
DataSourceSmartOS.cpython-36.pyc File 24.51 KB 0644
DataSourceUpCloud.cpython-36.opt-1.pyc File 4.36 KB 0644
DataSourceUpCloud.cpython-36.pyc File 4.36 KB 0644
DataSourceVMware.cpython-36.opt-1.pyc File 23.66 KB 0644
DataSourceVMware.cpython-36.pyc File 23.66 KB 0644
DataSourceVultr.cpython-36.opt-1.pyc File 3.44 KB 0644
DataSourceVultr.cpython-36.pyc File 3.44 KB 0644
__init__.cpython-36.opt-1.pyc File 30.52 KB 0644
__init__.cpython-36.pyc File 30.52 KB 0644