HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/hadoop.cpython-310.pyc
o

�N�g�@s^dZddlZgd�Zdd�Zdd�Zdd	�Zdd
d�Zddd
�Zdd�Z	dd�Z
ddd�ZdS)zw
Support for hadoop

:maintainer: Yann Jouanin <yann.jouanin@intelunix.fr>
:maturity: new
:depends:
:platform: linux


�N)�version�namenode�dfsadmin�dfs�fscCs$tjj�d�stjj�d�rdSdS)z:
    Check if hadoop is present, then load the module
    �hadoop�hdfs)FzPThe hadoop execution module cannot be loaded: hadoop or hdfs binary not in path.)�salt�utils�path�which�r
r
�G/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/hadoop.py�__virtual__srcGsjd}tjj�d�rd}d}|r3|r3|tvr1|||d�|�d�}djdi|��}td|dd	�}|Sd
SdS)
aU
    Hadoop/hdfs command wrapper

    As Hadoop command has been deprecated this module will default
    to use hdfs command and fall back to hadoop if it is not found

    In order to prevent random execution the module name is checked

    Follows hadoop command template:
       hadoop module -command args
    E.g.: hadoop dfs -ls /
    rrN� )�tool�module�command�argsz!{tool} {module} -{command} {args}zcmd.runF)Zpython_shellzError: Unknown modulez%Error: Module and command not definedr
)r	r
rr�__authorized_modules__�join�formatZ__salt__)rrrr�outZmappings�cmdr
r
r�_hadoop_cmds 
��rcCsd}t|d���}|dS)zy
    Return version from hadoop version

    CLI Example:

    .. code-block:: bash

        salt '*' hadoop.version
    rT�)r�split)rrr
r
rrAs
rcGs|rtd|g|�R�SdS)zp
    Execute a command on DFS

    CLI Example:

    .. code-block:: bash

        salt '*' hadoop.dfs ls /
    rzError: command must be provided�r)rrr
r
rrPs
rcCs,|dur|dvrtdd|�S	dStdd�S)a+
    .. versionadded:: 2019.2.0

    Reports basic filesystem information and statistics. Optional flags may be used to filter the list of displayed DataNodes.

    arg
        [live] [dead] [decommissioning]

    CLI Example:

    .. code-block:: bash

        salt '*' hadoop.dfsadmin -report
    N)ZliveZdeadZdecommissioningr�reportzJError: the arg is wrong, it must be in ['live', 'dead', 'decommissioning']r)�argr
r
r�dfsadmin_report`s�
r cC� tdd|�}d}||vrdSdS)z�
    Check if a file or directory is present on the distributed FS.

    CLI Example:

    .. code-block:: bash

        salt '*' hadoop.dfs_present /some_random_file

    Returns True if the file is present
    r�stat�No such file or directoryFTr�rZ
cmd_return�matchr
r
r�dfs_present{�r&cCr!)z�
    Check if a file or directory is absent on the distributed FS.

    CLI Example:

    .. code-block:: bash

        salt '*' hadoop.dfs_absent /some_random_file

    Returns True if the file is absent
    rr"r#TFrr$r
r
r�
dfs_absent�r'r(cCsd}|rd}tddd|�S)zj
    Format a name node

    .. code-block:: bash

        salt '*' hadoop.namenode_format force=True
    �z-forcerrz-nonInteractiver)�forceZforce_paramr
r
r�namenode_format�sr+)N)�__doc__Zsalt.utils.pathr	rrrrrr r&r(r+r
r
r
r�<module>s
#