__  __    __   __  _____      _            _          _____ _          _ _ 
 |  \/  |   \ \ / / |  __ \    (_)          | |        / ____| |        | | |
 | \  / |_ __\ V /  | |__) | __ ___   ____ _| |_ ___  | (___ | |__   ___| | |
 | |\/| | '__|> <   |  ___/ '__| \ \ / / _` | __/ _ \  \___ \| '_ \ / _ \ | |
 | |  | | |_ / . \  | |   | |  | |\ V / (_| | ||  __/  ____) | | | |  __/ | |
 |_|  |_|_(_)_/ \_\ |_|   |_|  |_| \_/ \__,_|\__\___| |_____/|_| |_|\___V 2.1
 if you need WebShell for Seo everyday contact me on Telegram
 Telegram Address : @jackleet
        
        
For_More_Tools: Telegram: @jackleet | Bulk Smtp support mail sender | Business Mail Collector | Mail Bouncer All Mail | Bulk Office Mail Validator | Html Letter private



Upload:

Command:

[email protected]: ~ $
�

x[hF����SSKrSSKrSSKrSSKrSSKrSSKJr SSKJrJ	r	J
r
 SSKJrJ
r
Jr SSKJr SSKJrJr SSKJr SSKJrJr SS	KJr SS
KJr SSKJr SSKJrJ r  SS
K!J"r" \RF"\$5r%Sr&Sr'"SS5r(Sr)\(RT/r+Sr,"SS\RZ5r."SS\.5r/Sr0Sr1Sr2Sr3Sr4Sr5Sr6Sr7S r8S!r9\ Rt4S"\\;\4S#\\;\;4S$\ S%\\;\<44S&jjr=S'\>S(\;S)\>S*\S+\?S,\<S%S4S-jr@SSS.\ Rt4S/jrAS0rBS1rC\/\R�44\.\R�\R�44/rFS2rGg)3�N)�suppress)�Dict�List�Literal)�dmi�net�sources)�
url_helper)�util�warnings)�Distro)�
EventScope�	EventType)�netplan)�NoDHCPLeaseError)�EphemeralIPNetwork)�HotplugRetrySettings�NicOrder)�ec2)�
datasource�Ec2�	strict_id�warnc�0�\rSrSrSrSrSrSrSrSr	Sr
S	rg
)�
CloudNames�$�aws�	brightbox�zstack�e24cloud�outscale�unknownzno-ec2-metadata�N)�__name__�
__module__�__qualname__�__firstlineno__�AWS�	BRIGHTBOX�ZSTACK�E24CLOUD�OUTSCALE�UNKNOWN�NO_EC2_METADATA�__static_attributes__r#��A/usr/lib/python3/dist-packages/cloudinit/sources/DataSourceEc2.pyrr$s)��
�C��I�
�F��H��H��G�(�Or0rc�L�URS:H=(a SUR;$)N�zmeta-data/tags/)�code�url)�	exceptions r1�skip_404_tag_errorsr73s ���>�>�S� �G�%6�)�-�-�%G�Gr0zS
ENV{ID_NET_DRIVER}=="vif|ena|ixgbevf", GOTO="cloudinit_hook"
GOTO="cloudinit_end"
c��^�\rSrSr%Sr/SQrSr/SQr\\	\
S'SrSrS	r
\RrS
r\R&\R*\R,\R.\R010r\R&\R*\R010r\r\"SSS
5rU4SjrS\ SS	4U4Sjjr!Sr"Sr#Sr$\%S5r&\%S5r'\%S5r(\%S5r)\%S5r*\%S5r+\%S5r,Sr-Sr.Sr/Sr0S r1\%S!5r2\%S"5r3S#r4\%S$5r5S%r6S-S&jr7S'\8RrS\:4S(jr;S'\8RrS\<S4S)jr=S'\8RrS\:4S*jr>S.S+jr?S,r@U=rA$)/�
DataSourceEc2�Br)zhttp://169.254.169.254zhttp://[fd00:ec2::254]zhttp://instance-data.:8773z
2009-04-04)z
2021-03-23z
2018-09-24z
2016-09-02�extended_metadata_versions���2NFT��c�t>�[[U]XU5 SUlSUl[
RUlg�N)�superr9�__init__�metadata_address�identityr�MAC�_fallback_nic_order)�self�sys_cfg�distro�paths�	__class__s    �r1rC�DataSourceEc2.__init__vs/���
�m�T�+�G�U�C� $�����
�#+�<�<�� r0�ci_pkl_version�returnc�>�[TU]U5 [Ul[R
Ul[SSS5Ulg)NTr>r?)	rB�	_unpickle�_EXTRA_HOTPLUG_UDEV_RULES�extra_hotplug_udev_rulesrrFrGr�hotplug_retry_settings)rHrNrLs  �r1rQ�DataSourceEc2._unpickle|s5���
���.�)�(A��%�#+�<�<�� �&:�4��B�&G��#r0c��[5$)z5Return the cloud name as identified during _get_data.)�identify_platform�rHs r1�_get_cloud_name�DataSourceEc2._get_cloud_name�s�� �"�"r0c�h�[[R"UR[[
5S5up[RSUURUR5 US:XaUR[R:XagUR[R:XagUR(a�[R"5(a[RS5 g[UR UR R"SSS9nUR%5Ul[RSUR((aS	UR(3OS
5 SSS5 OUR%5UlUR&(dgUR&R-SS5UlUR&R-SS5UlUR&R-S
05R-S05R-S05Ulg!,(df   N�=f![*a gf=f)N)rNz0strict_mode: %s, cloud_name=%s cloud_platform=%s�trueFz1FreeBSD doesn't support running dhclient with -sfT)�ipv4�ipv6zCrawled metadata service%s� ��	meta-data�	user-data�dynamic�instance-identity�document)�read_strict_moder�get_cfg_by_pathrI�STRICT_ID_PATH�STRICT_ID_DEFAULT�LOG�debug�
cloud_name�platformrr-r.�perform_dhcp_setup�
is_FreeBSDrrJ�fallback_interface�crawl_metadata�_crawled_metadata�	state_msgr�get�metadata�userdata_rawrE)rH�strict_mode�_sleep�netws    r1�	_get_data�DataSourceEc2._get_data�s���.�� � ����n�.?�
�
�	
���	�	�	�>���O�O��M�M�		
��&� �T�_�_�
�8J�8J�%J��
�_�_�
� :� :�
:���"�"���� � ��	�	�M�N��
�'��K�K��K�K�2�2���	�
�-1�-@�-@�-B�D�*��I�I�4�04���!�D�N�N�+�,�B����&*�%8�%8�%:�D�"��%�%���.�.�2�2�;��E��
� �2�2�6�6�{�D�I����"�"�&�&�y�"�5�
�S�$�b�
)�
�S��R�
 �	
�
�
�3���$�
��
�s1�)*H$�AH�H$�
H!�H$�!H$�$
H1�0H1c���UR(dgURRS05RS05nURS05R5H
up#SU;dM
 g g)z6Report if this instance type is Ec2 Classic (non-vpc).F�network�
interfaces�macszvpc-idT)rurt�items)rH�	ifaces_md�_mac�mac_datas    r1�is_classic_instance�!DataSourceEc2.is_classic_instance�sb���}�}���M�M�%�%�i��4�8�8��r�J�	�'�m�m�F�B�7�=�=�?�N�D��8�#��@�r0c�\�UR(dgURRS5$)Nzami-launch-index)rurtrXs r1�launch_index�DataSourceEc2.launch_index�s"���}�}���}�}� � �!3�4�4r0c��UR(d#[RR5UlUR$rA)�_platform_typer9�dsname�lowerrXs r1rm�DataSourceEc2.platform�s.���"�"�"/�"6�"6�"<�"<�">�D���"�"�"r0c��g)Nzlatest/api/tokenr#rXs r1�api_token_route�DataSourceEc2.api_token_route�s��!r0c��g)N�21600r#rXs r1�imdsv2_token_ttl_seconds�&DataSourceEc2.imdsv2_token_ttl_seconds�s��r0c��g)NzX-aws-ec2-metadata-tokenr#rXs r1�imdsv2_token_put_header�%DataSourceEc2.imdsv2_token_put_header�s��)r0c� �URS-$)Nz-ttl-seconds)r�rXs r1�imdsv2_token_req_header�%DataSourceEc2.imdsv2_token_req_header�s���+�+�n�<�<r0c�2�URUR/$rA)r�r�rXs r1�imdsv2_token_redact�!DataSourceEc2.imdsv2_token_redact�s���,�,�d�.J�.J�K�Kr0c�
�SnUR5nURH�nURURU5n[R
"UUURS9nURS:Xa[RSU5 Us $URS:Xa$Sn[RXcUR5 M�M� UR$![Ra!n[RSXG5 SnAM�SnAff=f)	aGet the best supported api version from the metadata service.

Loop through all extended support metadata versions in order and
return the most-fully featured metadata api version discovered.

If extended_metadata_versions aren't present, return the datasource's
min_metadata_version.
z{0}/{1}/meta-data/instance-id)r5�headers�headers_redact��z#Found preferred metadata version %sr3z0Metadata api version %s not present. Headers: %szurl %s raised exception %sN)
�_get_headersr;�formatrD�uhelp�readurlr�r4rjrkr��UrlError�min_metadata_version)rH�url_tmplr��api_verr5�resp�msg�es        r1�get_metadata_api_version�&DataSourceEc2.get_metadata_api_version�s���3���#�#�%���6�6�G��/�/�$�"7�"7��A�C�
:��}�}��#�#'�#;�#;����9�9��#��I�I�C�W�M�"�N��Y�Y�#�%�L�C��I�I�c�D�L�L�9�&�7�"�(�(�(���>�>�
@��	�	�6��?�?��
@�s� C
�
D�!C=�=Dc��UR[R:Xa�[USS5(deUR	5n[
R"UURURURURS9RS05UlURRSURS5$URS$)NrE��
headers_cbr��exception_cbre�
instanceIdzinstance-id)rlrr(�getattrr�r�get_instance_identityrDr�r��_refresh_stale_aws_token_cbrtrEru)rH�api_versions  r1�get_instance_id�DataSourceEc2.get_instance_ids����?�?�j�n�n�,��4��T�2�2�#�;�;�=�� #� 9� 9���)�)�#�0�0�#'�#;�#;�!%�!A�!A�!��#�j�"�%�
�
��=�=�$�$��d�m�m�M�:��
��=�=��/�/r0c�P�UR[;ag/n0nURnSnUH)nSRXd5nUR	U5 XcU'M+ [
R
S5 SnSnUR5n	[R"UU	RU	R[
RURURUURSS9	uphU(aU(a
X�lX6$[
R%SU5 g![R a NEf=f)z�Get an API token for EC2 Instance Metadata Service.

On EC2. IMDS will always answer an API token, unless
the instance owner has disabled the IMDS HTTP endpoint or
the network topology conflicts with the configured hop-limit.
N�PUT�{0}/{1}zFetching Ec2 IMDSv2 API TokenF)	�urls�max_wait�timeout�	status_cbr�r��request_methodr��connect_synchronouslyz$Unable to get response from urls: %s)rl� IDMSV2_SUPPORTED_CLOUD_PLATFORMSr�r��appendrjrk�get_url_paramsr��wait_for_url�max_wait_seconds�timeout_seconds�warningr��_token_exception_cbr�r��
_api_token�error)
rH�mdurlsr��url2base�url_pathr�r5�cur�response�
url_paramss
          r1�_maybe_fetch_api_token�$DataSourceEc2._maybe_fetch_api_tokens���?�?�"B�B�������'�'�����C��"�"�3�1�C��K�K����S�M��	�	�	�1�2������(�(�*�
�	�!�.�.��#�4�4�"�2�2��+�+��,�,�!�5�5�-�#�7�7�&+�
�M�C� �8�&�O��=� �	�	�	�8�$�?����~�~�	�
�	�s�AD�D%�$D%c
�
�/nSnURnUR5nURS::agURSUR5nUVs/sH"n[
R"U5(dM UPM$ nn[U5[U5:wa4[RS[[U5[U5-
55 [U5(aUnO![RS5 URnURU5nU(d�UR[;a�0n	SR!UR"S9n
SnUH)nS	R!X�5n
UR%U
5 X�U
'M+ [&R("5n[*R,"UURUR.[RUR0UR2US
9up�U(aX�nU(a'X�l[RSUR45 O`UR[;a[RS5 O6[R7S
U[9[&R("5U-
55 [;U5$s snf)NrF�
metadata_urlsz,Removed the following from metadata urls: %sz+Empty metadata url list! using default listz{ver}/meta-data/instance-id)�ver�GETr�)r�r�r�r�r�r�r�zUsing metadata source: '%s'z)IMDS's HTTP endpoint is probably disabledz(Giving up on md from %s after %s seconds)�ds_cfgr�r�rtr�r�is_resolvable_url�setrjrk�list�lenr�r�rlr�r�r�r��time�	monotonicr�r�r�r�r�rD�critical�int�bool)rHr��
start_time�mcfgr�r��x�filteredrDr�r�r�r5r��_s               r1�wait_for_metadata_service�'DataSourceEc2.wait_for_metadata_serviceMs�����
��{�{���(�(�*�
��&�&�!�+�����/�4�+=�+=�>��%�C�v�!��)?�)?��)B�A�v��C��x�=�C��K�'��I�I�>��c�&�k�C��M�1�3�
�
�x�=�=��F��K�K�E�F��'�'�F� �6�6�v�>��!����'G�G��H�4�;�;��-�-�<��H�#�N����&�&�s�5�����C� � #��
��
���)�J��'�'��#�4�4�"�2�2��+�+�#�7�7��,�,�-��F�C��#+�=� ��$4�!��I�I�3�T�5J�5J�K�
�_�_� @�
@��K�K�C�D��L�L�:���D�N�N�$�z�1�2�
��$�%�%��{Ds�J�5Jc�l�SUR;agSnURSn[U[5(d[R	SU5 gUR5H upEXA:XaUn OUS:XdMUS:XdMUnM" Uc[R	SU5 gUnUR
S5(dSU-n[RRU5(aU$UR[RRU55nU(a[R	SX'5 U$US:XagU$)	Nzblock-device-mappingz+block-device-mapping not a dictionary: '%s'�	ephemeral�
ephemeral0z Unable to convert %s to a device�/z/dev/%szRemapped device name %s => %s)ru�
isinstance�dictrjrkr��
startswith�os�path�exists�
_remap_device�basename)rH�name�found�bdm�entname�device�ofound�remappeds        r1�device_name_to_device�#DataSourceEc2.device_name_to_device�s��"����6�����m�m�2�3���#�t�$�$��I�I�C�S�I��"�y�y�{�O�G�������+�%�$�,�*>���
 +��=��I�I�8�$�?��������$�$���%�E�
�7�7�>�>�%� � ��L��%�%�b�g�g�&6�&6�u�&=�>����I�I�5�u�G��O��<����
r0c���UR[R:Xa,URR	SUR
SS5$UR
SS$![a gf=f)N�availabilityZone�	placementzavailability-zone)rlrr(rErtru�KeyErrorrXs r1�availability_zone�DataSourceEc2.availability_zone�sl��		����*�.�.�0��}�}�(�(�&��M�M�+�.�/B�C���
�}�}�[�1�2E�F�F���	��	�s�A	A�A�
A+�*A+c���UR[R:XaDURR	S5nUR
(aU(dUR
SSnU$UR
nUbUSS$g)N�region���)rlrr(rErtr)rHr�azs   r1r�DataSourceEc2.region�sf���?�?�j�n�n�,��]�]�&�&�x�0�F��%�%�f��/�/���4���M��'�'�B��~��#�2�w��r0c��U(dgUR[R:Xa+[[R
"U[[5U5 ggrA)rlrr-�warn_if_necessaryrrgrhri)rH�cfg�is_new_instances   r1�activate�DataSourceEc2.activate�s=�����?�?�j�0�0�0���$�$�S�.�:K�L��
�1r0c
�\�UR[R:waUR$URc[RS5 gSnURRnURRS5n[U[5(a�[UURU[R"URSS5URS9nUR!5(a�["R$"UR&5UlUR&[(R*R-[.R05 UR&[(R*R-[.R25 O[RSU5 XlUR$)z@Return a network config dict for rendering ENI or netplan files.Nz8Unexpected call to network_config when metadata is None.r}�apply_full_imds_network_configT)�fallback_nic�full_network_config�fallback_nic_orderz%Metadata 'network' key not valid: %s.)�_network_configr	�UNSETrurjr�rJrprtr�r��#convert_ec2_metadata_network_configr�get_cfg_option_boolr�rGr��copy�deepcopy�default_update_eventsr�NETWORK�addr�BOOT�BOOT_LEGACY)rH�result�iface�net_mds    r1�network_config�DataSourceEc2.network_config�sT�����7�=�=�0��'�'�'��=�=� ��K�K�J�
�������.�.�����"�"�9�-���f�d�#�#�9�����"�$(�$<�$<��K�K�!A�4�%�$(�#;�#;��F��'�'�)�)�-1�]�]��.�.�.��*��*�*�:�+=�+=�>�B�B��N�N���*�*�:�+=�+=�>�B�B��)�)���
�K�K�?��H�%���#�#�#r0c	�.�UR5(d0$UR5nURn0nUR[;aUR
nURnSnO-UR[R:Xa
S=pE[nOS=n=pV[R"UURURUUS9n[R"U5US'[R "UURURUUUS9US'UR[R":Xa3[R$"UURURUUS9nSU0US'XS	'U$![&a+ [R("[*SUR5 0s$f=f)
z�Crawl metadata service when available.

@returns: Dictionary of crawled metadata content containing the keys:
  meta-data, user-data and dynamic.
Nr�rb)r�r�r��retrieval_exception_ignore_cbrardrcz'Failed reading from metadata address %s�_metadata_api_version)r�r�r�rlr�r��#_skip_or_refresh_stale_aws_token_cbrr,r7r�get_instance_userdatarDr�r�maybe_b64decode�get_instance_metadatar(r��	Exception�logexcrj)	rHr��redact�crawled_metadata�exc_cb�	exc_cb_ud�skip_cb�raw_userdatarEs	         r1rq�DataSourceEc2.crawl_metadatas����-�-�/�/��I��3�3�5���)�)�����?�?�>�>��5�5�F��@�@�I��G�
�_�_�
� 3� 3�
3�!%�%�F�)�G�+/�/�F�/�Y� 	��4�4���%�%��,�,�%�&��L�-1�,@�,@��,N��[�)�,/�,E�,E���%�%��,�,�%�#�.5�
-��[�)����*�.�.�0��4�4���)�)�#�0�0�#)�!'���0C�H�.M� ��+�5@�0�1�����	��K�K��9��%�%�
�
�I�
	�s�CE�2F�Fc��UR[;agUcURn[R	S5 UR
U0nSR
URUR5n[R"UUURSS9nUR$![Ra n[RSX55 SnAgSnAff=f)z�Request new metadata API token.
@param seconds: The lifetime of the token in seconds

@return: The API token or None if unavailable.
Nz!Refreshing Ec2 metadata API tokenz{}/{}r�)r�r�r�z/Unable to get API token: %s raised exception %s)rlr�r�rjrkr�r�rDr�r�r�r�r�r��contents)rH�seconds�request_header�	token_urlr�r�s      r1�_refresh_api_token� DataSourceEc2._refresh_api_tokenVs����?�?�"B�B���?��3�3�G��	�	�5�6��6�6��@���N�N�4�#8�#8�$�:N�:N�O�	�	��}�}��&�#�7�7�$�	�H�� � � ���~�~�	��K�K�A�9�
���		�s�/!B�C�0C�Cr6c�~�[R"[RU5nU(dgURU5$)zKCallback will not retry on SKIP_USERDATA_CODES or if no token
is available.F)r�skip_retry_on_codes�SKIP_USERDATA_CODESr�)rHr6�retrys   r1r(�1DataSourceEc2._skip_or_refresh_stale_aws_token_cbss3��
�'�'��(?�(?��K�����/�/�	�:�:r0c�\�URS:Xa[RS5 SUlg)z=Exception handler for Ec2 to refresh token if token is stale.i�z+Clearing cached Ec2 API token due to expiryNT)r4rjrkr��rHr6s  r1r��)DataSourceEc2._refresh_stale_aws_token_cb}s'���>�>�S� ��I�I�C�D�"�D�O�r0c���UR(a]URS:Xa[RS5 gURS:XagURS:�a[RS5 gg)a�Fail quickly on proper AWS if IMDSv2 rejects API token request

Guidance from Amazon is that if IMDSv2 had disabled token requests
by returning a 403, or cloud-init malformed requests resulting in
other 40X errors, we want the datasource detection to fail quickly
without retries as those symptoms will likely not be resolved by
retries.

Exceptions such as requests.ConnectionError due to IMDS being
temporarily unroutable or unavailable will still retry due to the
callsite wait_for_url.
i�zLEc2 IMDS endpoint returned a 403 error. HTTP endpoint is disabled. Aborting.Fi�i�z2Fatal error while requesting Ec2 IMDSv2 API tokensT)r4rjr�rBs  r1r��!DataSourceEc2._token_exception_cb�s_���>�>��~�~��$����;������3�&�����3�&����H���r0c�$�UR[;a0$URUR0nURU;aU$UR
(d(UR
5UlUR
(d0$URUR
0$)z�Return a dict of headers for accessing a url.

If _api_token is unset on AWS, attempt to refresh the token via a PUT
and then return the updated token header.
)rlr�r�r�r�r�r:r�)rHr5�request_token_headers   r1r��DataSourceEc2._get_headers�s����?�?�"B�B��I�
�(�(�$�*G�*G� 
�����3�&�'�'����#�5�5�7�D�O��?�?��	��,�,�d�o�o�>�>r0)r�rrrGrr�rrSrTrErurDrvrA)r`)Br$r%r&r'r�r�r�r;r�str�__annotations__�url_max_wait�url_timeoutr�r	rrrnrrr�BOOT_NEW_INSTANCErr�HOTPLUG�supported_update_eventsrrRrSrrTrCr�rQrYrzr��propertyr�rmr�r�r�r�r�r�r�r�r�r�rrrr#rqr:r�r�r�r(rr�r�r�r/�
__classcell__�rLs@r1r9r9BsA���
�F��M�(��
-���S�	���L��K��J��m�m�O���	����'�'��N�N��!�!����	
���	����'�'����
��� 9��1�$��2�>��0�H��H��H�#�1�f��5��5�
�#��#��"��"������*��*��=��=��L��L�)�>0�(1�fH&�T1�f�
��
�������-$��-$�^6 �p!�:;����;�	
�;������	�����U�^�^����>?�?r0r9c�0^�\rSrSrSrSrU4SjrSrU=r$)�DataSourceEc2Locali�aeDatasource run at init-local which sets up network to query metadata.

In init-local, no network is available. This subclass sets up minimal
networking with dhclient on a viable nic so that it can talk to the
metadata service. If the metadata service provides network configuration
then render the network configuration for that instance based on metadata.
Tc��>�[R[R4nURU;a"[RSUUR5 g[[U]#5$)Nz+Local Ec2 mode only supported on %s, not %sF)	rr(r,rlrjrkrBrT�get_data)rH�supported_platformsrLs  �r1rV�DataSourceEc2Local.get_data�sT���)�~�~�z�/B�/B�C���?�?�"5�5��I�I�=�#����
�
��'��7�9�9r0r#)	r$r%r&r'�__doc__rnrVr/rQrRs@r1rTrT�s������	:�	:r0rTc�v�[U5$![a!n[RU5 UsSnA$SnAff=frA)�parse_strict_mode�
ValueErrorrjr�)�cfgval�defaultr�s   r1rfrf�s2��� ��(�(�������A������s�

�
8�3�8�8c�
�USLagUSLagU(dgURS5upnUS;a[SU<S	U<S
35eU(a[U5nX4$SnX4$![an[SU<S	U<S35UeSnAff=f)
NT)r\NF)�falseN)rr�,)r\r`rzInvalid mode 'z' in strict_id setting 'z+': Expected one of 'true', 'false', 'warn'.zInvalid sleep 'z': not an integer)�	partitionr\r�)r]�moder��sleepr�s     r1r[r[�s�����~��
�������%�%�c�*�N�D�U��,�,��:>��
H�
�	
�

�	���J�E��;�����;����	���&�"���
��	�s�A�
B�(A=�=Bc��[U5up#US:Xag[R
"SUSUS9 g![an[RU5 SnAgSnAff=f)Nr`�
non_ec2_mdT)rcrd)r[r\rjr�r�show_warning)r]rrcrdr�s     r1rr�sS���'��/���
�w������,��$�e�D�������A�����s�
.�
A�A�Ac�d�USnURS5(a[R$[[5 [
R"U5RR5RS5(a[RsSSS5 $SSS5 g!,(df   g=f)N�uuidr)	r�rr(rr\ri�UUID�bytes_le�hex)�data�uuid_strs  r1�identify_awsros����F�|�H����5�!�!��~�~��	�*�	��9�9�X��'�'�+�+�-�8�8��?�?��>�>�
�	�?�
��

�	��s�AB!�!
B/c�V�USRS5(a[R$g)N�serialz.brightbox.com)�endswithrr)�rms r1�identify_brightboxrts)���H�~���/�0�0��#�#�#�1r0c�V�USRS5(a[R$g)N�	asset_tagz
.zstack.io)rrrr*rss r1�identify_zstackrw s)���K��!�!�,�/�/�� � � �0r0c�6�USS:Xa[R$g)N�vendorr )rr+rss r1�identify_e24cloudrz%s���H�~��#��"�"�"�$r0c��USSR5:Xa(USSR5:Xa[R$gg)N�product_namez3DS Outscale VMryz3DS Outscale)r�rr,rss r1�identify_outscaler}*sD���^�� 1� 7� 7� 9�9���N�n�2�2�4�4��"�"�"�
5�	:r0c���[5n[[[[[
S4nUHnU"U5nU(aUs $M g![a"n[RSX U5 SnAMCSnAff=f)Nc�"�[R$rA)rr-)r�s r1�<lambda>�#identify_platform.<locals>.<lambda>;s
��*�$�$r0z'calling %s with %s raised exception: %s)	�_collect_platform_datarortrwrzr}r,rjr�)rm�checks�checkerr r�s     r1rWrW2st��!�#�D������$�
�F���	��T�]�F���
����
�	��K�K�9�7�!�
�
��	�s�A�
A2�A-�-A2c��Sn[[[5 [R"S5R5nSSS5 U=(d [R"S5=(d Sn[R"S5=(d Sn[R"S5=(d Sn[R"S5=(d Sn[R"S5=(d SnUR"5UR5UR5UR5UR5S	.$!,(df   GN=f)
a"Returns a dictionary of platform info from dmi or /sys/hypervisor.

Keys in the dictionary are as follows:
   uuid: system-uuid from dmi or /sys/hypervisor
   serial: dmi 'system-serial-number' (/sys/.../product_serial)
   asset_tag: 'dmidecode -s chassis-asset-tag'
   vendor: dmi 'system-manufacturer' (/sys/.../sys_vendor)
   product_name: dmi 'system-product-name' (/sys/.../system-manufacturer)

On Ec2 instances experimentation is that product_serial is upper case,
and product_uuid is lower case.  This returns lower case values for both.
Nz/sys/hypervisor/uuidzsystem-uuidr`zsystem-serial-numberzchassis-asset-tagzsystem-manufacturerzsystem-product-name�rirqrvryr|)	r�OSError�UnicodeDecodeErrorr�load_text_file�stripr�
read_dmi_datar�r�s     r1r�r�Hs����D�	�'�-�	.��"�"�#9�:�@�@�B��
/��9�3�$�$�]�3�9�r�D�
�
�
�5�
6�
<�"�F��!�!�"5�6�<�"�I�
�
�
�4�
5�
;��F��$�$�%:�;�A�r�L��
�
���,�,�.��_�_�&��,�,�.�$�*�*�,���
/�	.�s�%D7�7
E�
macs_metadata�macs_to_nicsrrOc	�^^^^	�0nT(aT(dU$[S[UU4SjTR555nSm	[[	UU	U4SjS95VVVVs0sHunupgnXe_M
 snnnn$s snnnnf)a%
Builds a dictionary containing macs as keys and nic orders as values,
taking into account `network-card` and `device-number` if present.

Note that the first NIC will be the primary NIC as it will be the one with
[network-card] == 0 and device-number == 0 if present.

@param macs_metadata: dictionary with mac address as key and contents like:
{"device-number": "0", "interface-id": "...", "local-ipv4s": ...}
@macs_to_nics: dictionary with mac address as key and nic name as value

@return: Dictionary with macs as keys and nic orders as values.
c��USSL$)N�r#)�mmds r1r��"_build_nic_order.<locals>.<lambda>�s
��C��F�$�&r0c�2>�UTRU5TU4$rA)rt)�macr�r�s ��r1r�r��s����m�/�/��4�l�3�6G�Hr0c�F�URUS5nUb[U5$U$rA)rtr�)�dikt�key�	alt_value�values    r1�_get_key_as_int_or�,_build_nic_order.<locals>._get_key_as_int_or�s(������d�#�����u�:���r0c�>�T"USS[S55T"USS[S55T[R:XaUS4$US4$)Nr�znetwork-card�infinity�
device-number�r)�floatr�NIC_NAME)r�r�rs ��r1r�r��sa���&��A����j�0A��'��A����z�1B��
.��1B�1B�B��A��!�!��V�!r0)r�)�filter�map�keys�	enumerate�sorted)
r�r�r�	nic_order�valid_macs_metadata�ir��
_mac_metadata�	_nic_namer�s
```      @r1�_build_nic_orderr�hs����$!#�I��-��� �&��H�����	
�	���3<��#��
�3
��3
�.�A�.��I�	��3
����s�!A9
�
dev_config�nic_name�nic_metadatarJ�is_ipv4�tablec�$�U(a#URS5nURS5nO"URS5nURS5nU(aU(d [RSU(aSOS5 gURS	5(d/US	'U(a7URR	XS
9nUSn	US	RSU	US
.5 [U[5(aU/OUnUHnUS	RUUS.5 M URS5(d/US'[U[5(aU/OUnUHnUSRUUS.5 M g![a!n
[RSUU
5 Sn
A
N�Sn
A
ff=f)a�
Configure policy-based routing on secondary NICs / secondary IPs to
ensure outgoing packets are routed via the correct interface.

@param: dev_config: network cfg v2 to be updated inplace.
@param: nic_name: nic name. Only used if ipv4.
@param: nic_metadata: nic metadata from IMDS.
@param: distro: Instance of Distro. Only used if ipv4.
@param: is_ipv4: Boolean indicating if we are acting over ipv4 or not.
@param: table: Routing table id.
�subnet-ipv4-cidr-block�local-ipv4szsubnet-ipv6-cidr-blocks�ipv6szANot enough IMDS information to configure policy routing for IPv%s�4�6N�routes)rJ�routersz	0.0.0.0/0)�to�viar�zoCould not perform dhcp discovery on %s to find its gateway. Not adding default route via the gateway. Error: %s)r�r��routing-policy)�fromr�)
rtrjrk�dhcp_client�dhcp_discoveryr�rr�r�rI)
r�r�r�rJr�r��subnet_prefix_routes�ips�lease�gatewayr��prefix_route�ips
             r1�_configure_policy_routingr��s���(�+�/�/�0H�I�����}�-��+�/�/�0I�J�����w�'�� �S��	�	�
��C��	
�
	��>�>�(�#�#�!�
�8���	��&�&�5�5�h�5�N�E��I�&�G�
�x� �'�'�%�"�"��
��*�C�0�0�
��
!��
-���8��#�#�"��
�	
�-��>�>�*�+�+�')�
�#�$��c�3�'�'�3�%�S�C����#�$�+�+���
�	
���I �	��K�K����
�
��	�s�E$�$
F�.F
�
FTc
�
�S0S.nU(d[R"5nUSSnU(dlUR5Hup�X�:XdM O SSSWR50W	S.n
UR	U5nUR	S	5(aSU
S
'X�SU	'U$[UR[R5n[XrU5n
[UR55nUGHnX(n	UR	U5nU(dM"X�nUS:HnS
US-S-0nSUSSUR50U	S.n
SU-nU(a0UR	S5(aU(dSUS'[U
UU	USUS9 UR	S	5(a<SU
S
'UU
S'U(a+UR	S5(aU(d[U
UU	USUS9 [X�5U
S'U
S(dU
RS5 X�SU	'GM [US5S:XayUSR5Hbn	USU	RS5 USU	RSS5 USU	RSS5 USU	RSS5 Md U$)a�Convert ec2 metadata to network config version 2 data dict.

@param: network_md: 'network' portion of EC2 metadata.
   generally formed as {"interfaces": {"macs": {}} where
   'macs' is a dictionary with mac address as key and contents like:
   {"device-number": "0", "interface-id": "...", "local-ipv4s": ...}
@param: distro: instance of Distro.
@param: macs_to_nics: Optional dict of mac addresses and nic names. If
   not provided, get_interfaces_by_mac is called to get it from the OS.
@param: fallback_nic: Optionally provide the primary nic interface name.
   This nic will be guaranteed to minimally have a dhcp4 configuration.
@param: full_network_config: Boolean set True to configure all networking
   presented by IMDS. This includes rendering secondary IPv4 and IPv6
   addresses on all NICs and rendering network config on secondary NICs.
   If False, only the primary nic will be configured and only with dhcp
   (IPv4/IPv6).

@return A dict of network config version 2 based on the metadata and macs.
r�)�version�	ethernetsr~rTF�
macaddress)�dhcp4�dhcp6�match�set-namer�r�r�rzroute-metricr��d)r��dhcp4-overridesr�r�r�r�z
use-routes)rJr�r�r�r�zdhcp6-overrides�	addressesr�Nr�r�)r�get_interfaces_by_macr�r�rtr��network_rendererr�Rendererr�r�r�r��get_secondary_addresses�popr�)�
network_mdrJr�rrr�netcfgr�r�r�r�r��
is_netplanr�r�nic_idx�is_primary_nic�
dhcp_overrider�s                   r1rrs���6��
,�F���0�0�2���|�,�V�4�M��)�/�/�1�M�C��'��2���"�C�I�I�K�0� �	
�
�%�(�(��-�����G�$�$�"&�J�w��(2�{��H�%��
��F�3�3�W�5E�5E�F�J� ��%7��I��,�#�#�%�&�D����$��$�(�(��-�����.�� �A���'�'�A�+��)<�=�
��,��"�C�I�I�K�0� �
�
��g�
���� � ��1�1�"�*.�M�,�'�%���!�)���

����G�$�$�"&�J�w��,9�J�(�)�� �$�$�_�5�5�&�)��!�%�!-�!��
�#:�,�"L�
�;���+�&��N�N�;�'�(2�{��H�%�w�|�6�+���1�$��{�+�0�0�2�H��;���)�-�-�.?�@��;���)�-�-�.?��F��;���)�-�-�h��=��;���)�-�-�.>��E�	3�
�Mr0c	��URS5nURS5n/n[[U[5=(a [	U5S:�5(aUR[
USXS55 [[U[5=(a [	U5S:�5(aUR[
USXS55 [U5$)z�Parse interface-specific nic metadata and return any secondary IPs

:return: List of secondary IPv4 or IPv6 addresses to configure on the
interface
r�r�r�r��24zsubnet-ipv6-cidr-block�128)rtr�r�r�r��extend�_get_secondary_addressesr�)r�r��ipv4sr�r�s     r1r�r�|s���
���]�+�E����W�%�E��I��J�u�d�#�6��E�
�Q��7�7����$��6��D�
�	
�
�J�u�d�#�6��E�
�Q��7�7����$��6��E�
�	
�
�)��r0c�@�/nURU5nUnU(a[URS55S:wa%SU;aSOSn[R	SUUUUU5 OURS5SnUSSH!n	URSR
X�S	95 M# U$)
z�Return list of IP addresses as CIDRs for secondary IPs

The CIDR prefix will be default_prefix if cidr_key is absent or not
parseable in nic_metadata.
r�r�r]r^zJCould not parse %s %s for mac %s. %s network config prefix defaults to /%sr�Nz
{ip}/{prefix})r��prefix)rtr��splitrjr�r�r�)
r��cidr_keyr�r��default_prefixr��cidrr��ip_typer�s
          r1r�r��s����I����H�%�D�
�F��3�t�z�z�#��'�1�,�"�h�.�&�F�����
-������	
����C���#���!�"�g������/�/�2�/�E�F���r0c�8�[R"U[5$rA)r	�list_from_depends�datasources)�dependss r1�get_datasource_listr��s���$�$�W�k�:�:r0)Hr�loggingr�r�ri�
contextlibr�typingrrr�	cloudinitrrr	r
r�rr�cloudinit.distrosr
�cloudinit.eventrr�
cloudinit.netr�cloudinit.net.dhcpr�cloudinit.net.ephemeralr�cloudinit.sourcesrr�cloudinit.sources.helpersr�	getLoggerr$rjrhrirr7r(r�rR�
DataSourcer9rTrfr[rrortrwrzr}rWr�rFrIr�r�r�r�r�rr�r��DEP_FILESYSTEM�DEP_NETWORKr�r�r#r0r1�<module>r�s�����	����&�&�'�'�)�$�$�1�!�/�6�<�)�
����!��3����(�(�H�
%/�N�N�#3� ���y	?�G�&�&�y	?�x:��:�.��B
E�
� $�
!�
#�
#��,�F$,�<�<�@���T�	�?�@��s�C�x�.�@�!�@�
�#�s�(�^�	@�FR
��R
��R
��	R
�

�R
��
R
��R
�
�R
�p����|�|�
y�x�2�<�'�0�0�2�3��W�+�+�W�-@�-@�A�B���;r0

Filemanager

Name Type Size Permission Actions
DataSourceAkamai.cpython-313.pyc File 12.33 KB 0644
DataSourceAliYun.cpython-313.pyc File 18.33 KB 0644
DataSourceAltCloud.cpython-313.pyc File 9.85 KB 0644
DataSourceAzure.cpython-313.pyc File 79.75 KB 0644
DataSourceBigstep.cpython-313.pyc File 2.86 KB 0644
DataSourceCloudCIX.cpython-313.pyc File 7.22 KB 0644
DataSourceCloudSigma.cpython-313.pyc File 5.18 KB 0644
DataSourceCloudStack.cpython-313.pyc File 13.11 KB 0644
DataSourceConfigDrive.cpython-313.pyc File 14.2 KB 0644
DataSourceDigitalOcean.cpython-313.pyc File 6.2 KB 0644
DataSourceEc2.cpython-313.pyc File 43.31 KB 0644
DataSourceExoscale.cpython-313.pyc File 8.9 KB 0644
DataSourceGCE.cpython-313.pyc File 16.12 KB 0644
DataSourceHetzner.cpython-313.pyc File 6.46 KB 0644
DataSourceIBMCloud.cpython-313.pyc File 18.43 KB 0644
DataSourceLXD.cpython-313.pyc File 20.3 KB 0644
DataSourceMAAS.cpython-313.pyc File 18.29 KB 0644
DataSourceNWCS.cpython-313.pyc File 6.76 KB 0644
DataSourceNoCloud.cpython-313.pyc File 17.26 KB 0644
DataSourceNone.cpython-313.pyc File 1.88 KB 0644
DataSourceOVF.cpython-313.pyc File 15.34 KB 0644
DataSourceOpenNebula.cpython-313.pyc File 18.96 KB 0644
DataSourceOpenStack.cpython-313.pyc File 13.1 KB 0644
DataSourceOracle.cpython-313.pyc File 21.77 KB 0644
DataSourceRbxCloud.cpython-313.pyc File 10.25 KB 0644
DataSourceScaleway.cpython-313.pyc File 17.07 KB 0644
DataSourceSmartOS.cpython-313.pyc File 38.32 KB 0644
DataSourceUpCloud.cpython-313.pyc File 7.11 KB 0644
DataSourceVMware.cpython-313.pyc File 35.8 KB 0644
DataSourceVultr.cpython-313.pyc File 5.79 KB 0644
DataSourceWSL.cpython-313.pyc File 15.48 KB 0644
__init__.cpython-313.pyc File 47.24 KB 0644
Filemanager