a '¡DgPã@sÚUdZddlZddlZddlmZmZddlmZddlm Z ddl m Z ddl m Z ddlmZd e gegd œZe ed <d Zd ZdZdZe e¡ZdZee eeddœdd„Zdd„Zdd„Zdd„Zdd„Zdd„Z dS)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_INSTANCEZ cc_reset_rmc)ÚidZdistrosZ frequencyZactivate_by_schema_keysÚmetaÚz/opt/rsct/install/binÚrmcctrlZrecfgctz/etc/ct_node_id)ÚnameÚcfgÚcloudÚargsÚreturnc CsŠ|jjdkrt d¡dStj t¡s4t d¡dStj  d¡}z*t |ƒt ƒW|rb|tjd<q†tjd=n|r||tjd<ntjd=0dS)NZnonez(Skipping creation of new ct_node_id nodez&module disabled, RSCT_PATH not presentÚPATH) Z datasourceZ platform_typeÚLOGÚdebugÚosÚpathÚisdirÚ RSCT_PATHÚenvironÚgetÚadd_pathÚ reset_rmc)r rrrÚ orig_path©rúA/usr/lib/python3.9/site-packages/cloudinit/config/cc_reset_rmc.pyÚhandle<s        ý r cCsLz$t tg¡d}t | ¡¡|WStjyFt td¡‚Yn0dS)Nrz*Failed to reconfigure the RSCT subsystems.)rÚRECFGCTrrÚstripZProcessExecutionErrorrÚlogexc)ÚoutrrrÚreconfigure_rsct_subsystemsQs r%cCsHzt t¡}| d¡d}|WStyBt tdt¡‚Yn0dS)NÚ rz#Failed to get node ID from file %s.)rZload_text_fileÚ NODE_ID_FILEÚsplitÚ Exceptionr#r)ÚfpZnode_idrrrÚ get_node_id^s  r+cCs(|r d|nd}t|tjd<tjdS)Nú:r r)rrr)rZsuffrrrrhsrcCs6zt tdg¡WSty0t td¡‚Yn0dS)Nz-zz!Failed to stop the RMC subsystem.)rÚRMCCTRLr)rr#rrrrrr qs   cCs\t d¡tƒ}t d|¡tƒtƒtƒ}t d|¡||krXd}t |¡t|ƒ‚dS)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.)rrr+r r%ÚerrorÚ RuntimeError)Znode_id_beforeZ node_id_afterÚmsgrrrr{s    r)!Ú__doc__ZloggingrZ cloudinitrrZcloudinit.cloudrZcloudinit.configrZcloudinit.config.schemarZcloudinit.distrosrZcloudinit.settingsrr Ú__annotations__rr-r!Z getLoggerÚ__name__rr'ÚstrÚlistr r%r+rr rrrrrÚs2     ü