Ë
    x[hP  ã            
       óò   — U d Z ddlZddlZddlmZmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ ddlmZ d	egeg d
œZeed<   dZ dZdZdZ ej*                  e«      ZdZdede	dededdf
d„Zd„ Zd„ Zd„ Zd„ Zd„ Z y)a›  Reset RMC: Reset rsct node id

Reset RMC module is IBM PowerVM Hypervisor specific

Reliable Scalable Cluster Technology (RSCT) is a set of software components,
that  together provide a comprehensive clustering environment (RAS features)
for IBM PowerVM based virtual machines. RSCT includes the Resource monitoring
and control (RMC) subsystem. RMC is a generalized framework used for managing,
monitoring, and manipulating resources. RMC runs as a daemon process on
individual machines and needs creation of unique node id and restarts
during VM boot.
More details refer
https://www.ibm.com/support/knowledgecenter/en/SGVKBA_3.2/admin/bl503_ovrv.htm

This module handles
- creation of the unique RSCT node id to every instance/virtual machine
  and ensure once set, it isn't changed subsequently by cloud-init.
  In order to do so, it restarts RSCT service.

Prerequisite of using this module is to install RSCT packages.
é    N)ÚsubpÚutil)ÚCloud)ÚConfig)Ú
MetaSchema)ÚALL_DISTROS)ÚPER_INSTANCEÚcc_reset_rmc)ÚidÚdistrosÚ	frequencyÚactivate_by_schema_keysÚmetaÚ z/opt/rsct/install/binÚrmcctrlÚrecfgctz/etc/ct_node_idÚnameÚcfgÚcloudÚargsÚreturnc                 óä  — |j                   j                  dk(  rt        j                  d«       y t        j
                  j                  t        «      st        j                  d«       y t        j                  j                  d«      }	 t        |«       t        «        |r|t        j                  d<   y t        j                  d= y # |r|t        j                  d<   w t        j                  d= w xY w)NÚnonez(Skipping creation of new ct_node_id nodez&module disabled, RSCT_PATH not presentÚPATH)Ú
datasourceÚplatform_typeÚLOGÚdebugÚosÚpathÚisdirÚ	RSCT_PATHÚenvironÚgetÚadd_pathÚ	reset_rmc)r   r   r   r   Ú	orig_paths        ú?/usr/lib/python3/dist-packages/cloudinit/config/cc_reset_rmc.pyÚhandler)   <   s¨   € à×Ñ×%Ñ%¨Ò/Ü�	‰	Ð<Ô=Øä�7‰7�=‰=œÔ#Ü�	‰	Ð:Ô;Øä—
‘
—‘˜vÓ&€Ið#Ü�ÔÜŒáØ!*ŒB�J‰J�vÒä—
‘
˜6Ñ"øñ Ø!*ŒB�J‰J�vÒä—
‘
˜6Ñ"ús   Â	C Ã)C/c                  óì   — 	 t        j                   t        g«      d   } t        j                  | j	                  «       «       | S # t         j
                  $ r t        j                  t        d«       ‚ w xY w)Nr   z*Failed to reconfigure the RSCT subsystems.)r   ÚRECFGCTr   r   ÚstripÚProcessExecutionErrorr   Úlogexc)Úouts    r(   Úreconfigure_rsct_subsystemsr0   Q   sZ   € ðÜ�i‰iœ˜	Ó" 1Ñ%ˆÜ�	‰	�#—)‘)“+ÔØˆ
øÜ×%Ñ%ò Ü�‰”CÐEÔFØðús   ‚AA Á/A3c                  óÀ   — 	 t        j                  t        «      } | j                  d«      d   }|S # t        $ r# t        j
                  t        dt        z  «       ‚ w xY w)Nú
r   z#Failed to get node ID from file %s.)r   Úload_text_fileÚNODE_ID_FILEÚsplitÚ	Exceptionr.   r   )ÚfpÚnode_ids     r(   Úget_node_idr9   ^   sT   € ðÜ× Ñ ¤Ó.ˆØ—(‘(˜4“. Ñ#ˆØˆøÜò Ü�‰”CÐ>ÄÑMÔNØðús	   ‚.1 ±,Ac                 ón   — | rd| z   nd}t         |z   t        j                  d<   t        j                  d   S )Nú:r   r   )r"   r   r#   )r'   Úsuffs     r(   r%   r%   h   s3   € ñ (ˆ3�Š?¨R€DÜ" TÑ)„B‡J�JˆvÑÜ�:‰:�fÑÐó    c                  óŠ   — 	 t        j                   t        dg«      S # t        $ r t        j                  t
        d«       ‚ w xY w)Nz-zz!Failed to stop the RMC subsystem.)r   ÚRMCCTRLr6   r   r.   r   © r=   r(   r   r   q   s;   € ðÜ�y‰yœ' 4˜Ó)Ð)øÜò Ü�‰”CÐ<Ô=Øðús	   ‚ �%Ac                  ó$  — t         j                  d«       t        «       } t         j                  d| «       t        «        t	        «        t        «       }t         j                  d|«       || k(  r"d}t         j                  |«       t        |«      ‚y )NzAttempting to reset RMC.z"Node ID at beginning of module: %szNode ID at end of module: %sz"New node ID did not get generated.)r   r   r9   r   r0   ÚerrorÚRuntimeError)Únode_id_beforeÚnode_id_afterÚmsgs      r(   r&   r&   {   sr   € Ü‡I�IÐ(Ô)ä “]€NÜ‡I�IÐ2°NÔCô „IÜÔ!ä“M€MÜ‡I�IÐ,¨mÔ<ð ˜Ò&Ø2ˆÜ�	‰	�#ŒÜ˜3ÓÐð 'r=   )!Ú__doc__Úloggingr   Ú	cloudinitr   r   Úcloudinit.cloudr   Úcloudinit.configr   Úcloudinit.config.schemar   Úcloudinit.distrosr   Úcloudinit.settingsr	   r   Ú__annotations__r"   r?   r+   Ú	getLoggerÚ__name__r   r4   ÚstrÚlistr)   r0   r9   r%   r   r&   r@   r=   r(   ú<module>rT      s²   ðòó* Û 	ç  Ý !Ý #Ý .Ý )Ý +ð Øˆ}ØØ!ñ	€€jó ð €ð $€	Ø
€Ø
€à€g×Ñ˜Ó!€à €ð#�ð #˜6ð #¨%ð #°tð #Àó #ò*
òòòó r=   