File: //usr/lib/python3.6/site-packages/cloudinit/config/__pycache__/cc_rh_subscription.cpython-36.pyc
3
�xh�C �
@ s� U d Z ddlZddlmZ ddlmZmZ ddlmZ ddl m
Z
ddlmZm
Z
ddlmZ eje�Zd Zd
dded
ddgeed�ed�ed�gdgd�Zee
e�Z ee
eedd�dd�ZG dd� de�ZG dd� d�Zddd�ZdS ) zDRed Hat Subscription: Register Red Hat Enterprise Linux based system� N)�dedent)�subp�util)�Cloud)�Config)�
MetaSchema�get_meta_doc)�PER_INSTANCEa[ Register a Red Hat system either by username and password *or* activation and
org. Following a successful registration, you can:
- auto-attach subscriptions
- set the service level
- add subscriptions based on pool id
- enable/disable yum repositories based on repo id
- alter the rhsm_baseurl and server-hostname in ``/etc/rhsm/rhs.conf``.
Zcc_rh_subscriptionzRed Hat Subscriptionz.Register Red Hat Enterprise Linux based systemZfedoraZrhelZ openeulerz� rh_subscription:
username: joe@foo.bar
## Quote your password if it has symbols to be safe
password: '1234abcd'
zk rh_subscription:
activation-key: foobar
org: "ABC"
a� rh_subscription:
activation-key: foobar
org: "ABC"
auto-attach: true
service-level: self-support
add-pool:
- 1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a1a
- 2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b2b
enable-repo:
- repo-id-to-enable
- other-repo-id-to-enable
disable-repo:
- repo-id-to-disable
- other-repo-id-to-disable
# Alter the baseurl in /etc/rhsm/rhsm.conf
rhsm-baseurl: http://url
# Alter the server hostname in /etc/rhsm/rhsm.conf
server-hostname: foo.bar.com
�rh_subscription)�id�name�title�descriptionZdistrosZ frequencyZexamplesZactivate_by_schema_keys)r �cfg�cloud�args�returnc C sj t |td�}|j� s$tjd| � d S |j� �s\y�|j� \}}|dk rLt|��|j� }|s`td��|jr�|j d k r�|j
� s�td��q�|jjd� n$|jr�|j� s�td��n|jjd� |j
d k � r�t|j
t�s�d }t|��|j|j
�} | � s�td
j|j
���|j� } | �std��|jd� W n< tk
�rX }
z|jt|
�� |jd
� W Y d d }
~
X nX n
|jd� d S )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)r r r r ZsmZverifyZ
verify_msgZcontZ pool_failZreturn_stat�e� r* �(/usr/lib/python3.6/cc_rh_subscription.py�handleR sJ
r, c @ s e Zd ZdS )r N)�__name__�
__module__�__qualname__r* r* r* r+ r � s r c @ s� e Zd Zddddddddd d
dgZd'd
d�Zdd� Zdd� Zdd� Zdd� Zdd� Z dd� Z
dd� Zdd� Zdd � Z
d!d"� Zd#d$� Zd%d&� ZdS )(r �orgzactivation-key�username�passwordzdisable-repozenable-repozadd-poolzrhsm-baseurlzserver-hostnamezauto-attachz
service-levelNc C s� |d krt }|| _|| _| jjdi �| _| jjd�| _| jjd�| _| jjd�| _| jjd�| _| jjd�| _ | jjd�| _
| jjd�| _| jjd �| _| jjd
�| _
| jjd�| _| jjd�| _d S )
Nr
zrhsm-baseurlzserver-hostnamezadd-poolzactivation-keyr0 r1 r2 zauto-attachzenable-repozdisable-repoz
service-level)r r r �get�rhel_cfg�rhsm_baseurl�server_hostnamer �activation_keyr0 �useridr2 r �enable_repo�disable_repor )�selfr r r* r* r+ �__init__� s zSubscriptionManager.__init__c C s | j j|� dS )z>Simple wrapper for logging info messages. Useful for unittestsN)r �info)r; �msgr* r* r+ r&