+
    i@                        a  R t0 t R t^ RIt^ RIHtHt ^ RIHt ^ RIH	t	 ^ RI
Ht ^ RIHt ]P                  ! ]4      tRRR	R
R.R]RR./t] ^ k R R lt ! R R]4      t ! R R4      tRR ltR# )zDRed Hat Subscription: Register Red Hat Enterprise Linux based systemN)subputil)Cloud)Config)
MetaSchema)PER_INSTANCEidcc_rh_subscriptiondistrosfedorarhel	frequencyactivate_by_schema_keysrh_subscriptionc          
      L    V ^8  d   QhR\         R\        R\        R\        RR/# )   namecfgcloudargsreturnN)strr   r   list)formats   "E/usr/lib/python3/dist-packages/cloudinit/config/cc_rh_subscription.py__annotate__r      s/     71 71 716 71% 71t 71 71    c                    \        V4      pVP                  4       '       g   \        P                  R V 4       R# VP	                  4       '       Eg    VP                  4       w  rVVRJd   \        V4      hVP                  4       pV'       g   \        R4      hVP                  '       dF   VP                  e8   VP                  4       '       g   \        R4      h\        P                  R4       MHVP                  '       d7   VP                  4       '       g   \        R4      h\        P                  R4       VP                  eu   \        VP                  \        4      '       g   Rp\        V4      hVP                  VP                  4      p	V	'       g%   \        R	P!                  VP                  4      4      hVP#                  4       p	V	'       g   \        R
4      hVP$                  '       d!   VP'                  4        VP)                  4        \        P+                  R4       R# \        P+                  R4       R#   \         d?   p
\        P-                  \/        T
4      4       \        P-                  R4        Rp
?
R# Rp
?
ii ; i)z%s: module not configured.NTz-Registration failed or did not run completelyzSetting of service_level failedz(Completed auto_attach with service levelzSetting auto_attach failedzCompleted auto_attachz"Pools must in the format of a listzUnable to attach pools {0}zUnable to add or remove reposz-rh_subscription plugin completed successfullyz4rh_subscription plugin did not complete successfullyzSystem 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
isinstancer   addPoolr   update_reposrelease_version_set_release_version_delete_packagemanager_cacheinfowarningr   )r   r   r   r   smverify
verify_msgcont	pool_failreturn_states   &&&&       r   handler:      s   	S	!B		.5.	P!#!2FT!'
33??$D'C  ~~~"//"=,,..+,MNNIIHI**,,+,HIIII56xx#!"((D11 DI+I66 jj2"+4;;BHHE  //+K'(GHH!!!'')//1HHDE
 	/0	 ! 	PKKAKKNOO	PsI   :H< H< *#H< 2H< H< A=H< ;H< H< .5H< <J3J  Jc                       ] tR t^TtRtR# )r$    N)__name__
__module____qualname____firstlineno____static_attributes__r<   r   r   r$   r$   T   s    r   r$   c                   n   a  ] tR t^Xt o R tR tR tR tR tR t	R t
R tR	 tR
 tR tR tR tRtV tR# )r   c                   VP                  R / 4      V n        V P                  P                  R4      V n        V P                  P                  R4      V n        V P                  P                  R4      V n        V P                  P                  R4      V n        V P                  P                  RV P                  P                  R4      4      V n        V P                  P                  RV P                  P                  R4      4      V n        V P                  P                  R	V P                  P                  R
4      4      V n        V P                  P                  RV P                  P                  R4      4      V n	        V P                  P                  RV P                  P                  R4      4      V n
        V P                  P                  RV P                  P                  R4      4      V n        V P                  P                  RV P                  P                  R4      4      V n        V P                  P                  RV P                  P                  R4      4      V n        R# )r   orgusernamepasswordr.   rhsm_baseurlzrhsm-baseurlserver_hostnamezserver-hostnameadd_poolzadd-poolactivation_keyzactivation-keyr&   zauto-attachenable_repozenable-repodisable_repozdisable-reposervice_levelzservice-levelN)getrhel_cfgrD   useridrF   r.   rG   rH   r*   rJ   r&   rK   rL   r'   )selfr   s   &&r   __init__SubscriptionManager.__init__Z   s    126==$$U+mm''
3))*5#}}001BC !MM--DMM--n=
  $}}00t}}001BC 
 ]]&&))*5

 #mm//dmm//0@A
  ==,,4==,,];
  ==,,4==,,];
 !MM--DMM--n=
 !MM--T]]..?
r   c                p   V P                   eS   \        P                  ! V P                   4      '       g-   \        P                  ! V P                   4      '       g   RpRV3# V P                  eH   V P                   '       d0   \        P                  ! \        V P                   4      4      '       d   RpRV3# R# )zY
Checks that the keys in the rh_subscription dict from the user-data
are what we expect.
z8The 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)r&   r   is_trueis_falser'   r   )rQ   not_boolno_autos   &  r   r#    SubscriptionManager._verify_keys   s     (LL))**dmmD<L<L.M.M K  (?")!!!t}}S9I9I5J'K'K$ 
 '>! r   c                \    R.p \        V4       R#   \        P                   d     R# i ; i)zO
