
    x[hP              
           % S r SSKrSSKrSSKJrJr  SSKJr  SSKJ	r	  SSK
Jr  SSKJr  SSKJr  S	\/\/ S
.r\\S'   Sr SrSrSr\R*                  " \5      rSrS\S\	S\S\SS4
S jrS rS rS rS rS r g)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                    UR                   R                  S:X  a  [        R                  S5        g [        R
                  R                  [        5      (       d  [        R                  S5        g [        R                  R                  S5      n [        U5        [        5         U(       a  U[        R                  S'   g [        R                  S	 g ! U(       a  U[        R                  S'   f [        R                  S	 f = f)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    %%/		<=77==##		:;

v&I#!*BJJv

6" !*BJJv

6"s   C .C?c                       [         R                   " [        /5      S   n [        R                  U R	                  5       5        U $ ! [         R
                   a    [        R                  " [        S5        e f = f)Nr   z*Failed to reconfigure the RSCT subsystems.)r   RECFGCTr   r   stripProcessExecutionErrorr   logexc)outs    r(   reconfigure_rsct_subsystemsr0   Q   sZ    ii	"1%		#))+
%% CEFs   AA 1A6c                       [         R                  " [        5      n U R                  S5      S   nU$ ! [         a$    [         R
                  " [        S[        -  5        e f = f)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	   /2 .A c                 x    U (       a  SU -   OSn[         U-   [        R                  S'   [        R                  S   $ )N:r   r   )r"   r   r#   )r'   suffs     r(   r%   r%   h   s3     (3?RD"T)BJJv::f    c                       [         R                   " [        S/5      $ ! [         a    [        R                  " [
        S5        e f = f)Nz-zz!Failed to stop the RMC subsystem.)r   RMCCTRLr6   r   r.   r    r=   r(   r   r   q   s;    yy'4)) C<=s	    'Ac                  $   [         R                  S5        [        5       n [         R                  SU 5        [        5         [	        5         [        5       n[         R                  SU5        X:X  a"  Sn[         R                  U5        [        U5      eg )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&   {   sp    II() ]NII2NC I!MMII,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   $	

! # #6 #% #t # #*
 r=   