File manager - Edit - /opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/system.cpython-310.pyc
Back
o ;jM � @ s� d Z ddlZddlZddlZddlmZmZmZ ddlZ ddl Z ddlZ ddlm Z mZ ddlmZ e�e�ZdZdd� Zd d � Zdd� Zd d� Zd>dd�Zd>dd�Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� Z d>dd �Z!d>d!d"�Z"d>d#d$�Z# d?d%d&�Z$d>d'd(�Z%d>d)d*�Z&G d+d,� d,e�Z'd-d.� Z(d/d0� Z)d1d2� Z*d3d4� Z+d5d6� Z,d7d8� Z-d9Z.ed8�d:d;� �Z/ed8�d<d=� �Z0dS )@a� Support for reboot, shutdown, etc on POSIX-like systems. .. note:: If you have configured a wrapper such as ``molly-guard`` to intercept *interactive* shutdown commands, be aware that calling ``system.halt``, ``system.poweroff``, ``system.reboot``, and ``system.shutdown`` with ``salt-call`` will hang indefinitely while the wrapper script waits for user input. Calling them with ``salt`` will work as expected. � N)�datetime� timedelta�tzinfo)�CommandExecutionError�SaltInvocationError)�depends�systemc C s4 t jj�� rdS t jj�� rdS t jj�� rdS tS )zc Only supported on POSIX-like systems Windows, Solaris, and Mac have their own modules )Fz'This module is not available on Windows)Fz&This module is not available on Mac OS)Fz%This module is not available on SunOS)�salt�utils�platformZ is_windowsZ is_darwinZis_sunos�__virtualname__� r r �G/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/system.py�__virtual__ s r c C � dg} t d | dd�}|S )zi Halt a running system CLI Example: .. code-block:: bash salt '*' system.halt �halt�cmd.runF��python_shell��__salt__��cmd�retr r r r 0 � r c C s d| � g}t d |dd�}|S )z� Change the system runlevel on sysV compatible systems CLI Example: .. code-block:: bash salt '*' system.init 3 �initr Fr r )Zrunlevelr r r r r r ? s r c C r )zq Poweroff a running system CLI Example: .. code-block:: bash salt '*' system.poweroff �poweroffr Fr r r r r r r N r r c C s( dd| r| � ndg}t d |dd�}|S )z� Reboot the system at_time The wait time in minutes before the system will be rebooted. CLI Example: .. code-block:: bash salt '*' system.reboot �shutdownz-r�nowr Fr r )�at_timer r r r r �reboot] s r c C sV t jj�� st jj�� st jj�� rd}nd}d|| r| � ndg}td |dd�}|S )z� Shutdown a running system at_time The wait time in minutes before the system will be shutdown. CLI Example: .. code-block:: bash salt '*' system.shutdown 5 z-pz-hr r r Fr )r r r Z is_freebsdZ is_netbsdZ is_openbsdr )r �flagr r r r r r o s � � �r c C s� dg}| � � dur| | � � } | jtd�d�} |�d� dj| �� � }||g }td |dd �}|d dkr[dj| �� � }||g }td |dd �}|d dkr[d�|d �}t|��dS )z� set the system date/time using the date command Note using a strictly posix-compliant date binary we can only set the date up to the minute. �dateNr �r z-uz%{1:02}{2:02}{3:02}{4:02}{0:04}.{5:02}�cmd.run_allFr �retcodez {1:02}{2:02}{3:02}{4:02}{0:04}zdate failed: {}�stderrT)� utcoffset�replace�_FixedOffset�append�format� timetupler r ) Znew_dater Z non_posixZ non_posix_cmdZ ret_non_posix�posixZ posix_cmdZ ret_posix�msgr r r �_date_bin_set_datetime� s r/ c C s<