�
�Udac @ ss d d l Z d d l m Z d d l m Z m Z d d l m Z d � Z d � Z d � Z
d � Z d � Z d S(
i����N( t to_text( t to_listt ComplexList( t
Connectionc C sm t | d � r | j St | � } | j d � } | d k rR t | j � | _ n | j d d | � | j S( 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
t slxos_connectiont network_apit cliconft msgs Invalid connection type %s( t hasattrR t get_capabilitiest getR t _socket_patht fail_json( t modulet capabilitiesR ( ( sL /usr/lib/python2.7/site-packages/ansible/module_utils/network/slxos/slxos.pyt get_connection s c C sD t | d � r | j St | j � j � } t j | � | _ | j S( 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.
t slxos_capabilities( R R R R R t jsont loads( R
R ( ( sL /usr/lib/python2.7/site-packages/ansible/module_utils/network/slxos/slxos.pyR 5 s
c C s� t � } t | � } x� t | � D]� } t | t � rX | d } | d } | d } n | } d } d } | j | | | � } y t | d d �} Wn1 t k
r� | j d d | t | � f � n X| j
| � q"