403Webshell
Server IP : 198.38.94.13  /  Your IP : 216.73.217.33
Web Server : Apache
System : Linux d4744.dxb1.stableserver.net 5.14.0-611.49.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Apr 21 16:39:08 EDT 2026 x86_64
User : revivere ( 1140)
PHP Version : 8.2.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /opt/saltstack/salt/lib/python3.10/site-packages/salt/runners/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/saltstack/salt/lib/python3.10/site-packages/salt/runners/__pycache__/spacewalk.cpython-310.pyc
o

;j�&�@s�dZddlZddlZddlZe�e�ZiZdd�Z	ddd�Z
ddd	�Zd
d�Zdd
�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS)a?
Spacewalk Runner
================

.. versionadded:: 2016.3.0

Runner to interact with Spacewalk using Spacewalk API

:codeauthor: Nitin Madhok <nmadhok@g.clemson.edu>, Joachim Werner <joe@suse.com>, Benedikt Werner <1benediktwerner@gmail.com>
:maintainer: Benedikt Werner <1benediktwerner@gmail.com>

To use this runner, set up the Spacewalk URL, username and password in the
master configuration at ``/etc/salt/master`` or ``/etc/salt/master.d/spacewalk.conf``:

.. code-block:: yaml

    spacewalk:
      spacewalk01.domain.com:
        username: 'testuser'
        password: 'verybadpass'
      spacewalk02.domain.com:
        username: 'testuser'
        password: 'verybadpass'

.. note::

    Optionally, ``protocol`` can be specified if the spacewalk server is
    not using the defaults. Default is ``protocol: https``.

�NcCst�sdSdS)zz
    Check for spacewalk configuration in master config file
    or directory and load runner only if it is specified
    )Fz No spacewalk configuration foundT)�_get_spacewalk_configuration�rr�J/opt/saltstack/salt/lib/python3.10/site-packages/salt/runners/spacewalk.py�__virtual__)sr�c	
