404

[ Avaa Bypassed ]




Upload:

Command:

elspacio@18.188.41.251: ~ $
3

�~�f��@s�ddlZddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZddlm
Z
mZmZmZmZddlmZmZmZmZmZddlmZddlmZddlmZdd	lmZdd
lm Z m!Z!ddl"m#Z#ddl$m%Z%dd
l&m'Z'ddl(m)Z)dZ*dZ+dZ,dZ-e*e+e,gZ.dZ/dZ0dZ1dZ2dZ3dZ4dZ5dZ6ej7e8�Z9ddd�fddd�fd d!d�fd"�Z:eGd#d$�d$e
��Z;Gd%d&�d&e<�Z=Gd'd(�d(e<�Z>Gd)d*�d*e<�Z?d+ffd,d-�Z@e3fd.d/�ZAed0d1d2d3d4g�ZBed5d6d7g�ZCGd8d�de'ejDd9�ZEd:d;�ZFeeEeGfd<�d=d>�ZHd?d@�ZIdVeGeJdB�dCdD�ZKdEdF�ZLdWdHdI�ZMGdJdK�dKeN�ZOdLdM�ZPeEeGeJdN�dOdP�ZQeGeeEdQ�dRdS�ZReGd<�dTdU�ZSdS)X�N)�
namedtuple)�Enum�unique)�Any�Dict�List�Optional�Tuple)�
atomic_helper�dmi�importer�net�
type_utils)�	user_data)�util)�
write_json)�Distro)�
EventScope�	EventType)�launch_index)�Paths)�CloudInitPickleMixin)�eventsZdisabled�localr
�passZ
FILESYSTEM�NETWORK�
DataSourcez|EXPERIMENTAL: The structure and format of content scoped under the 'ds' key may change in subsequent releases of cloud-init.zredacted for non-root userz
cloud-nameZ_unset�unknownz	aws-chinacCs|dkS)N�aws�)�crr�/usr/lib/python3.6/__init__.py�<lambda>?sr"zaws-govcCs|dkS)Nrr)r rrr!r"@szazure-chinacCs|dkS)NZazurer)r rrr!r"As)zcn-zus-gov-Zchinac@s2eZdZdZdZdZdZdZdZe	d�dd	�Z
d
S)�NetworkConfigSourcezb
    Represents the canonical list of network config sources that cloud-init
    knows about.
    �cmdline�dsZ
system_cfgZfallbackZ	initramfs)�returncCs|jS)N)�value)�selfrrr!�__str__RszNetworkConfigSource.__str__N)�__name__�
__module__�__qualname__�__doc__�CMD_LINE�DS�
SYSTEM_CFGZFALLBACK�	INITRAMFS�strr)rrrr!r#Esr#c@seZdZdZdS)�DatasourceUnpickleUserDataErrorzERaised when userdata is unable to be unpickled due to python upgradesN)r*r+r,r-rrrr!r3Vsr3c@seZdZdS)�DataSourceNotFoundExceptionN)r*r+r,rrrr!r4Zsr4c@seZdZdZdS)�InvalidMetaDataExceptionz8Raised when metadata is broken, unavailable or disabled.N)r*r+r,r-rrrr!r5^sr5�c
Cs�tj|�}g}g}x�|j�D]�\}}|r6|d|}n|}|j�|ksR|j�|kr\|j|�t|t�r�|jd�r�|j|�|jdd�||<t|t	�rt
|||�}	|j|	jd��|j|	jd��|	||<qWt
|�|d<t
|�|d<|S)z�Process all instance metadata cleaning it up for persisting as json.

    Strip ci-b64 prefix and catalog any 'base64_encoded_keys' as a list

    @return Dict copy of processed metadata.
    �/zci-b64:r6�base64_encoded_keys�sensitive_keys)�copy�deepcopy�items�lower�append�
isinstancer2�
startswith�replace�dict�process_instance_metadata�extend�pop�sorted)
�metadata�key_pathr9�md_copyr8Z	sens_keys�key�valZsub_key_pathZ
return_valrrr!rCbs,




rCcCs�|jdg�s|Stj|�}xh|jd�D]Z}|jd�}|}x6|D].}||kr>t||t�r>||dkr>||}q>W||kr&|||<q&W|S)z�Redact any sensitive keys from to provided metadata dictionary.

    Replace any keys values listed in 'sensitive_keys' with redact_value.
    r9r7����)�getr:r;�splitr?rB)rGZredact_valuerIrH�
path_parts�obj�pathrrr!�redact_sensitive_keys�s


rS�	URLParamsZmax_wait_secondsZtimeout_secondsZnum_retries�sec_between_retries�DataSourceHostname�hostname�
is_defaultc
@s�eZdZUeZdZdZdZdZdZ	dZ
ejej
ejejfZeedfd|ZdZdZdZejejejejejhiZejejhiZdefd	efd
ifd}d~dd�d�d�f	Z eee!e"fdf dZ#d�Z$ee!df$dZ%dZ&d�e'e(d�dd�Z)e*dd�dd�Z+d d!�Z,e-d"�d#d$�Z.e-d"�d%d&�Z/d'd(�Z0d)d*�Z1ffd+d,�Z2e-d"�d-d.�Z3d�d0d1�Z4e-d"�d2d3�Z5d4d5�Z6d�d6d7�Z7d8d9�Z8d:d;�Z9e:d<d=��Z;e:d>d?��Z<e:d@dA��Z=dBdC�Z>e:dDdE��Z?dFdG�Z@e:dHdI��ZAdJdK�ZBe:dLdM��ZCdNdO�ZDdPdQ�ZEdRdS�ZFdTdU�ZGdVdW�ZHdXdY�ZIdZd[�ZJd\d]�ZKd^d_�ZLe:d`da��ZMe:dbdc��ZNddde�ZOd�dfdg�ZPdhdi�ZQeRedj�dkdl�ZSeRee-dm�dndo�ZTdpdq�ZUdrds�ZVeWd�dtdu��ZXe:dvdw��ZYdxdy�ZZdzd{�Z[dS)�rzen_US.UTF-8Z_undefN.rL�
��ec2_metadata�network_jsonrG�userdata�userdata_raw�
vendordata�vendordata_raw�vendordata2�vendordata2_rawF�combined_cloud_config�
merged_cfg�merged_system_cfg�security-credentials�	user-datar�vendor-data�ds/vendor_data)�distro�pathscCs~||_||_||_d|_i|_d|_d|_d|_d|_d|_	t
j|jd|jfi�|_
|j
s`i|_
|sttj|j�|_n||_dS)NZ
datasource)�sys_cfgrjrkr]rGr^r_rar`rbrZget_cfg_by_path�dsname�ds_cfg�udZUserDataProcessor�ud_proc)r(rlrjrkrprrr!�__init__s"zDataSource.__init__)�ci_pkl_versionr&cCs�t|d�sd|_t|d�s d|_t|d�s0d|_t|d�sJt|ddd��t|d	�r�|jdk	r�yt|j�Wn6tk
r�}ztj	d
|�t
�|�WYdd}~XnXdS)z(Perform deserialization fixes for Paths.raNrb�skip_hotplug_detectF�check_if_fallback_is_allowedcSsdS)NFrrrrr!r"=sz&DataSource._unpickle.<locals>.<lambda>r]z:Unable to unpickle datasource: %s. Ignoring current cache.)�hasattrrarbrs�setattrr]r2�AttributeError�LOG�debugr3)r(rr�errr!�	_unpickle3s 



