Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/module_utils/network/nos/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/module_utils/network/nos/nos.pyo

�
�Udac@ssddlZddlmZddlmZddlmZmZd�Zd�Z	d�Z
d�Zd	�ZdS(
i����N(tto_text(tto_list(t
ConnectiontConnectionErrorcCsmt|d�r|jSt|�}|jd�}|dkrRt|j�|_n|jdd|�|jS(s�Get switch connection

    Creates reusable SSH connection to the switch described in a given module.

    Args:
        module: A valid AnsibleModule instance.

    Returns:
        An instance of `ansible.module_utils.connection.Connection` with a
        connection to the switch described in the provided module.

    Raises:
        AnsibleConnectionFailure: An error occurred connecting to the device
    tnos_connectiontnetwork_apitcliconftmsgsInvalid connection type %s(thasattrRtget_capabilitiestgetRt_socket_patht	fail_json(tmoduletcapabilitiesR((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/nos/nos.pytget_connectionscCszt|d�r|jSyt|j�j�}Wn/tk
r`}|jdt|dd��nXtj	|�|_|jS(s�Get switch capabilities

    Collects and returns a python object with the switch capabilities.

    Args:
        module: A valid AnsibleModule instance.

    Returns:
        A dictionary containing the switch capabilities.
    tnos_capabilitiesRterrorstsurrogate_then_replace(
RRRRR	RRRtjsontloads(R
Rtexc((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/nos/nos.pyR	5s c
Cst�}t|�}x�t|�D]�}t|t�rX|d}|d}|d}n|}d}d}y+|j|||�}t|dd�}WnYtk
r�}	|j	dt|	��n1t
k
r�|j	dd|t|�f�nX|j|�q"W|S(	s.Run command list against connection.

    Get new or previously used connection and send commands to it one at a time,
    collecting response.

    Args:
        module: A valid AnsibleModule instance.
        commands: Iterable of command strings.

    Returns:
        A list of output strings.
    tcommandtprompttanswerRtsurrogate_or_strictRu#Failed to decode output from %s: %sN(tlistRRt
isinstancetdicttNoneR
RRRtUnicodeErrortappend(
R
tcommandst	responsest
connectiontcmdRRRtoutR((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/nos/nos.pytrun_commandsKs&
	



$cCs�t|d�si|_n|jikr1|jSt|�}y|j�}Wn/tk
r~}|jdt|dd��nXt|dd�j�}||_|S(s5Get switch configuration

    Gets the described device's current configuration. If a configuration has
    already been retrieved it will return the previously obtained configuration.

    Args:
        module: A valid AnsibleModule instance.

    Returns:
        A string containing the configuration.
    tdevice_configsRRR(RR&Rt
get_configRRRtstrip(R
R"R$Rtcfg((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/nos/nos.pyR'rs 	cCs\t|�}y |j|�}|jd�SWn)tk
rW}|jdt|��nXdS(sApply a list of commands to a device.

    Given a list of commands apply them to the device to modify the
    configuration in bulk.

    Args:
        module: A valid AnsibleModule instance.
        commands: Iterable of command strings.

    Returns:
        None
    tresponseRN(Rtedit_configR
RRR(R
R R"trespR((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/nos/nos.pytload_config�s
(
Rtansible.module_utils._textRt)ansible.module_utils.network.common.utilsRtansible.module_utils.connectionRRRR	R%R'R-(((sH/usr/lib/python2.7/site-packages/ansible/module_utils/network/nos/nos.pyt<module>s			'	

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]