403Webshell
Server IP : 159.69.118.108  /  Your IP : 216.73.216.231
Web Server : Apache/2.4.58 (Ubuntu)
System : Linux ubuntu-4gb-fsn1-1 6.8.0-90-generic #91-Ubuntu SMP PREEMPT_DYNAMIC Tue Nov 18 13:53:54 UTC 2025 aarch64
User : root ( 0)
PHP Version : 8.2.32
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /lib/python3/dist-packages/cloudinit/sources/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/cloudinit/sources/__pycache__/DataSourceCloudStack.cpython-312.pyc
�

��im2���ddlZddlZddlZddlmZddlmZmZmZddl	m
Z
ddlmZm
Z
mZmZddlmZddlmZddlmZdd	lmZdd
lmZddlmZej6e�ZdZGd
�d�ZGd�dej@�Z!Gd�de!�Z"d�Z#d�Z$d�Z%de&fd�Z'e"ejPffe!ejPejRffgZ*d�Z+y)�N)�suppress)�gaierror�getaddrinfo�	inet_ntoa)�pack)�dmi�net�performance�sources)�
url_helper)�util)�dhcp)�NoDHCPLeaseError)�EphemeralIPNetwork)�ec2�
CloudStackc�P�eZdZdZd�Zd�Zejdd��d��Zy)	�CloudStackPasswordServerClienta�
    Implements password fetching from the CloudStack password server.

    http://cloudstack-administration.readthedocs.org/
       en/latest/templates.html#adding-password-management-to-your-templates
    has documentation about the system.  This implementation is following that
    found at
    https://github.com/shankerbalan/cloudstack-scripts/
       blob/master/cloud-set-guest-password-debian
    c��||_y�N)�virtual_router_address)�selfrs  �H/usr/lib/python3/dist-packages/cloudinit/sources/DataSourceCloudStack.py�__init__z'CloudStackPasswordServerClient.__init__/s
��&<��#�c���d|j�d�}d|i}tj||dd��}|j�st	d��|j
j
d�j�S)	N�http://z:8080�DomU_Request��)�headers�timeout�retriesz+Failed to fetch VM password from CloudStackzutf-8)r�uhelp�readurl�ok�RuntimeError�contents�decode�strip)r�domu_request�urlr!�resps     r�_do_requestz*CloudStackPasswordServerClient._do_request2sh����3�3�4�E�:��!�<�0���}�}�S�'�2�q�I���w�w�y��L�M�M��}�}�#�#�G�,�2�2�4�4rzGetting password�always��log_modec�t�|jd�}|dvry|dk(rtd��|jd�|S)N�send_my_password)��saved_password�bad_requestz-Error when attempting to fetch root password.r5)r.r')r�passwords  r�get_passwordz+CloudStackPasswordServerClient.get_password=sG���#�#�$6�7���-�-���}�$��N�O�O����)�*��rN)	�__name__�
__module__�__qualname__�__doc__rr.r
�timedr8�rrrr#s5��	�=�	5��[���)�H�=��>�rrc���eZdZdZdZdZdZ�fd�Zd�Z			d�fd�	Z	d�Z
d	�Zed
e
fd��Zd�Zej"d
d��d��Zd�Zed��Z�xZS)�DataSourceCloudStackFr�x�2c���t�|�|||�tjj	|j
d�|_d|_i|_d|_y)N�cs�latest)	�superr�os�path�join�seed_dir�api_ver�cfg�vr_addr)r�sys_cfg�distro�paths�	__class__s    �rrzDataSourceCloudStack.__init__PsE���
����&�%�0������U�^�^�T�:��
� ��������rc�*�tjd�dD]+}tj|�}|s�|j	�cStjd�ttj�5tj�j|jd�}|r|j	�cddd�S	ddd�tjd|jjj�	|jjj|jj�}|jd�}|r|j	�S	tjd�y#1swY��xYw#tt t"f$rY�8wxYw)	z�Try obtaining a "domain-name" DHCP lease parameter:
        - From systemd-networkd lease (case-insensitive)
        - From ISC dhclient
        - From dhcpcd (ephemeral)
        - Return empty string if not found (non-fatal)
        z.Try obtaining domain name from networkd leases)�
DOMAINNAME�Domain�domain-namezHCould not obtain FQDN from networkd leases. Falling back to ISC dhclientrUNzBCould not obtain FQDN from ISC dhclient leases. Falling back to %sz7No domain name found in any DHCP lease; returning emptyr4)�LOG�debugr�networkd_get_option_from_leasesr*r�NoDHCPLeaseMissingDhclientError�IscDhclient�get_key_from_latest_leaserO�dhcp_client�client_name�get_newest_lease�fallback_interface�getr�FileNotFoundError�AttributeError)r�key�
domainname�domain_name�latest_leases     r�_get_domainnamez$DataSourceCloudStack._get_domainnameYsd��	�	�	�B�C�:�	*�C��=�=�c�B�J��!�'�'�)�)�	*�
	�	�	�
�	
��d�:�:�
;�	+��*�*�,�F�F����]��K��"�(�(�*�	+�	+��		+�	�	�	�
��K�K�#�#�/�/�	
�
	��;�;�2�2�C�C����.�.��L�'�*�*�=�9�K��"�(�(�*�*��
	�	�	�K�L��/	+�	+��&!�"3�^�D�	��	�s �4AE/�<AE;�/E8�;F�Fc�R��t�|�|||�}|r�d|jvr�tj	d�|j�}|rG|j�d|��}tj	d|�t
j||j�Stj	d|�|S)z�
        Returns instance's hostname / fqdn
        First probes the parent class method.

        If fqdn is requested, and the parent method didn't return it,
        then attach the domain-name from DHCP response.
        �.zFQDN requestedzObtained the following FQDN: %szNCould not determine domain name for FQDN. Fall back to hostname as an FQDN: %s)	rF�get_hostname�hostnamerVrWrgr�DataSourceHostname�
is_default)r�fqdn�
resolve_ip�
metadata_onlyrkrdrQs      �rrjz!DataSourceCloudStack.get_hostname�s�����7�'��j�-�H���C�x�0�0�0��I�I�&�'��-�-�/�J��"�+�+�,�A�j�\�:���	�	�;�T�B��1�1�$��8K�8K�L�L��I�I�7��
�
�rc���|j�}|jdkrytj|jd�g}tj�}tj||j|jtj��\}}|r!tjd|�t|�Stjd|ttj�|z
��t|�S)NrFzlatest/meta-data/instance-id)�urls�max_waitr"�	status_cbzUsing metadata source: '%s'z>Giving up on waiting for the metadata from %s after %s seconds)�get_url_params�max_wait_secondsr$�combine_url�metadata_address�time�	monotonic�wait_for_url�timeout_secondsrV�warningrW�critical�int�bool)r�
url_paramsrr�
start_timer,�	_responses      r�wait_for_metadata_servicez.DataSourceCloudStack.wait_for_metadata_service�s����(�(�*�
��&�&�!�+��
����%�%�'E�
�
��
�^�^�%�
��+�+���0�0��.�.��k�k�	
���Y���I�I�3�S�9��C�y��
�L�L�$���D�N�N�$�z�1�2�	
��C�y�rc��|jSr)rL�rs r�get_config_objz#DataSourceCloudStack.get_config_obj�s���x�x�r�returnc��t�S)z#Check if running on this datasource)�is_platform_viabler>rr�	ds_detectzDataSourceCloudStack.ds_detect�s
��"�#�#rc�|�i}tj||jdz��r5|d|_|d|_t
j
d|j�y|jrAtj�}t
j
d|�t|j|�}ntj�}	|5t|j�}t|t�r|j!d�n||_|j"st%d	��d
|j"�d�|_|j)�s
	ddd�y|j+�cddd�S#1swYyxYw#t,$rt
j/d�Yyt0$r)}t
j/d
t3|��Yd}~yd}~wwxYw)N�/)�basez	user-dataz	meta-dataz%Using seeded cloudstack data from: %sTzAttempting DHCP on: %s�dhcp-server-identifierzNo virtual router found!rFz#Unable to obtain a DHCP lease on %sz$Failed fetching metadata service: %s)r
�read_optional_seedrJ�userdata_raw�metadatarVrW�perform_dhcp_setupr	�find_fallback_nicrrO�nullcontext�get_vr_address�
isinstance�dictr`rMr'rxr��_crawl_metadatarr}�	Exception�str)r�seed_ret�primary_nic�network_contextrM�es      r�	_get_datazDataSourceCloudStack._get_data�su�����"�"�8�4�=�=�3�3F�H� (�� 5�D��$�[�1�D�M��I�I�=�t�}�}�M���"�"��/�/�1�K��I�I�.��<�0����k�J�O�"�.�.�0�O�	� �
.�(����5��"�'�4�0��K�K� 8�9� ���
�|�|�&�'A�B�B�*1�$�,�,��q�(A��%��5�5�7� �
.�
.��+�+�-�
.�
.�
.�� �	��K�K�=�{�K���	��K�K�>��A��G���	�sI�>E)�A;E�;E)�E�	E)�E&�"E)�&E)�)F;�
F;�F6�6F;zCrawling metadatar/r0c��tj|j|j�|_tj
|j|j�|_t|j�}	|j�}|r
d|ddid�|_
y#t$r(tjtd|j�YywxYw)NT�expireF)�
ssh_pwauthr7�chpasswdz/Failed to fetch password from virtual router %s)r�get_instance_userdatarKrxr��get_instance_metadatar�rrMr8rLr�r
�logexcrV)r�password_client�set_passwords   rr�z$DataSourceCloudStack._crawl_metadata�s����5�5��L�L�$�/�/�
����1�1��L�L�$�/�/�
��
�9����F��	�*�7�7�9�L��"&� ,� �%�!�������	��K�K��A����
��	�s�5B�.C�Cc� �|jdS)Nzinstance-id�r�r�s r�get_instance_idz$DataSourceCloudStack.get_instance_ids���}�}�]�+�+rc� �|jdS)Nzavailability-zoner�r�s r�availability_zonez&DataSourceCloudStack.availability_zones���}�}�0�1�1r)FFF)r9r:r;r��dsname�url_max_wait�url_timeoutrrgrjr�r��staticmethodr�r�r�r
r=r�r��propertyr��
__classcell__)rQs@rr@r@Hs������
�F��L��K��)�Z���	�8�>��$�t�$��$�"�H�[���*�X�>��?��8,��2��2rr@c��eZdZdZdZy)�DataSourceCloudStackLocalauRun in init-local using a dhcp discovery prior to metadata crawl.

    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.
    TN)r9r:r;r<r�r>rrr�r�s����rr�c�z�	tdd�}|dddS#t$rtjd�YywxYw)Nzdata-server�Pr�zDNS Entry data-server not found)rrrVrW)�addrinfos r�get_data_serverr�sI��!��}�b�1��
��{�1�~�a� � ��	���	�	�3�4���s��:�:c
��tjd�j�}|D]W}|jd�}|ddk(s�t	tdt
|dd���}tjd|�|cSy)	Nz/proc/net/route�	��00000000z<L��z"Found default route, gateway is %s)	r
�load_text_file�
splitlines�splitrrrrVrW)�lines�line�items�gws    r�get_default_gatewayr�'sz����� 1�2�=�=�?�E�����
�
�4� ����8�z�!��4��c�%��(�B�&7�8�9�B��I�I�:�B�?��I�
�rc���t�}|rtjd|�|Stjd�}|rtjd|�|Sttj�5tj�j|d�}|r!tjd|�|cddd�S	ddd�tt�5|jj|j�}|r6tjd||jj�|cddd�S	ddd�tjd�t�S#1swY��xYw#1swY�4xYw)Nz4Found metadata server '%s' via data-server DNS entry�SERVER_ADDRESSz-Found SERVER_ADDRESS '%s' via networkd_leasesr�z&Found SERVER_ADDRESS '%s' via dhclientz1Found SERVER_ADDRESS '%s' via ephemeral %s lease z$No DHCP found, using default gateway)r�rVrWrrXrrYrZr[rar\r^r_r]r�)rO�latest_addressrfs   rr�r�4sS��%�&�N���	�	�B��	
����9�9�:J�K�N���	�	�;�^�	
���

�$�6�6�	7�"��)�)�+�E�E��,�
����I�I�>��O�!�
"�"��	"�
�#�	$�
 ��)�)�:�:��%�%�
����I�I�C���"�"�.�.�
�
 �
 �
 ��	
 ��I�I�4�5�� � �-"�"��
 �
 �s�->E�
AE�E�E(r�c��tjd�}|stjd�y|j	t
�S)Nzsystem-product-namez-system-product-name not available in dmi dataF)r�
read_dmi_datarVrW�
startswith�CLOUD_STACK_DMI_NAME)�product_names rr�r�fs8���$�$�%:�;�L���	�	�A�B���"�"�#7�8�8rc�6�tj|t�Sr)r�list_from_depends�datasources)�dependss r�get_datasource_listr�vs���$�$�W�k�:�:r),�loggingrGry�
contextlibr�socketrrr�structr�	cloudinitrr	r
rrr$r
�
cloudinit.netr�cloudinit.net.dhcpr�cloudinit.net.ephemeralr�cloudinit.sources.helpersr�	getLoggerr9rVr�r�
DataSourcer@r�r�r�r�r�r��DEP_FILESYSTEM�DEP_NETWORKr�r�r>rr�<module>r�s����	���3�3��4�4�)���/�6�)��g����!��#��"�"�JE2�7�-�-�E2�P	� 4�	�!�
�/!�d9�D�9���!7�!7� 9�:��G�2�2�G�4G�4G�H�I���;r

Youez - 2016 - github.com/yon3zu
LinuXploit