zDataSource._unpicklecCs
tj|�S)N)r�obj_name)r(rrr!r)OszDataSource.__str__)r&cCsdS)z#Check if running on this datasourceTr)r(rrr!�	ds_detectRszDataSource.ds_detectcCsN|jj�t�j�kr$tjd|�dS|jjdg�|jgkrJtjd|�dSdS)aIOverride if either:
        - only a single datasource defined (nothing to fall back to)
        - commandline argument is used (ci.ds=OpenStack)

        Note: get_cmdline() is required for the general case - when ds-identify
        does not run, _something_ needs to detect the kernel command line
        definition.
        zOMachine is configured by the kernel commandline to run on single datasource %s.TZdatasource_listz5Machine is configured to run on single datasource %s.F)rmr=�
parse_cmdlinerxryrlrN)r(rrr!�override_ds_detectVs	zDataSource.override_ds_detectcCs@|j�r|j�S|j�r,tjd|�|j�Stjd|�dSdS)z&Overrides runtime datasource detectionz8Detected platform: %s. Checking for active instance dataz#Datasource type %s is not detected.FN)r�	_get_datar}rxry)r(rrr!�_check_and_get_datamszDataSource._check_and_get_datacCs�|j�j}|j�}|j}|d}ddg||t|j|j|j�|j|j|dd|dd|dd|j|j�|d|||d	d|||d	d
|j|j	|d|dd
�iS)z2Return a dictionary of standardized metadata keys.�sys_info�v1�subplatformZdistrrL��python�uname��platform�variant)Z
_beta_keyszavailability-zone�availability_zone�cloud_idz
cloud-name�
cloud_namerjZdistro_versionZdistro_releaser�Zpublic_ssh_keysZpython_versionzinstance-id�instance_idZkernel_releasezlocal-hostname�local_hostname�machine�regionr�Zsystem_platformr�)
�get_hostnamerW�get_instance_idr��canonical_cloud_idr�r��
platform_type�get_public_ssh_keysr�)r(�
instance_datar�r�r�Zsysinforrr!�_get_standardized_metadata{s8





z%DataSource._get_standardized_metadatacCsP|js
dS|r|}n|j}x&|D]\}}t||�r t|||�q W|sLd|_dS)z�Reset any cached metadata attributes to datasource defaults.

        @param attr_defaults: Optional tuple of (attr, value) pairs to
           set instead of cached_attr_defaults.
        NF)�_dirty_cache�cached_attr_defaultsrurv)r(Z
attr_defaultsZattr_valuesZ	attributer'rrr!�clear_cached_attrs�s
zDataSource.clear_cached_attrscCs"d|_|j�}|s|S|j�|S)z�Datasources implement _get_data to setup metadata and userdata_raw.

        Minimally, the datasource should return a boolean True on success.
        T)r�r��persist_instance_data)r(Zreturn_valuerrr!�get_data�szDataSource.get_dataTcCst|r&tjj|jj�r&t||jjd��t|d�rbtj	t
|d��}|jdd�|jdd�d|i}n^dd|jii}t|d�r�t
|d�}|t
kr�||dd<t|d	�r�t
|d	�}|t
kr�||dd	<t|dd
<tj	|j�|d<d|dd
<tj	|d�|d
<d|d
d
<tj�|d<|j|j|��y"tj|�}ttj|�|jd�}Wnbtk
�rv}ztjdt|��dSd}~Xn2tk
�r�}ztjdt|��dSd}~XnX|jjd�}	|dj dd�}
tjj!|jj"d�}tj#|�d|
��|
�d��d}|�d|
��}
tjj$|��rtjj%|�}tj&|
|dd�|�rH||
k�rHtj'|�t(|	|dd�|jjd�}t(|t)|��dS)aPProcess and write INSTANCE_JSON_FILE with all instance metadata.

        Replace any hyphens with underscores in key names for use in template
        processing.

        :param write_cache: boolean set True to persist obj.pkl when
            instance_link exists.

        @return True on successful write, False otherwise.
        Zobj_pklZ_crawled_metadataz	user-dataNzvendor-datar%Z	meta_datar\r[Z_docrdz<DEPRECATED: Use merged_system_cfg. Will be dropped from 24.1rezUMerged cloud-init system config from /etc/cloud/cloud.cfg and /etc/cloud/cloud.cfg.d/r�)r9z'Error persisting instance-data.json: %sFZinstance_data_sensitiver�r�Znonezcloud-id�-�
