Current Dir: /snap/core22/2955/usr/lib/python3/dist-packages/cloudinit/config/__pycache__/

[FILE] cc_ansible.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_apk_configure.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_apt_configure.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_apt_pipelining.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_bootcmd.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_byobu.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ca_certs.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_chef.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_disable_ec2_metadata.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_disk_setup.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_fan.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_final_message.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_growpart.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_grub_dpkg.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_install_hotplug.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_keyboard.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_keys_to_console.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_landscape.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_locale.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_lxd.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_mcollective.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_mounts.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ntp.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_package_update_upgrade_install.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_phone_home.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_power_state_change.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_puppet.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_raspberry_pi.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_reset_rmc.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_resizefs.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_resolv_conf.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_rh_subscription.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_rsyslog.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_runcmd.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_salt_minion.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_scripts_per_boot.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_scripts_per_instance.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_scripts_per_once.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_scripts_user.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_scripts_vendor.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_seed_random.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_set_hostname.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_set_passwords.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_snap.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_spacewalk.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ssh.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ssh_authkey_fingerprints.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ssh_import_id.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_timezone.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ubuntu_autoinstall.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ubuntu_drivers.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_ubuntu_pro.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_update_etc_hosts.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_update_hostname.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_users_groups.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_wireguard.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_write_files.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_write_files_deferred.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_yum_add_repo.cpython-310.pyc [ edit | delete | rename ]
[FILE] cc_zypper_add_repo.cpython-310.pyc [ edit | delete | rename ]
[FILE] modules.cpython-310.pyc [ edit | delete | rename ]
[FILE] schema.cpython-310.pyc [ edit | delete | rename ]
[FILE] __init__.cpython-310.pyc [ edit | delete | rename ]

Viewing: /snap/core22/2955/usr/lib/python3/dist-packages/cloudinit/config/__pycache__/cc_rh_subscription.cpython-310.pyc

o

��i�@�
@s�UdZddlZddlmZmZddlmZddlmZddl	m
Z
ddlmZe�
e�Zdd	d
gedgd�Ze
ed
<dededededdf
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�rh_subscription)�id�distros�	frequency�activate_by_schema_keys�meta�name�cfg�cloud�args�returnc
Csnt|�}|��st�d|�dS|��s�z||��\}}|dur#t|��|��}|s-td��|jrC|j	durC|�
�s=td��t�d�n|jrS|��sNtd��t�d�|jdurtt
|jt�sdd}t|��|�|j�}	|	sttd	�|j���|��}	|	s~td
��|jr�|��|��t�d�WdSty�}
zt�t|
��t�d�WYd}
~
dSd}
~
wwt�d
�dS)Nz%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�
is_configured�LOG�debug�
is_registered�_verify_keys�SubscriptionError�rhn_register�auto_attach�servicelevel�_set_service_level�_set_auto_attach�pools�
isinstance�list�addPool�format�update_repos�release_version�_set_release_version�_delete_packagemanager_cache�info�warning�str)rrrr�sm�verify�
verify_msg�cont�	pool_fail�return_stat�e�r5�E/usr/lib/python3/dist-packages/cloudinit/config/cc_rh_subscription.py�handlesX�	


���r7c@seZdZdS)rN)�__name__�
__module__�__qualname__r5r5r5r6rTsrc@steZdZdd�Zdd�Zdd�Zdd�Zd	d
�Zdd�Zd
d�Z	dd�Z
dd�Zdd�Zdd�Z
dd�Zdd�ZdS)rcCs
|�di�|_|j�d�|_|j�d�|_|j�d�|_|j�d�|_|j�d|j�d��|_|j�d|j�d	��|_|j�d
|j�d��|_|j�d|j�d
��|_	|j�d|j�d��|_
|j�d|j�d��|_|j�d|j�d��|_|j�d|j�d��|_
dS)Nr�org�username�passwordr(�rhsm_baseurlzrhsm-baseurl�server_hostnamezserver-hostname�add_poolzadd-pool�activation_keyzactivation-keyrzauto-attach�enable_repozenable-repo�disable_repozdisable-repo�
service_levelz
service-level)�get�rhel_cfgr;�useridr=r(r>r?r"rArrBrCr)�selfrr5r5r6�__init__Zs:�������
�zSubscriptionManager.__init__cCs^|jdurt�|j�st�|j�sd}d|fS|jdur-|jr't�t|j��r-d}d|fSdS)zq
        Checks that the keys in the rh_subscription dict from the user-data
        are what we expect.
        Nz8The key auto_attach must be a boolean value (True/False)FzqThe service_level key must be used in conjunction with the auto_attach key.  Please re-run with auto_attach: True)TN)rr�is_true�is_falserr-)rH�not_bool�no_autor5r5r6rs"

