Current File : //usr/lib/python3/dist-packages/cloudinit/config/__pycache__/cc_reset_rmc.cpython-312.pyc
�

ӇgP�
���UdZddlZddlZddlmZmZddlmZddlm	Z	ddl
mZddlm
Z
ddlmZd	e
gegd
�Zeed<dZd
ZdZdZej*e�ZdZdede	dededdf
d�Zd�Zd�Zd�Zd�Zd�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���|jjdk(rtjd�ytj
j
t�stjd�ytjjd�}	t|�t�|r|tjd<ytjd=y#|r|tjd<wtjd=wxYw)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)rrrr�	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���	tjtg�d}tj|j	��|S#tj
$rt
jtd��wxYw)Nrz*Failed to reconfigure the RSCT subsystems.)r�RECFGCTrr�strip�ProcessExecutionErrorr�logexc)�outs r(�reconfigure_rsct_subsystemsr0QsZ����i�i��	�"�1�%���	�	�#�)�)�+���
���%�%�����C�E�F�
��s�AA�/A3c��	tjt�}|jd�d}|S#t$r#tj
tdtz��wxYw)N�
rz#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�,Ac�n�|rd|znd}t|ztjd<tjdS)N�:rr)r"rr#)r'�suffs  r(r%r%hs3��(�3��?�R�D�"�T�)�B�J�J�v��
�:�:�f���c��	tjtdg�S#t$rtjt
d��wxYw)Nz-zz!Failed to stop the RMC subsystem.)r�RMCCTRLr6rr.r�r=r(rrqs;����y�y�'�4��)�)�������C�<�=�
��s	��%Ac�$�tjd�t�}tjd|�t�t	�t�}tjd|�||k(r"d}tj|�t
|��y)NzAttempting to reset RMC.z"Node ID at beginning of module: %szNode ID at end of module: %sz"New node ID did not get generated.)rrr9rr0�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�	cloudinitrr�cloudinit.cloudr�cloudinit.configr�cloudinit.config.schemar�cloudinit.distrosr�cloudinit.settingsr	r�__annotations__r"r?r+�	getLogger�__name__rr4�str�listr)r0r9r%rr&r@r=r(�<module>rTs����*�	� �!�#�.�)�+���}��!�	��j��
��
$�	�
��
���g����!�� ��#��#�6�#�%�#�t�#��#�*
���� r=