Cs�dtvrtdnd}|rrzB|��D];\}}|�dd�}|�dd�}|�dd�}|r+|s5t�d|�WdS|�d	|�d
�||d�}|rG||krL|WSqWntyg}z
t�d|�WYd}~dSd}~ww|rrt�d
|�dSdS)z[
    Return the configuration read from the master configuration
    file or directory
    Z	spacewalkN�username�password�protocol�httpszNUsername or Password has not been specified in the master configuration for %sFz://z/rpc/api)�api_urlrrzException encountered: %szGConfiguration for %s has not been specified in the master configuration)Z__opts__�items�get�log�error�	Exception)	Z
spacewalk_urlZspacewalk_configZspacewalk_serverZservice_configrrr	�ret�excrrrr3sB��
�����rcCs4i}tjj||dd�|d<|dj�||�|d<|S)zA
    Return the client object and session key for the client
    T)�verboseZuse_datetime�client�key)�xmlrpcrZServer�authZlogin)�url�userrr�sessionrrr�_get_client_and_key`srcCs|dj�|d�dS)z#
    Disconnect API connection
    rrN)rZlogout)rrrr�_disconnect_sessionksrcCst|tvrt|St|�}|std|�d���t|d|d|d�}t�t|�|d}|d}||ft|<||fS)z
    Get session and key
    zNo config for 'z' found on masterrrrrr)�	_sessionsrrr�atexit�registerr)�serverZconfigrrrrrr�_get_sessionrs�r!c
Os�d|vr	|d}n|}|�d|��}zt|�\}}Wn!ty;}zd�||�}	t�|	�||	iWYd}~Sd}~ww|�d�\}
}}|
sJ|diStt||
�|�}
z
|
|g|�R�}W||iStyy}zd|��}WYd}~||iSd}~ww)aD
    Call the Spacewalk xmlrpc api.

    CLI Example:

    .. code-block:: bash

        salt-run spacewalk.api spacewalk01.domain.com systemgroup.create MyGroup Description
        salt-run spacewalk.api spacewalk01.domain.com systemgroup.create arguments='["MyGroup", "Description"]'

    State Example:

    .. code-block:: yaml

        create_group:
          salt.runner:
            - name: spacewalk.api
            - server: spacewalk01.domain.com
            - command: systemgroup.create
            - arguments:
              - MyGroup
              - Description
    �	arguments� �=Exception raised when connecting to spacewalk server ({}): {}N�.z@Error: command must use the following format: 'namespace.method'zAPI call failed: )r!r�formatrr�
rpartition�getattr)r Zcommand�args�kwargsr"�callrrr�err_msg�	namespace�_�methodZendpoint�output�errr�api�s8
��
��	����r2c

Cs�zt|�\}}Wn!ty)}zd�||�}t�|�d|iWYd}~Sd}~ww|j�|�}g}|D]}	|	d|vrC|�|	d�q4|j�	|||�dkrR||iS|diS)z�
    Add server groups to a activation key

    CLI Example:

    .. code-block:: bash

        salt-run spacewalk.addGroupsToKey spacewalk01.domain.com 1-my-key '[group1, group2]'
    r$�ErrorN�name�id�z&Failed to add groups to activation key)
r!rr&rr�systemgroup�
listAllGroups�append�
activationkeyZaddServerGroups)
r Zactivation_key�groupsrrrr,Z
all_groupsZgroupIds�grouprrr�addGroupsToKey�s(��
��	�r=c

C�zt|�\}}Wn!ty)}zd�||�}t�|�d|iWYd}~Sd}~ww|j�|�}g}g}|D]}|j�||d�dkrK|�|d�q6|�|d�q6d|i}	|r]||	d<|	S)z1
    Delete all server groups from Spacewalk
    r$r3Nr4r6�deleted�failed)	r!rr&rrr7r8�deleter9)
r rrrr,r;Zdeleted_groupsZ
failed_groupsr<rrrr�deleteAllGroups�s,��
��	rBc	
Cs�zt|�\}}Wn!ty)}zd�||�}t�|�d|iWYd}~Sd}~ww|j�|�}g}g}|D]}|�|d�|�|d�q6|j�||�dkrTd|iSddiS)	z�
    Delete all systems from Spacewalk

    CLI Example:

    .. code-block:: bash

        salt-run spacewalk.deleteAllSystems spacewalk01.domain.com
    r$r3Nr5r4r6r?zFailed to delete all systems)	r!rr&rr�systemZlistSystemsr9Z
deleteSystems)	r rrrr,ZsystemsZids�namesrCrrr�deleteAllSystemss(��
��	rEc

Cr>)z�
    Delete all activation keys from Spacewalk

    CLI Example:

    .. code-block:: bash

        salt-run spacewalk.deleteAllActivationKeys spacewalk01.domain.com
    r$r3Nrr6r?r@)	r!rr&rrr:ZlistActivationKeysrAr9)
r rrrr,Zactivation_keysZdeleted_keysZfailed_keysZaKeyrrrr�deleteAllActivationKeys(s,��
��	rFc	
Cs�zt|�\}}Wn!ty)}zd�||�}t�|�||iWYd}~Sd}~ww|j�||�}|rX|D] }|j�||d�}|dkrM|d|��iS|d|��iSdS|d|�d�iS)	z�
    Unregister specified server from Spacewalk

    CLI Example:

    .. code-block:: bash

        salt-run spacewalk.unregister my-test-vm spacewalk01.domain.com
    r$Nr5r6zSuccessfully unregistered from zFailed to unregister from z+System does not exist in spacewalk server (�))r!rr&rrrCZgetIdZdeleteSystem)	r4Z
server_urlrrrr,Zsystems_listrC�outrrr�
unregisterOs(��
��	�rI)r)r)�__doc__r�loggingZ
xmlrpc.clientr�	getLogger�__name__rrrrrrr!r2r=rBrErFrIrrrr�<module>s"



-8"!$'

Youez - 2016 - github.com/yon3zu
LinuXploit