T)�forcei�)�moder�)*�osrR�lexistsrkZ
instance_link�	pkl_storeZ
get_ipath_currur:r;�getattrrErG�UNSET�EXPERIMENTAL_TEXTrlrZsystem_info�updater�r
Z
json_dumpsrC�json�loads�sensitive_metadata_keys�	TypeErrorrx�warningr2�UnicodeDecodeErrorZget_runpathrN�joinZrun_dir�
write_file�exists�realpathZsym_linkZdel_filerrS)r(Zwrite_cacheZcrawled_metadatar�r\r[ZcontentZprocessed_datarzZjson_sensitive_filer�Z
cloud_id_fileZprev_cloud_id_fileZnew_cloud_id_fileZ	json_filerrr!r��sf







z DataSource.persist_instance_datacCstd��dS)z@Walk metadata sources, process crawled data and save attributes.zlSubclasses of DataSource must implement _get_data which sets self.metadata, vendordata_raw and userdata_raw.N)�NotImplementedError)r(rrr!r�szDataSource._get_datac%CsL|j}yt|jjd|j��}Wn,tk
rJtjtd|jjd�|�YnX|j}yt	dt|jjd|j���}Wn2tk
r�|j}tjtd|jjd�|�YnX|j
}yt|jjd|j
��}Wn,tk
r�tjtd|jjd�|�YnX|j}yt|jjd|j��}Wn.tk
�r<tjtd	|jjd�|�YnXt
||||�S)
z�Return the Datasource's preferred url_read parameters.

        Subclasses may override url_max_wait, url_timeout, url_retries.

        @return: A URLParams object with max_wait_seconds, timeout_seconds,
            num_retries.
        �max_waitz6Config max_wait '%s' is not an int, using default '%s'r�timeoutz5Config timeout '%s' is not an int, using default '%s'�retriesz5Config retries '%s' is not an int, using default '%s'rUzAConfig sec_between_retries '%s' is not an int, using default '%s')�url_max_wait�intrnrN�
