관리-도구
편집 파일: linux.cpython-39.pyc
a �)g� � @ s d dl mZmZmZ eZd dlZd dlZd dlZd dl Z d dl Z d dlZd dlZd dl Z d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d dlmZ d d lmZmZ d d lmZmZm Z d dl!m"Z" d dl#m$Z$ d d� Z%G dd� de�Z&G dd� de�Z'dS )� )�absolute_import�division�print_functionN)� cpu_count)� ThreadPool)�to_text)�get_best_parsable_locale)�get_bin_path)�bytes_to_human)�Hardware�HardwareCollector)�get_file_content�get_file_lines�get_mount_size)� iteritems)�timeoutc C sV zt �d�}W n ty" Y d S 0 |D ](}t j�d| �}|d| kr(| S q(d S )N�/dev/disk/by-uuidz/dev/disk/by-uuid/z/dev/)�os�listdir�OSError�path�realpath)�partname�uuids�uuid�dev� r �M/usr/lib/python3.9/site-packages/ansible/module_utils/facts/hardware/linux.py�get_partition_uuid+ s r c @ s e Zd ZdZdZed�Ze�d�Ze � d�Ze � d�Ze � d�Z d7d d �Zdd� Zd8d d�Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Zedd� �Zdd � Zd!d"� Zd#d$� Zd%d&� Zd'd(� Zd)d*� Zd+d,� Z d-d.� Z!d/d0� Z"d1d2� Z#d3d4� Z$d5d6� Z%dS )9� LinuxHardwarea" Linux-specific subclass of Hardware. Defines memory and CPU facts: - memfree_mb - memtotal_mb - swapfree_mb - swaptotal_mb - processor (a list) - processor_cores - processor_count In addition, it also defines number of DMI facts and device facts. �Linux)ZMemTotalZ SwapTotalZMemFreeZSwapFree)ZBuffersZCachedZ SwapCachedz.*\]z .*bind.*"z \\[0-9]{3}Nc C s� i }t | j�}|||d�| j_| j|d�}| �� }| �� }| �� }| �� }| �� } i } z| � � } W n t jy� | j�d� Y n0 |� |� |� |� |� |� |� |� |� |� |� | � |� | � |S )N)�LANG�LC_ALL� LC_NUMERIC)�collected_factsz,No mount facts were gathered due to timeout.)r �moduleZrun_command_environ_update� get_cpu_facts�get_memory_facts� get_dmi_facts�get_device_facts�get_uptime_facts� get_lvm_facts�get_mount_factsr �TimeoutError�warn�update)�selfr$ Zhardware_facts�locale� cpu_facts�memory_facts� dmi_facts�device_facts�uptime_facts� lvm_factsZmount_factsr r r �populateW s, zLinuxHardware.populatec C s� i }t �dt j�s|S i }td�D ]�}|�dd�}|d }|| jv rr|d �� �d�d }t|�d |d|�� <