Checks if the system is already registered and returns
True if so, else False
identityFT)_sub_man_clir   ProcessExecutionError)rQ   cmds   & r   r"   !SubscriptionManager.is_registered   s7    
 l	  )) 		s    ++c                   V P                   e   V P                  e   RRP                  V P                   4      RP                  V P                  4      .pV P                  e+   VP	                  RP                  V P                  4      4       V P
                  e+   VP	                  RP                  V P
                  4      4        \        VRR7      ^ ,          pEMV P                  e   V P                  e   RRP                  V P                  4      RP                  V P                  4      .pV P                  e+   VP	                  RP                  V P                  4      4       V P
                  e+   VP	                  RP                  V P
                  4      4        \        VRR7      ^ ,          pM,\        P                  R4       \        P                  R4       R# VP                  R4      ^,          P!                  4       p\        P#                  RV4       R#   \        P                   d=   pTP                  R	8X  d!   \        P                  R
TP                  4        Rp?R# Rp?ii ; i  \        P                   d=   pTP                  R	8X  d!   \        P                  R
TP                  4        Rp?R# Rp?ii ; i)zv
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_val zRegistration 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 passwordzID: z"Registered successfully with ID %s)rJ   rD   r   rG   appendrH   r\   r   r]   stdoutr    r2   stderrrP   rF   splitrstripr!   )rQ   r^   
return_outr9   reg_ids   &    r   r%    SubscriptionManager.rhn_register   s/    +$((2F %,,T-@-@A""488,C   ,

?11$2C2CDE##/

,33D4H4HIJ)#TB1E
 kk%DMM,E  ''4 ''6C   ,

?11$2C2CDE##/

,33D4H4HIJ)#TB1E
 KKJ KKK !!&)!,335		6?S -- 88r>KK @!((K2 -- 88r>KK @!((Ks0   H I2 I/31I**I/2K1J>>Kc                6   R RRP                  V P                  4      .p \        V4      ^ ,          pTP                  R4       F!  pTR8w  g   K  \        P                  T4       K#  	  R#   \        P                   d   pTP
                  P                  4       R8w  dB   TP
                  P                  R4       F!  pTR8w  g   K  \        P                  T4       K#  	  M.\        P                  RTP                  P                  4       4        Rp?R# Rp?ii ; i)	attach--autoz--servicelevel={0}rc   
z)Setting the service level failed with: %sNFT)r   r'   r\   r   r]   re   rh   rg   r    r2   rf   stripr!   rQ   r^   ri   r9   lines   &    r   r(   &SubscriptionManager._set_service_level   s     ''(9(9:
	%c*1-J $$T*Drz		$ +  )) 
	xx B&HHNN40DrzD) 1 ?HHNN$ 
	s   A* *D?ADADDc                   R R.p \        V4      ^ ,          pTP                  R4       F!  pTR8w  g   K  \        P                  T4       K#  	  R#   \        P                   d"   p\        P	                  RT4        Rp?R# Rp?ii ; i)rm   rn   zauto_attach failed with: %sNFro   rc   T)r\   r   r]   r    r2   rg   r!   rq   s   &    r   r)   $SubscriptionManager._set_auto_attach  sx    "	%c*1-J $$T*Drz		$ +  )) 	KK5q9	s   A B%BBc                    . p. p. ROp\        V4      ^ ,          pVP                  4       P                  R4      p. ROp\        V4      ^ ,          pVP                  4       P                  R4      pW3# )zP
Gets the list pools for the active subscription and returns them
in list form.
ro   )r   z--available--pool-only)r   z
--consumedrw   )r\   rh   rg   )rQ   	availableconsumedr^   resultss   &    r   	_getPoolsSubscriptionManager._getPools  sq    
 	 5s#A&^^%,,T2	 4s#A&NN$++D1""r   c                   RR.p\        V4      ^ ,          p. pVP                  R4       FA  pRV9   g   K  VP                  VP                  R4      ^,          P                  4       4       KC  	  RR.p\        V4      ^ ,          p. pVP                  R4       FA  pRV9   g   K  VP                  VP                  R4      ^,          P                  4       4       KC  	  W53# )zT