ValueErrorr�logexcrx�url_timeout�max�url_retries�	Exception�url_sec_between_retriesrT)r(r�r�r�rUrrr!�get_url_paramssP



zDataSource.get_url_paramscCs2|jdkr|jj|j��|_|r,|j|j�S|jS)N)r]rp�process�get_userdata_raw�
_filter_xdata)r(Zapply_filterrrr!�get_userdataUs

zDataSource.get_userdatacCs"|jdkr|jj|j��|_|jS)N)r_rpr��get_vendordata_raw)r(rrr!�get_vendordata\s
zDataSource.get_vendordatacCs"|jdkr|jj|j��|_|jS)N)rarpr��get_vendordata2_raw)r(rrr!�get_vendordata2as
zDataSource.get_vendordata2cCs2|jdkr,tj�|_|jdkr,tjd|j�|jS)zADetermine the network interface used during local network config.Nz(Did not find a fallback interface on %s.)�_fallback_interfacer
Zfind_fallback_nicrxr�r�)r(rrr!�fallback_interfacefs



zDataSource.fallback_interfacecCs.t|d�s|jj�|_|js(|jj�|_|jS)N�_platform_type)rurmr=r�)r(rrr!r�qs

zDataSource.platform_typecCs*t|d�s|j�|_|js$|j�|_|jS)a�Return a string representing subplatform details for the datasource.

        This should be guidance for where the metadata is sourced.
        Examples of this on different clouds:
            ec2:       metadata (http://169.254.169.254)
            openstack: configdrive (/dev/path)
            openstack: metadata (http://169.254.169.254)
            nocloud:   seed-dir (/seed/dir/path)
            lxd:   nocloud (/seed/dir/path)
        �_subplatform)ru�_get_subplatformr�)r(rrr!r�zs



zDataSource.subplatformcCst|d�rdt|d�StS)z?Subclasses should implement to return a "slug (detail)" string.Zmetadata_addressz
metadata (%s))rur��METADATA_UNKNOWN)r(rrr!r��s
zDataSource._get_subplatformcCsv|jr|jS|jrb|jjt�rb|jjt�}t|t�r@|j�|_qp|j�j�|_tj	dtt
|��n|j�j�|_|jS)z�Return lowercase cloud name as determined by the datasource.

        Datasource can determine or define its own cloud product name in
        metadata.
        z5Ignoring metadata provided key %s: non-string type %s)�_cloud_namerGrN�METADATA_CLOUD_NAME_KEYr?r2r=�_get_cloud_namerxry�type)r(r�rrr!r��s
zDataSource.cloud_namecCs|jS)z�Return the datasource name as it frequently matches cloud name.

        Should be overridden in subclasses which can run on multiple
        cloud names, such as DatasourceEc2.
        )rm)r(rrr!r��szDataSource._get_cloud_namecCs"|js
dSd|jkr|jdSdS)Nzlaunch-index)rG)r(rrr!r�s


zDataSource.launch_indexcCs4tjtj|j��g}|}x|D]}|j|�}qW|S)N)r�FilterrZsafe_intZapply)r(Zprocessed_ud�filtersZnew_ud�frrr!r��s

zDataSource._filter_xdatacCsdS)NFr)r(rrr!�is_disconnected�szDataSource.is_disconnectedcCs|jS)N)r^)r(rrr!r��szDataSource.get_userdata_rawcCs|jS)N)r`)r(rrr!r��szDataSource.get_vendordata_rawcCs|jS)N)rb)r(rrr!r��szDataSource.get_vendordata2_rawcCsiS)Nr)r(rrr!�get_config_obj�szDataSource.get_config_objcCst|jjd��S)Nzpublic-keys)�normalize_pubkey_datarGrN)r(rrr!r��szDataSource.get_public_ssh_keyscCsdS)a5Publish the public SSH host keys (found in /etc/ssh/*.pub).

        @param hostkeys: List of host key tuples (key_type, key_value),
            where key_type is the first field in the public key file
            (e.g. 'ssh-rsa') and key_value is the key itself
            (e.g. 'AAAAB3NzaC1y...').
        Nr)r(Zhostkeysrrr!�publish_host_keys�szDataSource.publish_host_keyscCsdddi}xV|j�D]J\}}|j|�s&qx4|D],}d||t|�d�f}tjj|�r,|Sq,WqWdS)NZsd�vd�xvd�vtbz	/dev/%s%s)r�r�r�)r<r@�lenr�rRr�)r(Z
short_nameZmappingsZnfromZtlistZntoZcandrrr!�
_remap_device�s

zDataSource._remap_devicecCsdS)Nr)r(�_namerrr!�device_name_to_device�sz DataSource.device_name_to_devicecCs.|j}y|jj�}Wntk
r(YnX|S)z<Default locale is en_US.UTF-8, but allow distros to override)�default_localerj�
get_localer�)r(Zlocalerrr!r��szDataSource.get_localecCs2|jjd|jjd��}|r|S|jjdi�jd�S)Nzavailability-zoner�Z	placement)rGrN)r(Ztop_level_azrrr!r�s
zDataSource.availability_zonecCs|jjd�S)Nr�)rGrN)r(rrr!r�
szDataSource.regioncCs$|jsd|jkrdSt|jd�S)Nzinstance-idziid-datasource)rGr2)r(rrr!r�szDataSource.get_instance_idcCsdd}d}|}d}|js&|jjd�r�|r4td|�Sg}tj�}	|	dkrLd}tj|	�}
|
rx|
jd�dkrxt|
�jd�}n8|	r�|	jd�dkr�t|	�jd�}n|	r�|	|g}n||g}nZ|jd}t	j
|��rg}|r�tj|�}|r�t|�jd�}nd	|jdd
�g}n
|jd�}t
|�dk�r6|d}	dj|dd��}n|d}	|�rZ||k�rZd|	|f}	t|	|�S)
a�Get hostname or fqdn from the datasource. Look it up if desired.

        @param fqdn: Boolean, set True to return hostname with domain.
        @param resolve_ip: Boolean, set True to attempt to resolve an ipv4
            address provided in local-hostname meta-data.
        @param metadata_only: Boolean, set True to avoid looking up hostname
            if meta-data doesn't have local-hostname present.

        @return: a DataSourceHostname namedtuple
            <hostname or qualified hostname>, <is_default> (str, bool).
            is_default is a bool and
            it's true only if hostname is localhost and was
            returned by util.get_hostname() as a default.
            This is used to differentiate with a user-defined
            localhost hostname.
            Optionally return (None, False) when
            metadata_only is True and local-hostname data is not available.
        ZlocaldomainZ	localhostFzlocal-hostnameNT�.rzip-%sr�rLz%s.%s)rGrNrVrr�Zget_fqdn_from_hosts�findr2rOr
Zis_ipv4_addressZ
gethostbyaddrrAr�r�)r(ZfqdnZ
resolve_ipZ
metadata_onlyZ	defdomainZdefhostZdomainrXZtoksrWZ
hosts_fqdnZlhostrrr!r�sF






zDataSource.get_hostnamecCs|jj|d�S)N)Zdata_source)rj�get_package_mirror_info)r(rrr!r�_sz"DataSource.get_package_mirror_info)�source_event_typescCsXi}xN|D]F}x@|jj�D]2\}}||kr|j|�s>t�||<||j|�qWq
W|S)N)�supported_update_eventsr<rN�set�add)r(r��supported_events�eventZupdate_scopeZ
update_eventsrrr!�get_supported_eventsbs


zDataSource.get_supported_events)r�r&cCs�|j|�}xH|j�D]<\}}tjd|jdjdd�|D���|jd|tff�qW|rp|j�|j�}|rpdStjd|djdd�|D���d	S)
a�Refresh cached metadata if the datasource supports this event.

        The datasource has a list of supported_update_events which
        trigger refreshing all cached metadata as well as refreshing the
        network configuration.

        @param source_event_types: List of EventTypes which may trigger a
            metadata update.

        @return True if the datasource did successfully update cached metadata
            due to source_event_type.
        z:Update datasource metadata and %s config due to events: %sz, cSsg|]
}|j�qSr)r')�.0r�rrr!�
<listcomp>�sz;DataSource.update_metadata_if_supported.<locals>.<listcomp>z
_%s_configTz(Datasource %s not updated for events: %scSsg|]
}|j�qSr)r')r�r�rrr!r��sF)	r�r<rxryr'r�r�r�r�)r(r�r�ZscopeZmatched_events�resultrrr!�update_metadata_if_supportedos"
z'DataSource.update_metadata_if_supportedcCsdS)NFr)r(rlrrr!�check_instance_id�szDataSource.check_instance_idcCsdS)acheck_if_fallback_is_allowed()
        Checks if a cached ds is allowed to be restored when no valid ds is
        found in local mode by checking instance-id and searching valid data
        through ds list.

        @return True if a ds allows fallback, False otherwise.
        Fr)r(rrr!rt�sz'DataSource.check_if_fallback_is_allowedcCsR|dkrt}|dkrt}x4|D],}|dkr,q||kr8|Stjd||�|SqW|S)Nz%invalid dsmode '%s', using default=%s)�DSMODE_NETWORK�
VALID_DSMODESrxr�)Z
candidates�defaultZvalid�	candidaterrr!�_determine_dsmode�s

zDataSource._determine_dsmodecCsdS)Nr)r(rrr!�network_config�szDataSource.network_configcCsdS)a(setup(is_new_instance)

        This is called before user-data and vendor-data have been processed.

        Unless the datasource has set mode to 'local', then networking
        per 'fallback' or per 'network_config' will have been written and
        brought up the OS at this point.
        Nr)r(�is_new_instancerrr!�setup�s	zDataSource.setupcCsdS)a�activate(cfg, is_new_instance)

        This is called before the init_modules will be called but after
        the user-data and vendor-data have been fully processed.

        The cfg is fully up to date config, it contains a merged view of
           system config, datasource config, user config, vendor config.
        It should be used rather than the sys_cfg passed to __init__.

        is_new_instance is a boolean indicating if this is a new instance.
        Nr)r(Zcfgr�rrr!�activate�szDataSource.activaterM)r]N)r^N)r_N)r`N)raN)rbN)
