403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /lib/python3.11/site-packages/ansible/plugins/cliconf/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /lib/python3.11/site-packages/ansible/plugins/cliconf/__pycache__/__init__.cpython-311.pyc
�

���c$Y���ddlmZmZmZeZddlmZddlm	Z	ddl
mZddlm
Z
mZddlmZmZ	ddlmZdZn
#e$rd	ZYnwxYwd
�ZGd�de��Zd
S)�)�absolute_import�division�print_function)�abstractmethod��wraps)�
AnsiblePlugin)�AnsibleError�AnsibleConnectionFailure)�to_bytes�to_text)�	SCPClientTFc�<��t����fd���}|S)Nc����|j���}t|d�������d��std����|g|�Ri|��S)N�surrogate_or_strict��errors�#z'operation requires privilege escalation)�_connection�
get_promptr
�strip�endswithr
)�self�args�kwargs�prompt�funcs    ��E/usr/lib/python3.11/site-packages/ansible/plugins/cliconf/__init__.py�wrappedzenable_mode.<locals>.wrapped%sw����!�,�,�.�.���v�&;�<�<�<�B�B�D�D�M�M�c�R�R�	J��H�I�I�I��t�D�*�4�*�*�*�6�*�*�*�r)rrs` r�enable_moder!$s3���
�4�[�[�+�+�+�+��[�+�
�Nr c���eZdZdZgd�Z�fd�Zd�Zd!d�Zd	�Zd
�Z	d�Z
d�Zd
�Ze
d"d���Ze
d#d���Ze
d$d���Ze
d���Ze
d���Zd%d�Zd�Zd&d�Zd'd�Zd'd�Zd(d�Zd)d�Zd*d�Zd�Zd+d �Z�xZS),�CliconfBasea"
    A base class for implementing cli connections

    .. note:: String inputs to :meth:`send_command` will be cast to byte strings
         within this method and as such are not required to be made byte strings
         beforehand.  Please avoid using literal byte strings (``b'string'``) in
         :class:`CliConfBase` plugins as this can lead to unexpected errors when
         running on Python 3

    List of supported rpc's:
        :get_config: Retrieves the specified configuration from the device
        :edit_config: Loads the specified commands into the remote device
        :get: Execute specified command on remote device
        :get_capabilities: Retrieves device information and supported rpc methods
        :commit: Load configuration from candidate to running
        :discard_changes: Discard changes to candidate datastore

    Note: List of supported rpc's for remote device can be extracted from
          output of get_capabilities()

    :returns: Returns output received from remote device as byte string

            Usage:
            from ansible.module_utils.connection import Connection

            conn = Connection()
            conn.get('show lldp neighbors detail')
            conn.get_config('running')
            conn.edit_config(['hostname test', 'netconf ssh'])
    )�
get_config�edit_config�get_capabilities�get�enable_response_logging�disable_response_loggingc���tt|�����||_t	��|_d|_dS)NF)�superr#�__init__r�list�history�response_logging)r�
connection�	__class__s  �rr,zCliconfBase.__init__Ps@���
�k�4� � �)�)�+�+�+�%����v�v��� %����r c��|j�dd|jjjz��|���dS)z0Alarm handler raised in case of command timeout �logz2closing shell due to command timeout (%s seconds).N)r�
queue_message�
_play_context�timeout�close)r�signum�frames   r�_alarm_handlerzCliconfBase._alarm_handlerVsP����&�&�u�.b�ei�eu�fD�fL�/L�	M�	M�	M��
�
�����r NFTc��t|��||||d�}|�7t|t��rd�|D��|d<nt|��|d<|�7t|t��rd�|D��|d<nt|��|d<|jjd	i|��}	|js|j�d��n"|j�|d|	f��|	S)
aExecutes a command over the device connection

        This method will execute a command over the device connection and
        return the results to the caller.  This method will also perform
        logging of any commands based on the `nolog` argument.

        :param command: The command to send over the connection to the device
        :param prompt: A single regex pattern or a sequence of patterns to evaluate the expected prompt from the command
        :param answer: The answer to respond with if the prompt is matched.
        :param sendonly: Bool value that will send the command but not wait for a result.
        :param newline: Bool value that will append the newline character to the command
        :param prompt_retry_check: Bool value for trying to detect more prompts
        :param check_all: Bool value to indicate if all the values in prompt sequence should be matched or any one of
                          given prompt.
        :returns: The output from the device after executing the command
        )�command�sendonly�newline�prompt_retry_check�	check_allNc�,�g|]}t|����S��r��.0�ps  r�
<listcomp>z,CliconfBase.send_command.<locals>.<listcomp>v���#@�#@�#@�A�H�Q�K�K�#@�#@�#@r rc�,�g|]}t|����SrBrCrDs  rrGz,CliconfBase.send_command.<locals>.<listcomp>{rHr �answer)�*****rKr<rB)r�
isinstancer-r�sendr/r.�append)
rr<rrJr=r>r?r@r�resps
          r�send_commandzCliconfBase.send_command[s��$ ��(�(� ��"4�"�
�
�����&�$�'�'�
4�#@�#@��#@�#@�#@��x� � �#+�F�#3�#3��x� ����&�$�'�'�
4�#@�#@��#@�#@�#@��x� � �#+�F�#3�#3��x� �$�t��$�.�.�v�.�.���$�	;��L��� 2�3�3�3�3��L����	�!2�D� 9�:�:�:��r c��|jS)z:Returns list of base rpc method supported by remote device)�__rpc__�rs r�get_base_rpczCliconfBase.get_base_rpc�s
���|�r c��|jS)aR Returns the history file for all commands

        This will return a log of all the commands that have been sent to
        the device and all of the output received.  By default, all commands
        and output will be redacted unless explicitly configured otherwise.

        :return: An ordered list of command, output pairs
        )r.rSs r�get_historyzCliconfBase.get_history�s���|�r c�,�t��|_dS)zB Resets the history of run commands
        :return: None
        N)r-r.rSs r�
reset_historyzCliconfBase.reset_history�s���v�v����r c��d|_dS)zEnable logging command responseTN�r/rSs rr(z#CliconfBase.enable_response_logging�s�� $����r c��d|_dS)z Disable logging command responseFNrZrSs rr)z$CliconfBase.disable_response_logging�s�� %����r �runningc��dS)a�Retrieves the specified configuration from the device

        This method will retrieve the configuration specified by source and
        return it to the caller as a string.  Subsequent calls to this method
        will retrieve a new configuration from the device

        :param source: The configuration source to return from the device.
            This argument accepts either `running` or `startup` as valid values.

        :param flags: For devices that support configuration filtering, this
            keyword argument is used to filter the returned configuration.
            The use of this keyword argument is device dependent and will be
            silently ignored on devices that do not support it.

        :param format: For devices that support fetching different configuration
            format, this keyword argument is used to specify the format in which
            configuration is to be retrieved.

        :return: The device configuration as specified by the source argument.
        NrB)r�source�flags�formats    rr$zCliconfBase.get_config�s	��,	
�r c��dS)aeLoads the candidate configuration into the network device

        This method will load the specified candidate config into the device
        and merge with the current configuration unless replace is set to
        True.  If the device does not support config replace an errors
        is returned.

        :param candidate: The configuration to load into the device and merge
            with the current running configuration

        :param commit: Boolean value that indicates if the device candidate
            configuration should be  pushed in the running configuration or discarded.

        :param replace: If the value is True/False it indicates if running configuration should be completely
                        replace by candidate configuration. If can also take configuration file path as value,
                        the file in this case should be present on the remote host in the mentioned path as a
                        prerequisite.
        :param comment: Commit comment provided it is supported by remote host
        :return: Returns a json string with contains configuration applied on remote host, the returned
                 response on executing configuration commands and platform relevant data.
               {
                   "diff": "",
                   "response": [],
                   "request": []
               }

        NrB)r�	candidate�commit�replace�diff�comments      rr%zCliconfBase.edit_config�s	��:	
�r c��dS)a.Execute specified command on remote device
        This method will retrieve the specified data and
        return it to the caller as a string.
        :param command: command in string format to be executed on remote device
        :param prompt: the expected prompt generated by executing command, this can
                       be a string or a list of strings
        :param answer: the string to respond to the prompt with
        :param sendonly: bool to disable waiting for response, default is false
        :param newline: bool to indicate if newline should be added at end of answer or not
        :param output: For devices that support fetching command output in different
                       format, this keyword argument is used to specify the output in which
                        response is to be retrieved.
        :param check_all: Bool value to indicate if all the values in prompt sequence should be matched or any one of
                          given prompt.
        :return: The output from the device after executing the command
        NrB)rr<rrJr=r>�outputr@s        rr'zCliconfBase.get��	��$	
�r c�p�i}|���|d<|���|d<d|d<|S)a;
Returns the basic capabilities of the network device
        This method will provide some basic facts about the device and
        what capabilities it has to modify the configuration.  The minimum
        return from this method takes the following format.
        eg:
            {

                'rpc': [list of supported rpcs],
                'network_api': <str>,            # the name of the transport
                'device_info': {
                    'network_os': <str>,
                    'network_os_version': <str>,
                    'network_os_model': <str>,
                    'network_os_hostname': <str>,
                    'network_os_image': <str>,
                    'network_os_platform': <str>,
                },
                'device_operations': {
                    'supports_diff_replace': <bool>,       # identify if config should be merged or replaced is supported
                    'supports_commit': <bool>,             # identify if commit is supported by device or not
                    'supports_rollback': <bool>,           # identify if rollback is supported or not
                    'supports_defaults': <bool>,           # identify if fetching running config with default is supported
                    'supports_commit_comment': <bool>,     # identify if adding comment to commit is supported of not
                    'supports_onbox_diff': <bool>,          # identify if on box diff capability is supported or not
                    'supports_generate_diff': <bool>,       # identify if diff capability is supported within plugin
                    'supports_multiline_delimiter': <bool>, # identify if multiline demiliter is supported within config
                    'supports_diff_match': <bool>,          # identify if match is supported
                    'supports_diff_ignore_lines': <bool>,   # identify if ignore line in diff is supported
                    'supports_config_replace': <bool>,     # identify if running config replace with candidate config is supported
                    'supports_admin': <bool>,              # identify if admin configure mode is supported or not
                    'supports_commit_label': <bool>,       # identify if commit label is supported or not
                }
                'format': [list of supported configuration format],
                'diff_match': [list of supported match values],
                'diff_replace': [list of supported replace values],
                'output': [list of supported command output format]
            }
        :return: capability as json string
        �rpc�device_info�cliconf�network_api)rT�get_device_info)r�results  rr&zCliconfBase.get_capabilities�sD��R���)�)�+�+��u�
� $� 4� 4� 6� 6��}�� )��}���
r c��dS)aCReturns basic information about the network device.

        This method will provide basic information about the device such as OS version and model
        name. This data is expected to be used to fill the 'device_info' key in get_capabilities()
        above.

        :return: dictionary of device information
        NrBrSs rrozCliconfBase.get_device_infos	��	
�r c�P�|j�d|jjz��S)a�Commit configuration changes

        This method will perform the commit operation on a previously loaded
        candidate configuration that was loaded using `edit_config()`.  If
        there is a candidate configuration, it will be committed to the
        active configuration.  If there is not a candidate configuration, this
        method should just silently return.

        :return: None
        z(commit is not supported by network_os %s�r�method_not_foundr5�
network_os)rrfs  rrczCliconfBase.commit+s(����0�0�1[�^b�^p�^{�1{�|�|�|r c�P�|j�d|jjz��S)aDiscard candidate configuration

        This method will discard the current candidate configuration if one
        is present.  If there is no candidate configuration currently loaded,
        then this method should just silently return

        :returns: None
        z1discard_changes is not supported by network_os %srsrSs r�discard_changeszCliconfBase.discard_changes8s8����0�0�1d�gk�gy�hE�2E�F�F�	Fr c��dS)z�

        :param rollback_id: The commit id to which configuration should be rollbacked
        :param commit: Flag to indicate if changes should be committed or not
        :return: Returns diff between before and after change.
        NrB)r�rollback_idrcs   r�rollbackzCliconfBase.rollbackCs	��	
�r �scp�c��|jj���}|dkrjtst	d���t|���|���5}|�||��}ddd��dS#1swxYwYdS|dkrE|���5}|�||��ddd��dS#1swxYwYdSdS)a�Copies file over scp/sftp to remote device

        :param source: Source file path
        :param destination: Destination file path on remote device
        :param proto: Protocol to be used for file transfer,
                      supported protocol: scp and sftp
        :param timeout: Specifies the wait time to receive response from
                        remote host before triggering timeout exception
        :return: None
        r{�QRequired library scp is not installed.  Please install it using `pip install scp`��socket_timeoutN�sftp)	r�
paramiko_conn�_connect_uncached�HAS_SCPr
r�
get_transport�put�	open_sftp)	rr^�destination�protor6�sshr{�outr�s	         r�	copy_filezCliconfBase.copy_fileLsb����,�>�>�@�@���E�>�>��
x�"�#v�w�w�w��3�,�,�.�.�w�G�G�G�
3�3��g�g�f�k�2�2��
3�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3�
3����
3�
3�
3�
3�
3�
3�
�f�_�_������
.�D������-�-�-�
.�
.�
.�
.�
.�
.�
.�
.�
.�
.�
.�
.����
.�
.�
.�
.�
.�
.��_s$�B�B�	B�)C
�
C�Cc���	|jj���}|dkr|tst	d���	t|���|���5}|�||��ddd��dS#1swxYwYdS#t$rYdSwxYw|dkrE|�	��5}|�||��ddd��dS#1swxYwYdSdS)a�Fetch file over scp/sftp from remote device
        :param source: Source file path
        :param destination: Destination file path
        :param proto: Protocol to be used for file transfer,
                      supported protocol: scp and sftp
        :param timeout: Specifies the wait time to receive response from
                        remote host before triggering timeout exception
        :return: None
        r{r~rNr�)
rr�r�r�r
rr�r'�EOFErrorr�)rr^r�r�r6r�r{r�s        r�get_filezCliconfBase.get_fileas���	:���,�>�>�@�@���E�>�>��
x�"�#v�w�w�w�
��s�0�0�2�2�7�K�K�K�1�s��G�G�F�K�0�0�0�1�1�1�1�1�1�1�1�1�1�1�1����1�1�1�1�1�1���
�
�
����
�����f�_�_������
.�D������-�-�-�
.�
.�
.�
.�
.�
.�
.�
.�
.�
.�
.�
.����
.�
.�
.�
.�
.�
.��_sG�#B� B�7B�B�B�B�B�
B�B�<C � C$�'C$c��dS)a:	
        Generate diff between candidate and running configuration. If the
        remote host supports onbox diff capabilities ie. supports_onbox_diff in that case
        candidate and running configurations are not required to be passed as argument.
        In case if onbox diff capability is not supported candidate argument is mandatory
        and running argument is optional.
        :param candidate: The configuration which is expected to be present on remote host.
        :param running: The base configuration which is used to generate diff.
        :param diff_match: Instructs how to match the candidate configuration with current device configuration
                      Valid values are 'line', 'strict', 'exact', 'none'.
                      'line' - commands are matched line by line
                      'strict' - command lines are matched with respect to position
                      'exact' - command lines must be an equal match
                      'none' - will not compare the candidate configuration with the running configuration
        :param diff_ignore_lines: Use this argument to specify one or more lines that should be
                                  ignored during the diff.  This is used for lines in the configuration
                                  that are automatically updated by the system.  This argument takes
                                  a list of regular expressions or exact line matches.
        :param path: The ordered set of parents that uniquely identify the section or hierarchy
                     the commands should be checked against.  If the parents argument
                     is omitted, the commands are checked against the set of top
                    level or global commands.
        :param diff_replace: Instructs on the way to perform the configuration on the device.
                        If the replace argument is set to I(line) then the modified lines are
                        pushed to the device in configuration mode.  If the replace argument is
                        set to I(block) then the entire command block is pushed to the device in
                        configuration mode if any line is not correct.
        :return: Configuration and/or banner diff in json format.
               {
                   'config_diff': ''
               }

        NrB)rrbr\�
diff_match�diff_ignore_lines�path�diff_replaces       r�get_diffzCliconfBase.get_diffzs
��D	
�r c��dS)aI
        Execute a list of commands on remote host and return the list of response
        :param commands: The list of command that needs to be executed on remote host.
                The individual command in list can either be a command string or command dict.
                If the command is dict the valid keys are
                {
                    'command': <command to be executed>
                    'prompt': <expected prompt on executing the command>,
                    'answer': <answer for the prompt>,
                    'output': <the format in which command output should be rendered eg: 'json', 'text'>,
                    'sendonly': <Boolean flag to indicate if it command execution response should be ignored or not>
                }
        :param check_rc: Boolean flag to check if returned response should be checked for error or not.
                         If check_rc is False the error output is appended in return response list, else if the
                         value is True an exception is raised.
        :return: List of returned response
        NrB)r�commands�check_rcs   r�run_commandszCliconfBase.run_commands�rir c�*�|s|std���|dvrtd|z���|r|dstd���|r%|�dd��std���|r%|�dd��std���dSdS)	Nz9must provide a candidate or replace to load configuration)TFz'commit' must be a bool, got %s�supports_replacez&configuration replace is not supported�supports_commit_commentFzcommit comment is not supported)�
ValueErrorr')r�
operationsrbrcrdrfs      r�check_edit_config_capabilityz(CliconfBase.check_edit_config_capability�s����	Z��	Z��X�Y�Y�Y���&�&��>��G�H�H�H��	G�:�&8�9�	G��E�F�F�F��	@�:�>�>�*C�U�K�K�	@��>�?�?�?��	G�:�>�>�*<�e�D�D�	G��E�F�F�F�	G�	G�	G�	Gr c��dS)z\
        Ensure the command prompt on device is in right mode
        :return: None
        NrBrSs r�set_cli_prompt_contextz"CliconfBase.set_cli_prompt_context�s	��
	
�r �exitc��|j���}|�td|jjz����	t	|d������}|r_|�|��rJ|j�dd��|�|��|j���}ndS��)	a&
        Update the cli prompt context to ensure it is in operational mode
        :param config_context: It is string value to identify if the current cli prompt ends with config mode prompt
        :param exit_command: Command to execute to exit the config mode
        :return: None
        NzGcli prompt is not identified from the last received response window: %s)�messageT�surrogate_then_replacer�vvvvz%wrong context, sending exit to device)	rrr�_last_recv_windowr
rrr4rP)r�config_context�exit_commandr�s    r�_update_cli_prompt_contextz&CliconfBase._update_cli_prompt_context�s�����)�)�+�+���;�*�4K�MQ�M]�Mo�4p�q�q�q�
q�	��#�&>�?�?�?�E�E�G�G�C��
�#�,�,�~�">�">�
�� �.�.�v�7^�_�_�_��!�!�,�/�/�/��&�1�1�3�3�����	r )NNNFTFF)r\NN)NTNFN)NNNFTNF)N)T)NNr{r|)NNNNNN)NT)NTNN)Nr�)�__name__�
__module__�__qualname__�__doc__rRr,r:rPrTrVrXr(r)rr$r%r'r&rorcrwrzr�r�r�r�r�r�r��
__classcell__)r1s@rr#r#.s ���������>~�}�}�G�&�&�&�&�&����
+�+�+�+�Z���	�	�	����%�%�%�&�&�&��
�
�
��^�
�.�
�
�
��^�
�<�
�
�
��^�
�&�,�,��^�,�\�	
�	
��^�	
�}�}�}�}�	F�	F�	F�
�
�
�
�.�.�.�.�*.�.�.�.�2"
�"
�"
�"
�H
�
�
�
�(G�G�G�G�"
�
�
��������r r#N)�
__future__rrr�type�
__metaclass__�abcr�	functoolsr�ansible.pluginsr	�ansible.errorsr
r�ansible.module_utils._textrr
r{rr��ImportErrorr!r#rBr r�<module>r�s ��&C�B�B�B�B�B�B�B�B�B��
�������������)�)�)�)�)�)�A�A�A�A�A�A�A�A�8�8�8�8�8�8�8�8���������G�G�������G�G�G��������o�o�o�o�o�-�o�o�o�o�os�9�A�A

Youez - 2016 - github.com/yon3zu
LinuXploit