404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@3.145.45.223: ~ $
3

\�me�<�@sddlZddlZddlZddlZddlmZmZmZddlm	Z	ddl
mZeje
�ZdZd%d&d'd(d)gZGdd�dej�ZGdd�de�Zdd�Zdd�Zdd�Zddeddfdd�Zdd�ZGdd�de�ZGdd�de�ZeejffeejejffgZd d!�Ze
d"k�rd#d$�Z e �dS)*�N)�sources�
url_helper�util)�KlibcNetworkConfigSource)�NetworkConfigSourcez
2012-03-01�meta-data/instance-idF�meta-data/local-hostname�meta-data/public-keysT�meta-data/vendor-data�vendor-data�	user-datac@s`eZdZdZdZdZdZdd�Zedd��Z	dd	�Z
d
d�Zdd
�Zdd�Z
dd�Zdd�ZdS)�DataSourceMAASz�
    DataSourceMAAS reads instance information from MAAS.
    Given a config metadata_url, and oauth tokens, it expects to find
    files under the root named:
      instance-id
      user-data
      hostname
      vendor-data
    �MAASNcCs:tjj||||�d|_tjj|jd�|_t|j	�|_
dS)NZmaas)r�
DataSource�__init__�base_url�os�path�join�seed_dir�get_id_from_ds_cfg�ds_cfg�id_hash)�self�sys_cfgZdistro�paths�r�$/usr/lib/python3.6/DataSourceMAAS.pyr.szDataSourceMAAS.__init__cCs|jst|j�|_|jS)N)�
_oauth_helper�get_oauth_helperr)rrrr�oauth_helper4szDataSourceMAAS.oauth_helpercCstjj|�}d||jfS)Nz%s [%s])rr�__str__r)r�rootrrrr!:szDataSourceMAAS.__str__cCs�|j}y|j|jt|j��dStk
r2Yn4tk
rd}ztjd|j|��WYdd}~XnX|jdd�}|szdSy0|j	|�s�dS|j|t
||jj|j
dd��dStk
r�tjtd|�dSXdS)NTz%s was malformed: %s�metadata_urlF�)�read_file_or_urlr�retriesz$Failed fetching metadata from url %s)r�	_set_datar�read_maas_seed_dir�MAASSeedDirNone�MAASSeedDirMalformed�LOG�warning�get�wait_for_metadata_service�read_maas_seed_urlr �readurlr�	Exceptionr�logexc)r�mcfg�exc�urlrrr�	_get_data>s4

zDataSourceMAAS._get_datacCsp||_|\}}}||_||_||_|rlytj|�|_Wn4tk
rj}ztj	d|�d|_WYdd}~XnXdS)Nz"Invalid content in vendor-data: %s)
rZuserdata_raw�metadataZvendordata_purerZconvert_vendordataZvendordata_raw�
ValueErrorr+r,)rr5�dataZud�md�vd�errrr'es
zDataSourceMAAS._set_datacCs
d|jS)z/Return the subplatform metadata source details.z
seed-dir (%s))r)rrrr�_get_subplatformsszDataSourceMAAS._get_subplatformc	Cs
|j}d}yt|jd|��}Wn"tk
r@tjtd|�YnX|dkrNdSd}y||krlt|jd|��}Wn tk
r�tjd|�YnXtj�}|j	d	�r�|dd�}d|t
f}|g}|jj|||d�\}}|r�tj
d
|�ntjd|ttj�|��t|�S)N�x�max_waitz Failed to get max wait. using %srF�2�timeoutzFailed to get timeout, using %s�/r$z%s/%s/meta-data/instance-id)�urlsr?rAzUsing metadata source: '%s'z(Giving up on md from %s after %i seconds���)r�intr-r1rr2r+r,�time�endswith�
MD_VERSIONr Zwait_for_url�debugZcritical�bool)	rr5r3r?rAZ	starttimeZ	check_urlrCZ	_responserrrr.ws8
z(DataSourceMAAS.wait_for_metadata_servicecCs0|jdkrdStj|d|jfi�}|jt|�kS)alocally check if the current system is the same instance.

        MAAS doesn't provide a real instance-id, and if it did, it is
        still only available over the network.  We need to check based
        only on local resources.  So compute a hash based on Oauth tokens.NF�
datasource)rrZget_cfg_by_path�dsnamer)rrZncfgrrr�check_instance_id�s
z DataSourceMAAS.check_instance_id)�__name__�
__module__�__qualname__�__doc__rLrrr�propertyr r!r6r'r=r.rMrrrrr
s	'&r
cs0eZdZejejejejfZ�fdd�Z	�Z
S)�DataSourceMAASLocalcs,t�j�stjd�dStjd�t�j�S)NzNo initramfs applicable configFz!Found initramfs applicable config)rZ
is_applicabler+rI�superr6)r)�	__class__rrr6�s



zDataSourceMAASLocal._get_data)rNrOrPrZCMD_LINEZ
SYSTEM_CFGZDSZ	INITRAMFSZnetwork_config_sourcesr6�
__classcell__rr)rUrrS�s
rScs&d}t�fdd�|D��}tjf|�S)z�Return an oauth helper instance for values in cfg.

    @raises ValueError from OauthUrlHelper if some required fields have
            true-ish values but others do not.�consumer_key�consumer_secret�	token_key�token_secretcsg|]}|�j|�f�qSr)r-)�.0�r)�cfgrr�
<listcomp>�sz$get_oauth_helper.<locals>.<listcomp>)rWrXrYrZ)�dictrZOauthUrlHelper)r]�keys�kwargsr)r]rr�srcs4d	}dj�fdd�|D��}dtj|jd��j�S)
z;Given a config, generate a unique identifier for this node.rWrYrZ�csg|]}�j|d��qS)�)r-)r[�f)rrrr^�sz&get_id_from_ds_cfg.<locals>.<listcomp>zv1:zutf-8)rWrYrZ)r�hashlibZsha256�encodeZ	hexdigest)rZfieldsZidstrr)rrr�srcCsN|jd�r|dd�}tjj|�s6ttj|��dkr>td��td|dd�S)Nzfile://�rz%s: not a directoryz	file://%s)�version)�
startswithrr�isdir�len�listdirr)r/)Zseed_drrrr(�s

 r(cCs |dkrtj}|jd�r$|dd
�}i}x�tD]�\}}}	}
|dkrPd||f}nd|||f}yXtj|�}|||||d�}
|
j�r�|	r�|
j||<q�tj|
j�||<nt	j
d||
j�Wq.tjk
�r}z:|jdkr�|
r�t
d	||f�|�n|jdk�r|�WYdd}~Xq.Xq.Wt||�S)a�
    Read the maas datasource at seed_url.
      read_file_or_url is a method that should provide an interface
      like util.read_file_or_url

    Expected format of seed_url is are the following files:
      * <seed_url>/<version>/meta-data/instance-id
      * <seed_url>/<version>/meta-data/local-hostname
      * <seed_url>/<version>/user-data
    If version is None, then <version>/ will not be used.
    NrBr$z%s/%sz%s/%s/%s)r&rA�ssl_detailsz4Fetching from %s resulted in an invalid http code %si�zMissing required %s: %srD)rr%rG�	DS_FIELDSrZfetch_ssl_details�ok�contentsZ
decode_binaryr+r,�codeZUrlErrorr*�check_seed_contents)Zseed_urlr%rArhrr&r:rZ	_dictnameZbinary�optionalr5rmZrespr<rrrr/�s:

r/c
Cs�i}g}xrtD]j\}}}}||kr2|s|j|�qd|krl|jd�\}}	}
||krZi||<|||||
<q||||<qWt|�dkr�td|��|r�td||f��d}|jd�r�t�}tj	|jd�|td�}||kr�td��|jd	�|jd
�|fS)z�Validate if dictionary content valid as a return for a datasource.
    Either return a (userdata, metadata, vendordata) tuple or
    Raise MAASSeedDirMalformed or MAASSeedDirNone
    rBrz%s: no data files foundz%s: missing files %sNzvendor-data)�defaultZallowedz%vendor-data was not loadable as yaml.z	user-dataz	meta-data)
rn�append�	partitionrkr)r*r-�objectrZ	load_yaml)
ZcontentZseed�retZmissingZspathZdpathZ_binaryrs�top�_�pZvd_data�errrrrrrs2

rrc@seZdZdS)r)N)rNrOrPrrrrr)9sr)c@seZdZdS)r*N)rNrOrPrrrrr*=sr*cCstj|t�S)N)rZlist_from_depends�datasources)Zdependsrrr�get_datasource_listIsr~�__main__cs.ddl}ddl}ddl}|jdd�}|jddddd�|jd	d
ddd�|jdd
d
dd�|jddddd�|jddddd�|jdddtd�|jddd�}x0dCD](\}}|j||d �}|jd!d"d#dd$�q�W|j�}|j	|j
|j|jd%�}	|j
dk�rJxNdDD]F}
d(|
d)}tjj|��rtj|tj��r|jjd*|�||_
�qW|j
�r�tj|j
�}d+|k�rt|d+d,}x6|	j�D]*}
|
|k�r~|	|
dk�r~||
|	|
<�q~W|jdk�r�d-|k�r�|d-|_|jdk�r�|jjd.�|jd/�t|	���fd0d1���fd2d3�����fd4d5��|jdk�r�|jjd6|j��j}|jdd7k�s`|jjd8��rrt|j�\}}}nt|j|j |d9d:�\}}}t!d;�t!|dk�r�d<n|j"��t!d=�|j|�t!d>�|j|dk�r�d<n|�nH|jdk�r��|j�n0|jdk�r*|jj#d7��s d?|j|_�|j�dS)Ez�
        Call with single argument of directory or http or https url.
        If url is given additional arguments are allowed, which will be
        interpreted as consumer_key, token_key, token_secret, consumer_secret
        rNzInteract with MAAS DS)�descriptionz--config�filezspecify DS config file)�metavar�helprtz--ckey�keyzthe consumer key to auth withz--tkeyzthe token key to auth withz--csecZsecretzthe consumer secret (likely '')rcz--tseczthe token secret to auth withz--apiverrhz the apiver to use ( can be used)Zsubcommands�subcmd)�title�dest�crawl�crawl the datasourcer-�do a single GET of provided url�
check-seed�read and verify seed at url)r�r5zthe datasource url�?)r��nargsrt)rWrYrZrX�91_kernel_cmdline_url�90_dpkg_maasz/etc/cloud/cloud.cfg.d/z.cfgzUsed config in %s.
rKrr#z)Must provide a url or a config with url.
r$cs�j|dd�jS)Nr$)r&)r0rp)r5)r rr�geturl�szmain.<locals>.geturlcstd|�|�j�f�dS)Nz== %s ==
%s
)�print�decode)r5)r�rr�printurl�szmain.<locals>.printurlcsx|jd�rlxh�|�j�j�D]J}|jd�r<�d||f�q|dkrV�d|df�q�d||f�qWn�|�dS)NrBz%s%sz	meta-dataz
meta-data/)rGr��
splitlines)r5�line)r�r�r�rrr��s

zmain.<locals>.crawlzChecking seed at %s
rBzfile://�)rhr%r&z=== user-data ===zN/Az=== meta-data ===z=== vendor-data ===z%s/�r�r��r-r��r�r�)r�r�r�)r�r�)$�argparse�pprint�sys�ArgumentParser�add_argumentrHZadd_subparsersZ
add_parser�
parse_argsZckeyZtkeyZtsecZcsec�configrr�exists�access�R_OK�stderr�writerZ	read_confr`r5�exitrr�r0rir(r/Zapiverr�r�rG)r�r�r��parserZsubcmds�namer�r{�argsZcredsZfnameZfpathr]r�r0Zuserdatar7r;r)r�r�r r�r�mainOs�






r�)rrFF)rrFF)r	r	FT)r
rTT)rrTT)!reZloggingrrFZ	cloudinitrrrZcloudinit.net.cmdlinerZcloudinit.sourcesrZ	getLoggerrNr+rHrnrr
rSrrr(r/rrr1r)r*ZDEP_FILESYSTEMZDEP_NETWORKr}r~r�rrrr�<module>	sD

	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