rcrdrerfr]rgrr_rhri)N)T)F)FFF)NN)\r*r+r,r�Zdsmoder�rmr�r�r�r�r#r.r1r0r/Znetwork_config_sourcesr	r�r�r�r�rrr�BOOT_NEW_INSTANCEZBOOTZBOOT_LEGACYZHOTPLUGr�Zdefault_update_eventsr�r�r2rr�r�rsZ_ci_pkl_versionrrrqr�r{r)�boolr}rr�r�r�r�r�r�r�r�r�r��propertyr�r�r�r�r�r�rr�r�r�r�r�r�r�r�r�r�r�r�r�r�r�r�rr�r�r�rt�staticmethodr�r�r�r�rrrr!r�s�


&
R<
					
H$
)�	metaclasscCs�g}|s|St|t�r|j�St|ttf�r4t|�St|t�r�xN|j�D]B\}}t|t�r`|g}t|ttf�rHx|D]}|rt|j|�qtWqHW|S)N)r?r2�
splitlines�listr�rBr<r>)Zpubkey_data�keysZ_keynameZklistZpkeyrrr!r��s 



r�)r&cCst|||�}dd�|D�}t|kr&dnd}	tjd|	|�x�t||�D]�\}
}tjd|
jdd�d	|	|
fd
|	|
f|d�}yV|�Htjd|�||||�}
|
jt	j
g�r�d
|	|
f|_|
tj
|�fSWdQRXWqDtk
r�tjtd|�YqDXqDWddj|�}t|��dS)NcSsg|]}tj|��qSr)rr|)r�r�rrr!r��szfind_source.<locals>.<listcomp>Znetworkrz#Searching for %s data source in: %sz	search-%srr6zsearching for %s data from %szno %s data found from %s)�name�description�message�parentz%Seeing if we can get any data from %szfound %s data from %szGetting data from %s failedz4Did not find any data source, searched classes: (%s)z, )�list_sources�DEP_NETWORKrxry�ziprZReportEventStackrAr�rr�rrr|r�rr�r�r4)rlrjrkZds_deps�cfg_list�pkg_listZreporter�ds_listZds_namesr�r�clsZmyrep�s�msgrrr!�find_source�s.


rcCs�g}tjd|||�xt|D]l}tj|�}tj||dg�\}}|sLtjd|�x8|D]0}tj|�}	t|	d�}
|
|�}|rR|j|�PqRWqW|S)z�Return a list of classes that have the same depends as 'depends'
    iterate through cfg_list, loading "DataSource*" modules
    and calling their "get_datasource_list".
    Return an ordered list of classes that match (if any)
    zLLooking for data source in: %s, via packages %s that matches dependencies %sZget_datasource_listzDCould not import %s. Does the DataSource exist and is it importable?)	rxryrZ"match_case_insensitive_module_name�find_module�error�
import_moduler�rD)r
�dependsrZsrc_listr%Zds_nameZm_locsZ_looked_locsZm_loc�modZlisterZmatchesrrr!rs,






r�system-uuid)�fieldr&cCs*|sdStj|�}|sdS|j�|j�kS)NF)rZ
read_dmi_datar=)r�rZ	dmi_valuerrr!�instance_id_matches_system_uuid9s
rcCsl|st}|st}|tkr(|tkr$|S|Sx2tj�D]&\}}|\}}|j|�r2||�r2|Sq2W|tkrh|S|S)z@Lookup the canonical cloud-id for a given cloud_name and region.)r��CLOUD_ID_REGION_PREFIX_MAPr<r@)r�r�r��prefixZ
cloud_id_testr�Zvalid_cloudrrr!r�Gsr�TcCsj|sdSt|t�r|St|t�r*tj|�St|t�rV|dkrNt|jd�dd�Std��tdt	|���dS)aLdata: a loaded object (strings, arrays, dicts).
    return something suitable for cloudinit vendordata_raw.

    if data is:
       None: return None
       string: return string
       list: return data
             the list is then processed in UserDataProcessor
       dict: return convert_vendordata(data.get('cloud-init'))
    NTz
cloud-initF)�recursez'vendordata['cloud-init'] cannot be dictz$Unknown data type for vendordata: %s)
r?r2rr:r;rB�convert_vendordatarNr�r�)�datarrrr!rZs



rc@seZdZdS)�BrokenMetadataN)r*r+r,rrrr!rrsrcCs8g}t|�}x&|D]\}}|t|�kr|j|�qW|S)N)r�r>)rrZret_listZdepsetr
Zdepsrrr!�list_from_depends}sr)rQ�fnamer&cCspytj|�}Wn"tk
r0tjtd|�dSXytj||ddd�Wn"tk
rjtjtd|�dSXdS)z[Use pickle to serialize Datasource to a file as a cache.

    :return: True on success
    zFailed pickling datasource %sF�wb�)Zomoder�z Failed pickling datasource to %sT)�pickle�dumpsr�rr�rxr�)rQr Zpk_contentsrrr!r��sr�)r r&cCs�d}ytj|dd�}Wn<tk
rR}z tjj|�rBtjd||�WYdd}~XnX|s\dSy
tj	|�St
k
rzdStk
r�tjtd|�dSXdS)zBUse pickle to deserialize a instance Datasource from a cache file.NF)�decodezfailed loading pickle in %s: %sz#Failed loading pickled blob from %s)rZ	load_filer�r�rR�isfilerxr�r#r�r3r�)r Zpickle_contentsrzrrr!�pkl_load�s 
r'cCs�tj�}tjd|�}tjd|�}tjd|�}|p6|p6|}|p>|}|rv|jd�j�}tjd|�d|��dd|�d	�d
�|r�|jd�r�|jd�SdS)z�Check if command line argument for this datasource was passed
    Passing by command line overrides runtime datasource detection
    zds=([^\s;]+)zci\.ds=([^\s;]+)zci\.datasource=([^\s;]+)rLz7Defining the datasource on the commandline using ci.ds=z or ci.datasource=z23.2zUse ds=z instead)�
deprecatedZdeprecated_versionZ
extra_messager6)rZget_cmdline�re�search�group�stripZ	deprecate)r$Z
ds_parse_0Z
ds_parse_1Z
ds_parse_2r%r(rmrrr!r~�s
r~)r)T)T�abcr:r�Zloggingr�r#r)�collectionsr�enumrrZtypingrrrrr	Z	cloudinitr
rrr
rrrorZcloudinit.atomic_helperrZcloudinit.distrosrZcloudinit.eventrrZcloudinit.filtersrZcloudinit.helpersrZcloudinit.persistencerZcloudinit.reportingrZDSMODE_DISABLEDZDSMODE_LOCALr�ZDSMODE_PASSr�ZDEP_FILESYSTEMrZ	DS_PREFIXr�ZREDACT_SENSITIVE_VALUEr�r�r�Z	getLoggerr*rxrr#r�r3r4r5rCrSrTrV�ABCMetarr�r2rrr�rr�r�IOErrorrrr�r'r~rrrr!�<module>s�



#
+%
	

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