Obtains the current list of active yum repositories and returns
them in list form.
reposz--list-enabledro   zRepo ID::z--list-disabled)r\   rg   rd   rp   )rQ   r^   ri   active_reposrepoinactive_reposs   &     r   	_getReposSubscriptionManager._getRepos+  s     ()!#&q)
$$T*DT!##TZZ_Q%7$>$>$@A + )*!#&q)
$$T*DT!%%tzz#q'9&@&@&BC + ++r   c                H   V'       g   \         P                  R4       R# V P                  4       w  r#. pR.pV FG  pWc9  d)   Wb9   d#   VP                  RP	                  V4      4       K1  \         P                  RV4       KI  	  \        V4      ^ 8  dU   VP                  V4        \        V4       \         P                  RRP                  V4      P                  RR	4      4       R# R#   \        P                   d#   p\         P                  R
XT4        Rp?R# Rp?ii ; i)zT
Takes a list of subscription pools and "attaches" them to the
current subscription
zNo pools to attachTrm   z
--pool={0}zPool %s is not availablez/Attached the following pools to your system: %s, z--pool=rc   z"Unable to attach pool %s due to %sNF)r    r!   r{   rd   r   r2   lenextendr\   joinreplacer   r]   )rQ   r*   pool_availablepool_consumed	pool_listr^   poolr9   s   &&      r   r,   SubscriptionManager.addPoolA  s     II*+(,(8%	jD)0F  !4!4T!:;6=	 
 y>AJJy!	S!		EYYy)229bA   -- @$Js   &A C* *D!?DD!c                   V P                   pV P                  pVf   . pVf   . p\        V\        4      '       g   \        P                  R4       R# \        V\        4      '       g   \        P                  R4       R# V'       g    V'       g   \        P                  R4       R# V P                  4       w  r4. p. pV F<  pWt9   d#   VP                  RP                  V4      4       K+  VP                  V4       K>  	  . p. p	V F<  pWs9   d#   VP                  RP                  V4      4       K+  V	P                  V4       K>  	  \        V4      ^ 8  d>   V F7  p
W9   d   \        P                  RV
4       K!  \        P                  R	V
4       K9  	  \        V	4      ^ 8  d    V	 F  p
\        P                  R
V
4       K  	  R.p\        V4      ^ 8  d   VP                  V4       \        V4      ^ 8  d   VP                  V4        \        V4       \        T4      ^ 8  d6   \        P                  RRP                  T4      P!                  RR4      4       \        T4      ^ 8  d6   \        P                  RRP                  T4      P!                  RR4      4       R#   \        P                   d"   p\        P                  RT4        Rp?R# Rp?ii ; i)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}zRepo %s is already enabledz Repo %s does not appear to existz.Repo %s not disabled because it is not enabledr~   zUnable to alter repos due to %szEnabled the following repos: %sr   z	--enable=rc   z Disabled the following repos: %sz
--disable=)rK   rL   r+   r   r    r2   r!   r   rd   r   r   r   r\   r   r]   r   r   )rQ   ereposdreposr   r   enable_listenable_list_failrepoiddisable_listdisable_list_failfailr^   r9   s   &            r   r-    SubscriptionManager.update_reposa  sb    !!"">F>F&$''KK@A&$''KK@A II89'+~~'7$F'"">#8#8#@A ''/	  F%##O$:$:6$BC!((0	   1$('II:DAKK BDI )  !A%)		Dd *
 i|q JJ|${aJJ{#	
 {aII1;'00bA |q II2<(11,C  )) 	KK91=	s   J K2KKc                |    \        V P                  ;'       d    V P                  ;'       g    V P                  4      # )N)boolrP   rF   rJ   )rQ   s   &r   r   !SubscriptionManager.is_configured  s+    T[[22T]]JJt7J7JKKr   c                    RRV P                    2.p \        V4       R#   \        P                   d   p\	        RT 24      ThRp?ii ; i)zo
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.   r\   r   r]   r$   )rQ   r^   r9   s   &  r   r/   (SubscriptionManager._set_release_version  sY     F4#7#7"89:	)) 	#7u=	s     A	AA	c                    \         P                  R4        \        P                  ! R4       \        P                  ! R4       R#   \         d   p\        R4      ThRp?ii ; i)zS
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)r    r!   r   del_dir	Exceptionr$   )rQ   r9   s   & r   r0   0SubscriptionManager._delete_packagemanager_cache  sS    
 			67	LL)*LL)* 	#<	s   ,A A!AA!)rJ   r&   rL   rK   rD   rF   r*   r.   rO   rG   rH   r'   rP   N)r=   r>   r?   r@   rR   r#   r"   r%   r(   r)   r{   r   r,   r-   r   r/   r0   rA   __classdictcell__)__classdict__s   @r   r   r   X   sS     #
JBBH2
#(,,@RhL r   r   c                B    \         P                   ! R.V ,           VR7      # )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
zsubscription-manager)	logstring)r   )r^   rb   s   &&r   r\   r\     s     99,-3}MMr   c                @    V ^8  d   Qh/ ^ \         9   d
   \        ;R&   # )r   meta)__conditional_annotations__r   )r   s   "r   r   r      s     J J j  Kr   )F)r   __doc__logging	cloudinitr   r   cloudinit.cloudr   cloudinit.configr   cloudinit.config.schemar   cloudinit.settingsr   	getLoggerr=   r    r   r:   r   r$   r   r\   r   )r   s   @r   <module>r      s    K    ! # . +! 	
&! 12	 71t		 	z zzNr   