404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@18.224.61.70: ~ $
3

�~�fZ�@s�dZddlZddlZddlZddlZddlZddlmZddlm	Z	m
Z
mZddlm
Z
mZeje�ZdZdd�Zeed	�d
d�Zejed�d
d�Zdd�Zdd�Zdd�Zdd�Zdd�ZGdd�de	j�Zee	j ffgZ!dd�Z"dS)zr
This file contains code used to gather the user data passed to an
instance on rootbox / hyperone cloud platforms
�N)�IPv4Address)�sources�subp�util)�
EventScope�	EventTypez
/etc/hostscCs.tjtdd�}|r tjd�dStjd�dS)NT)�quietz5/etc/hosts exists - setting manage_etc_hosts to FalseFz=/etc/hosts does not exists - setting manage_etc_hosts to True)r�	load_file�	ETC_HOSTS�LOG�debug)Zhosts�r
�(/usr/lib/python3.6/DataSourceRbxCloud.py�get_manage_etc_hostss

r)�inc�returncCstttt|��|��S)N)�strr�int)�addrrr
r
r�increment_ip#sr)rcCs|t|d�t|d�gS)z�Return a list of 3 IP addresses: [addr, addr + 2, addr + 3]

    @param addr: an object that is passed to IPvAddress
    @return: list of strings
    ��)r)rr
r
r�
get_three_ips'srcCstjdg|�S)z�
    Uses the preferred cloud-init subprocess def of subp.subp
    and runs arping.  Breaking this to a separate function
    for later use in mocking and unittests
    Zarping)r)�cmdr
r
r�_sub_arp4srcCs�d}|jd
krd}xh|D]`}ytdd	||d
|dg�Wqtjk
rv}ztjd|d
|d|�WYdd}~XqXqWdS)Nz-S�	almalinux�fedora�centos�
cloudlinux�rhelz-sz-c�2�source�destinationz&Failed to arping from "%s" to "%s": %s)rrrrr)�namerrZProcessExecutionErrorrZwarning)�items�distroZsource_param�item�errorr
r
r�gratuitous_arp=s

r(cCs�ttjd�tjd��}|s dSx�|D]z}y"tj|tdddgd�}|rJ|SWq&tk
r|}z|jtjkrl�WYdd}~Xq&tjk
r�tj	t
d	|�Yq&Xq&Wt
jd
dj|��dS)zAReturns False (not found or error) or a dictionary with metadata.z
LABEL=CLOUDMDz
LABEL=cloudmdFZvfatZfatZmsdosfs)�device�callbackZmtypeNz-Failed to mount %s when looking for user dataz0Did not find RbxCloud data, searched devices: %s�,)
�setrZfind_devs_withZmount_cb�read_user_data_callback�OSError�errno�ENOENTZMountFailedError�logexcrr�join)Zdevicesr)�rbx_data�errr
r
r�get_mdRs,
r5cCsddd�t|�D�d�S)z�Generate network configuration

    @param netadps: A list of network adapter settings

    @returns: A dict containing network config
    �csBg|]:\}�ddjt|���dj��fdd��dD�d��qS)Zphysicalzeth{}Z
macaddressc	s>g|]6}d|d�ddd�dd�dddd��qS)	Zstatic�address�network�netmask�auto�gatewayZdnsZnameservers)�typer7r9Zcontrolr;Zdns_nameserversr
)�.0�ip)�netadpr
r�
<listcomp>�s
z6generate_network_config.<locals>.<listcomp>.<listcomp>r>)r<r#Zmac_addressZsubnets)�formatr�lower)r=�ir
)r?rr@{sz+generate_network_config.<locals>.<listcomp>)�version�config)�	enumerate)Znetadpsr
r
r�generate_network_configqsrGc
Cstjtjtjj|d�dd�d�}tjtjj|d�dd�}d|ksHd	|krXtjtd
�dS|jdi�jd
�}|jdi�jdg�}d}|jdi�jd�r�|ddd}t	|d	�}||dd|ddgd�dd�|d	D�ddd||dg|d|d�i|t
�d�d�}tjd�tj|�|S)aThis callback will be applied by util.mount_cb() on the mounted
    drive.

    @param mount_dir: String representing path of directory where mounted drive
    is available

    @returns: A dict containing userdata, metadata and cfg based on metadata.
    z
cloud.jsonF)�fname�decode)�textz	user.dataT)rHrZvmr?z(Failed to load metadata. Invalid format.NZadditionalMetadata�usernameZsshKeysZpasswordZsha512Z_idr#)zinstance-idzlocal-hostnamezpublic-keyscSs>g|]6}|dD](}t|dd�D]}|d|d��q$qqS)r>r8r;r7)r!r")r)r=r?r>�targetr
r
rr@�sz+read_user_data_callback.<locals>.<listcomp>Zdefault_userzALL=(ALL) NOPASSWD:ALL)r#ZgecosZsudoZpasswdZlock_passwdZssh_authorized_keys)Z
ssh_pwauthZdisable_rootZsystem_info�network_configZmanage_etc_hosts)�userdata�metadatar(�cfgzreturning DATA object:)rZ	load_jsonr	�os�pathr2r1r�getrGrr)Z	mount_dirZ	meta_dataZ	user_datarKZssh_keys�hashr8�datar
r
rr-�sD	




r-c@sjeZdZdZejejejej	hiZ
dd�Zdd�Zdd�Z
edd	��Zd
d�Zdd
�Zdd�Zdd�ZdS)�DataSourceRbxCloudZRbxCloudcCstjj||||�d|_dS)N)r�
DataSource�__init__�seed)�selfZsys_cfgr%�pathsr
r
rrX�szDataSourceRbxCloud.__init__cCstjj|�}d||jfS)Nz%s [seed=%s])rrW�__str__rY)rZ�rootr
r
rr\�szDataSourceRbxCloud.__str__cCs>t�}|dkrdS|d|_|d|_|d|_|d|_dS)zw
        Metadata is passed to the launching instance which
        is used to perform instance configuration.
        FrNrOr(rPT)r5�userdata_rawrOr(rP)rZr3r
r
r�	_get_data�s



zDataSourceRbxCloud._get_datacCs
|jdS)NrM)rP)rZr
r
rrM�sz!DataSourceRbxCloud.network_configcCs
|jdS)Nzpublic-keys)rO)rZr
r
r�get_public_ssh_keys�sz&DataSourceRbxCloud.get_public_ssh_keyscCs|jS)N)r^)rZr
r
r�get_userdata_raw�sz#DataSourceRbxCloud.get_userdata_rawcCs|jS)N)rP)rZr
r
r�get_config_obj�sz!DataSourceRbxCloud.get_config_objcCst|j|j�dS)N)r(r%)rZrPZis_new_instancer
r
r�activateszDataSourceRbxCloud.activateN)�__name__�
__module__�__qualname__ZdsnamerZNETWORKrZBOOT_NEW_INSTANCEZBOOTZBOOT_LEGACYZdefault_update_eventsrXr\r_�propertyrMr`rarbrcr
r
r
rrV�s
rVcCstj|t�S)N)rZlist_from_depends�datasources)Zdependsr
r
r�get_datasource_listsri)#�__doc__r/ZloggingrQZos.pathZtypingZ	ipaddressrZ	cloudinitrrrZcloudinit.eventrrZ	getLoggerrdrr
rrrrZListrrr(r5rGr-rWrVZDEP_FILESYSTEMrhrir
r
r
r�<module>s*
	
	!B3

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