3 cjC @ s U d Z ddlZddlmZ ddlmZmZ ddlmZ ddl m Z ddlmZm Z ddlmZ ejeZd Zd dded ddgeedededgdgdZee eZ ee eeddddZG dd deZG dd dZdddZdS ) zDRed Hat Subscription: Register Red Hat Enterprise Linux based system N)dedent)subputil)Cloud)Config) MetaSchemaget_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)idnametitledescriptionZdistrosZ frequencyZexamplesZactivate_by_schema_keys)r cfgcloudargsreturnc C sj t |td}|j s$tjd| d S |j s\y|j \}}|dk rLt||j }|s`td|jr|j d k r|j stdq|jjd n$|jr|j stdn|jjd |j d k rt|j tsd }t||j|j } | std 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)SubscriptionManagerLOG is_configureddebug is_registered_verify_keysSubscriptionErrorrhn_registerauto_attachservicelevel_set_service_levelr _set_auto_attachpools isinstancelistaddPoolformatupdate_reposlog_successlog_warnstr)r r r r ZsmZverifyZ verify_msgZcontZ pool_failZreturn_state r* (/usr/lib/python3.6/cc_rh_subscription.pyhandleR 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 dZdd Zdd Zdd Zdd Zdd Z dd Z dd Zdd Zdd Z d!d" Zd#d$ Zd%d&