�
��
���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)rH�cmdr5r5r6r�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
krRt
�d|j�WYd}~dSd}~ww|j
dur�|jdur�dd
�|j
�d�|j�g}|jdur�|�d�|j��|jdur�|�d�|j��z
t|dd�d	}Wn,tjy�}z|j	d
kr�t
�d|j�WYd}~dSd}~wwt
�d�t
�d�dS|�d�d��}t
�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: %sFz--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)rAr;r&r>�appendr?rOrrP�stdoutrr,�stderrrGr=�split�rstripr)rHrQ�
return_outr4�reg_idr5r5r6r�sX

�
	

��

�
	

����z SubscriptionManager.rhn_registerc
Cs�ddd�|j�g}zt|�d}Wn7tjyH}z*|j��dkr4|j�d�D]}|dkr2t�	|�q'n	t�	d|j
���WYd}~dSd}~ww|�d�D]}|dkrYt�|�qNd	S)
N�attach�--autoz--servicelevel={0}rrT�
z)Setting the service level failed with: %sFT)
r&rrOrrPrWrZrYrr,rX�stripr�rHrQr[r4�liner5r5r6r �s2
�
�����
�z&SubscriptionManager._set_service_levelc
Cstddg}zt|�d}Wntjy&}z
t�d|�WYd}~dSd}~ww|�d�D]}|dkr7t�|�q,dS)	Nr]r^rzauto_attach failed with: %sFr_rTT)rOrrPrr,rYrrar5r5r6r!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-onlyrr_)r$z
--consumedrc)rOrZrY)rH�	available�consumedrQ�resultsr5r5r6�	_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-enabledrr_zRepo ID:�:rUz--list-disabled)rOrYrVr`)rHrQr[�active_repos�repo�inactive_reposr5r5r6�	_getRepos+s��zSubscriptionManager._getReposc
Cs�|s	t�d�dS|��\}}g}dg}|D]}||vr)||vr)|�d�|��qt�d|�qt|�dkrk|�|�zt|�t�dd�	|��
d	d
��WdStjyj}zt�d||�WYd}~d
Sd}~wwdS)zl
        Takes a list of subscription pools and "attaches" them to the
        current subscription
        zNo pools to attachTr]z
--pool={0}zPool %s is not availablerz/Attached the following pools to your system: %s�, z--pool=rTz"Unable to attach pool %s due to %sNF)
rrrgrVr&r,�len�extendrO�join�replacerrP)rHr"�pool_available�
pool_consumed�	pool_listrQ�poolr4r5r5r6r%As2

����zSubscriptionManager.addPoolc

Cs|j}|j}|durg}|durg}t|t�st�d�dSt|t�s*t�d�dS|s5|s5t�d�dS|��\}}g}g}|D]}||vrP|�d�	|��qA|�|�qAg}g}	|D]}||vrk|�d�	|��q\|	�|�q\t
|�dkr�|D]}
|
|vr�t�d	|
�qyt�d
|
�qyt
|	�dkr�|	D]}
t�d|
�q�dg}t
|�dkr�|�|�t
|�dkr�|�|�zt|�Wnt
jy�}z
t�d
|�WYd}~dSd}~wwt
|�dkr�t�dd�|��dd��t
|�dkr�t�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 %s does not appear to existz.Repo %s not disabled because it is not enabledrhzUnable to alter repos due to %szEnabled the following repos: %srnz	--enable=rTz Disabled the following repos: %sz
--disable=)rBrCr#r$rr,rrmrVr&rorprOrrPrqrr)
rH�erepos�dreposrjrl�enable_list�enable_list_fail�repoid�disable_list�disable_list_fail�failrQr4r5r5r6r'asz




�

����z SubscriptionManager.update_reposcCst|jr|jp	|j�S)N)�boolrGr=rA)rHr5r5r6r�sz!SubscriptionManager.is_configuredc
CsJdd|j��g}zt|�WdStjy$}ztd|���|�d}~ww)z�
        Execute "subscription-manager release --set=<release_version>"
        Raises Subscription error if the command fails
        �releasez--set=z%Unable to set release_version using: N)r(rOrrPr)rHrQr4r5r5r6r)�s����z(SubscriptionManager._set_release_versionc
CsHt�d�z
t�d�t�d�WdSty#}ztd�|�d}~ww)zk
        Delete the package manager cache.
        Raises Subscription error if the deletion fails
        z"Deleting the package manager cachez/var/cache/dnfz/var/cache/yumz*Unable to delete the package manager cacheN)rrr�del_dir�	Exceptionr)rHr4r5r5r6r*�s

����z0SubscriptionManager._delete_packagemanager_cacheN)r8r9r:rIrrrr r!rgrmr%r'rr)r*r5r5r5r6rXs%!D TrFcCstjdg||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)rQrSr5r5r6rO�srO)F)�__doc__�logging�	cloudinitrr�cloudinit.cloudr�cloudinit.configr�cloudinit.config.schemar�cloudinit.settingsr�	getLoggerr8rr�__annotations__r-r$r7r�rrrOr5r5r5r6�<module>s&
�:
Upload File: