[Python-modules-commits] [netmiko] 01/04: New upstream release.

Vincent Bernat bernat at moszumanska.debian.org
Sun Nov 12 18:49:42 UTC 2017


This is an automated email from the git hooks/post-receive script.

bernat pushed a commit to annotated tag debian/1.4.3-1
in repository netmiko.

commit aeeac8b2129bc4fc27d27401a18ac7506e283208
Author: Vincent Bernat <bernat at debian.org>
Date:   Sun Nov 12 19:46:24 2017 +0100

    New upstream release.
---
 COMMON_ISSUES.md                           |  94 +++++
 PKG-INFO                                   |   4 +-
 README.md                                  |  47 ++-
 TESTING.md                                 |  20 +-
 netmiko.egg-info/PKG-INFO                  |   4 +-
 netmiko.egg-info/SOURCES.txt               |  27 ++
 netmiko.egg-info/top_level.txt             |   9 +
 netmiko/__init__.py                        |  19 +-
 netmiko/a10/__init__.py                    |   1 +
 netmiko/a10/a10_ssh.py                     |   2 +
 netmiko/accedian/__init__.py               |   3 +
 netmiko/accedian/accedian_ssh.py           |  38 ++
 netmiko/alcatel/__init__.py                |   4 +-
 netmiko/alcatel/alcatel_aos_ssh.py         |  36 ++
 netmiko/alcatel/alcatel_sros_ssh.py        |   1 +
 netmiko/arista/__init__.py                 |   1 +
 netmiko/arista/arista_ssh.py               |  21 +-
 netmiko/aruba/__init__.py                  |   1 +
 netmiko/aruba/aruba_ssh.py                 |   8 +-
 netmiko/avaya/__init__.py                  |   1 +
 netmiko/avaya/avaya_vsp_ssh.py             |   1 +
 netmiko/base_connection.py                 | 567 +++++++++++++++++++----------
 netmiko/brocade/__init__.py                |   1 +
 netmiko/brocade/brocade_fastiron_ssh.py    |  37 ++
 netmiko/brocade/brocade_netiron_ssh.py     |   1 +
 netmiko/brocade/brocade_nos_ssh.py         |   1 +
 netmiko/checkpoint/__init__.py             |   4 +
 netmiko/checkpoint/checkpoint_gaia_ssh.py  |  26 ++
 netmiko/ciena/__init__.py                  |   4 +
 netmiko/ciena/ciena_saos_ssh.py            |  15 +
 netmiko/cisco/__init__.py                  |   6 +-
 netmiko/cisco/cisco_asa_ssh.py             |  33 +-
 netmiko/cisco/cisco_ios.py                 |  21 +-
 netmiko/cisco/cisco_nxos_ssh.py            |  12 +-
 netmiko/cisco/cisco_s300.py                |   1 +
 netmiko/cisco/cisco_tp_tcce.py             |  80 ++++
 netmiko/cisco/cisco_wlc_ssh.py             |  17 +-
 netmiko/cisco/cisco_xr_ssh.py              |   1 +
 netmiko/cisco_base_connection.py           |  95 ++++-
 netmiko/dell/__init__.py                   |   5 +-
 netmiko/dell/dell_force10_ssh.py           |   6 +-
 netmiko/dell/dell_powerconnect_ssh.py      |  94 +++++
 netmiko/dell/dell_powerconnect_telnet.py   |  38 ++
 netmiko/eltex/__init__.py                  |   4 +
 netmiko/eltex/eltex_ssh.py                 |  14 +
 netmiko/enterasys/__init__.py              |   1 +
 netmiko/enterasys/enterasys_ssh.py         |   3 +-
 netmiko/extreme/__init__.py                |   4 +-
 netmiko/extreme/extreme_ssh.py             |  57 ++-
 netmiko/extreme/extreme_wing_ssh.py        |  13 +
 netmiko/f5/__init__.py                     |   1 +
 netmiko/f5/f5_ltm_ssh.py                   |   1 +
 netmiko/fortinet/__init__.py               |   1 +
 netmiko/fortinet/fortinet_ssh.py           |  25 +-
 netmiko/hp/__init__.py                     |   1 +
 netmiko/hp/hp_comware_ssh.py               |   6 +-
 netmiko/hp/hp_procurve_ssh.py              |  40 +-
 netmiko/huawei/__init__.py                 |   1 +
 netmiko/huawei/huawei_ssh.py               |  32 +-
 netmiko/juniper/__init__.py                |   1 +
 netmiko/juniper/juniper_ssh.py             |   5 +-
 netmiko/linux/__init__.py                  |   1 +
 netmiko/linux/linux_ssh.py                 |   7 +-
 netmiko/mellanox/__init__.py               |   4 +
 netmiko/mellanox/mellanox_ssh.py           |  49 +++
 netmiko/mrv/__init__.py                    |   4 +
 netmiko/mrv/mrv_ssh.py                     |  27 ++
 netmiko/netmiko_globals.py                 |   1 +
 netmiko/ovs/__init__.py                    |   1 +
 netmiko/ovs/ovs_linux_ssh.py               |   1 +
 netmiko/paloalto/__init__.py               |   1 +
 netmiko/paloalto/paloalto_panos_ssh.py     |  11 +-
 netmiko/pluribus/__init__.py               |   4 +
 netmiko/pluribus/pluribus_ssh.py           |  37 ++
 netmiko/py23_compat.py                     |  15 +
 netmiko/quanta/__init__.py                 |   1 +
 netmiko/quanta/quanta_mesh_ssh.py          |   1 +
 netmiko/scp_handler.py                     | 176 ++++++++-
 netmiko/snmp_autodetect.py                 | 270 ++++++++++++++
 netmiko/ssh_autodetect.py                  | 265 ++++++++++++++
 netmiko/ssh_dispatcher.py                  | 132 ++++---
 netmiko/ssh_exception.py                   |   1 +
 netmiko/terminal_server/__init__.py        |   5 +
 netmiko/terminal_server/terminal_server.py |  24 ++
 netmiko/ubiquiti/__init__.py               |   4 +
 netmiko/ubiquiti/edge_ssh.py               |  25 ++
 netmiko/utilities.py                       |   9 +-
 netmiko/vyos/__init__.py                   |   1 +
 netmiko/vyos/vyos_ssh.py                   |   5 +-
 requirements.txt                           |   1 -
 setup.cfg                                  |  11 +-
 setup.py                                   |  40 +-
 92 files changed, 2334 insertions(+), 417 deletions(-)

diff --git a/COMMON_ISSUES.md b/COMMON_ISSUES.md
new file mode 100644
index 0000000..94898e8
--- /dev/null
+++ b/COMMON_ISSUES.md
@@ -0,0 +1,94 @@
+### Show commands that prompt for more information
+
+In these cases, I generally use the send_command_timing() method (which doesn't look for prompts)
+
+
+For example, a CLI interaction that looks like this:
+
+```
+pynet-rtr1#copy running-config flash:test1.txt
+Destination filename [test1.txt]? 
+5587 bytes copied in 1.316 secs (4245 bytes/sec)
+
+pynet-rtr1#
+```
+
+```python
+cmd1 = "copy running-config flash:test1.txt
+output = net_connect.send_command_timing(cmd1)
+if 'Destination filename' in output:
+    output += net_connect.send_command_timing("\n")
+print(output)
+```
+
+### Enable Netmiko logging of all reads and writes of the communications channel
+
+This will create a file named 'test.log' in the current working directory.
+
+```python
+import logging
+logging.basicConfig(filename='test.log', level=logging.DEBUG)
+logger = logging.getLogger("netmiko")
+```
+
+### Does Netmiko support connecting via a terminal server
+
+There is a 'terminal_server' device_type that basically does nothing post SSH connect. This means you have to manually handle the interaction with the terminal server to connect to the end device. After you are fully connected to the end network device, you can then 'redispatch' and Netmiko will behave normally
+
+```python
+from __future__ import unicode_literals, print_function
+import time
+from netmiko import ConnectHandler, redispatch
+
+net_connect = ConnectHandler(
+    device_type='terminal_server',        # Notice 'terminal_server' here
+    ip='10.10.10.10', 
+    username='admin', 
+    password='admin123', 
+    secret='secret123')
+
+# Manually handle interaction in the Terminal Server 
+# (fictional example, but hopefully you see the pattern)
+# Send Enter a Couple of Times
+net_connect.write_channel("\r\n")
+time.sleep(1)
+net_connect.write_channel("\r\n")
+time.sleep(1)
+output = net_connect.read_channel()
+print(output)                             # Should hopefully see the terminal server prompt
+
+# Login to end device from terminal server
+net_connect.write_channel("connect 1\r\n")
+time.sleep(1)
+
+# Manually handle the Username and Password
+max_loops = 10
+i = 1
+while i <= max_loops:
+    output = net_connect.read_channel()
+    
+    if 'Username' in output:
+        net_connect.write_channel(net_connect.username + '\r\n')
+        time.sleep(1)
+        output = net_connect.read_channel()
+
+    # Search for password pattern / send password
+    if 'Password' in output:
+        net_connect.write_channel(net_connect.password + '\r\n')
+        time.sleep(.5)
+        output = net_connect.read_channel()
+        # Did we successfully login
+        if '>' in output or '#' in output:
+            break
+
+    net_connect.write_channel('\r\n')
+    time.sleep(.5)
+    i += 1
+
+# We are now logged into the end device 
+# Dynamically reset the class back to the proper Netmiko class
+redispatch(net_connect, device_type='cisco_ios')
+
+# Now just do your normal Netmiko operations
+new_output = net_connect.send_command("show ip int brief")
+```
diff --git a/PKG-INFO b/PKG-INFO
index e518f12..d9555ff 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: netmiko
-Version: 1.1.0
+Version: 1.4.3
 Summary: Multi-vendor library to simplify Paramiko SSH connections to network devices
 Home-page: https://github.com/ktbyers/netmiko
 Author: Kirk Byers
@@ -11,9 +11,7 @@ Platform: UNKNOWN
 Classifier: Development Status :: 4 - Beta
 Classifier: License :: OSI Approved :: MIT License
 Classifier: Programming Language :: Python :: 2
-Classifier: Programming Language :: Python :: 2.6
 Classifier: Programming Language :: Python :: 2.7
 Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.3
 Classifier: Programming Language :: Python :: 3.4
 Classifier: Programming Language :: Python :: 3.5
diff --git a/README.md b/README.md
index a95f264..be740c1 100644
--- a/README.md
+++ b/README.md
@@ -1,26 +1,30 @@
+[![PyPI](https://img.shields.io/pypi/v/netmiko.svg)](https://pypi.python.org/pypi/netmiko)
+  
+  
 Netmiko
 =======
 
 Multi-vendor library to simplify Paramiko SSH connections to network devices
 
-Python 2.6, 2.7, 3.3, 3.4, 3.5  
+Python 2.7, 3.4, 3.5  
 
-<br>
 #### Requires:
+
 Paramiko >= 1.13+  
 scp >= 0.10.0  
 pyyaml  
 pytest (for unit tests)   
 
-
-<br>
 #### Supports:
 
 ###### Regularly tested
+
 Arista vEOS  
 Cisco ASA  
 Cisco IOS  
+Cisco IOS-XE  
 Cisco IOS-XR  
+Cisco NX-OS  
 Cisco SG300  
 HP Comware7  
 HP ProCurve  
@@ -28,39 +32,49 @@ Juniper Junos
 Linux  
   
 ###### Limited testing
+
+Alcatel AOS6/AOS8  
 Avaya ERS  
 Avaya VSP  
 Brocade VDX  
 Brocade ICX/FastIron  
 Brocade MLX/NetIron  
-Cisco IOS-XE  
-Cisco NX-OS  
 Cisco WLC  
 Dell-Force10 DNOS9  
+Dell PowerConnect  
 Huawei  
+Mellanox  
 Palo Alto PAN-OS  
+Pluribus  
+Ubiquiti EdgeOS  
 Vyatta VyOS  
 
 ###### Experimental
+
 A10  
+Accedian  
 Alcatel-Lucent SR-OS  
+Aruba  
+Ciena SAOS  
+Cisco Telepresence  
+CheckPoint Gaia  
 Enterasys  
-Extreme  
+Extreme EXOS  
+Extreme Wing  
 F5 LTM  
 Fortinet  
+MRV Communications OptiSwitch  
 
-
-<br>
 ## Tutorials:
 
 ##### Standard Tutorial:
+
 https://pynet.twb-tech.com/blog/automation/netmiko.html
 
 ##### SSH Proxy:
-https://pynet.twb-tech.com/blog/automation/netmiko-proxy.html
 
+https://pynet.twb-tech.com/blog/automation/netmiko-proxy.html
 
-<br>
 ## Examples:
 
 #### Create a dictionary representing the device.
@@ -81,14 +95,14 @@ cisco_881 = {
 
 ```
 
-<br>
 #### Establish an SSH connection to the device by passing in the device dictionary.
+
 ```py
 net_connect = ConnectHandler(**cisco_881)
 ```
 
-<br>
 #### Execute show commands.
+
 ```py
 output = net_connect.send_command('show ip int brief')
 print(output)
@@ -103,27 +117,27 @@ FastEthernet4              10.10.10.10     YES manual up                    up
 Vlan1                      unassigned      YES unset  down                  down    
 ```
 
-<br>
 #### For long-running commands, use `send_command_expect()`
 
 `send_command_expect` waits for the trailing prompt (or for an optional pattern)
 ```py
 net_connect.send_command_expect('write memory')
 ```
+
 ```
 Building configuration...
 [OK]
 ```
 
-<br>
 #### Enter and exit enable mode.
+
 ```py
 net_connect.enable()
 net_connect.exit_enable_mode()
 ```
 
-<br>
 #### Execute configuration change commands (will automatically enter into config mode)
+
 ```py
 config_commands = [ 'logging buffered 20000',
                     'logging buffered 20010',
@@ -150,7 +164,6 @@ If you have questions or would like to discuss Netmiko, a Netmiko channel exists
 
 
 
-<br>
 ---    
 Kirk Byers  
 Python for Network Engineers  
diff --git a/TESTING.md b/TESTING.md
index 931c4bd..9a981fe 100644
--- a/TESTING.md
+++ b/TESTING.md
@@ -2,16 +2,16 @@
 
 This document covers the test suite for Netmiko.
 
-<br />
 ## The simple version
 
+```
 cd ./netmiko/tests/etc  
 cp test_devices.yml.example test_devices.yml  
 cp responses.yml.example responses.yml  
 cp commands.yml.example commands.yml  
+```
 
-<br />
-##### edit test_devices.yml  
+#### edit test_devices.yml
 
 Pick the device_types you want to test against; update:
 * ip 
@@ -19,8 +19,7 @@ Pick the device_types you want to test against; update:
 * password
 * secret (optional)
 
-<br />
-##### edit responses.yml  
+#### edit responses.yml
 
 For the device_types that you are testing against, update the following to match the test 
 device(s):  
@@ -29,18 +28,19 @@ device(s):
 * enable_prompt
 * interface_ip
 
-<br />
-##### Execute the test
+#### Execute the test
+```
 cd ./netmiko/tests
+```
 
 Note, the test_device is the name of the device from test_devices.yml and responses.yml:  
+```
 py.test -v test_netmiko_show.py --test_device cisco881  
 py.test -v test_netmiko_config.py --test_device cisco881
+```
 
-<br />
 There are three tests available:  
 * test_netmiko_show.py  
 * test_netmiko_config.py  
-* test_netmiko_commit.py      # currently only for Juniper  
+* test_netmiko_commit.py      # currently only for Juniper and IOS-XR  
 
-<br />
diff --git a/netmiko.egg-info/PKG-INFO b/netmiko.egg-info/PKG-INFO
index e518f12..d9555ff 100644
--- a/netmiko.egg-info/PKG-INFO
+++ b/netmiko.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: netmiko
-Version: 1.1.0
+Version: 1.4.3
 Summary: Multi-vendor library to simplify Paramiko SSH connections to network devices
 Home-page: https://github.com/ktbyers/netmiko
 Author: Kirk Byers
@@ -11,9 +11,7 @@ Platform: UNKNOWN
 Classifier: Development Status :: 4 - Beta
 Classifier: License :: OSI Approved :: MIT License
 Classifier: Programming Language :: Python :: 2
-Classifier: Programming Language :: Python :: 2.6
 Classifier: Programming Language :: Python :: 2.7
 Classifier: Programming Language :: Python :: 3
-Classifier: Programming Language :: Python :: 3.3
 Classifier: Programming Language :: Python :: 3.4
 Classifier: Programming Language :: Python :: 3.5
diff --git a/netmiko.egg-info/SOURCES.txt b/netmiko.egg-info/SOURCES.txt
index 163e6e7..e3534b8 100644
--- a/netmiko.egg-info/SOURCES.txt
+++ b/netmiko.egg-info/SOURCES.txt
@@ -1,3 +1,4 @@
+COMMON_ISSUES.md
 LICENSE
 MANIFEST.in
 README.md
@@ -10,7 +11,10 @@ netmiko/__init__.py
 netmiko/base_connection.py
 netmiko/cisco_base_connection.py
 netmiko/netmiko_globals.py
+netmiko/py23_compat.py
 netmiko/scp_handler.py
+netmiko/snmp_autodetect.py
+netmiko/ssh_autodetect.py
 netmiko/ssh_dispatcher.py
 netmiko/ssh_exception.py
 netmiko/utilities.py
@@ -21,7 +25,10 @@ netmiko.egg-info/requires.txt
 netmiko.egg-info/top_level.txt
 netmiko/a10/__init__.py
 netmiko/a10/a10_ssh.py
+netmiko/accedian/__init__.py
+netmiko/accedian/accedian_ssh.py
 netmiko/alcatel/__init__.py
+netmiko/alcatel/alcatel_aos_ssh.py
 netmiko/alcatel/alcatel_sros_ssh.py
 netmiko/arista/__init__.py
 netmiko/arista/arista_ssh.py
@@ -34,19 +41,29 @@ netmiko/brocade/__init__.py
 netmiko/brocade/brocade_fastiron_ssh.py
 netmiko/brocade/brocade_netiron_ssh.py
 netmiko/brocade/brocade_nos_ssh.py
+netmiko/checkpoint/__init__.py
+netmiko/checkpoint/checkpoint_gaia_ssh.py
+netmiko/ciena/__init__.py
+netmiko/ciena/ciena_saos_ssh.py
 netmiko/cisco/__init__.py
 netmiko/cisco/cisco_asa_ssh.py
 netmiko/cisco/cisco_ios.py
 netmiko/cisco/cisco_nxos_ssh.py
 netmiko/cisco/cisco_s300.py
+netmiko/cisco/cisco_tp_tcce.py
 netmiko/cisco/cisco_wlc_ssh.py
 netmiko/cisco/cisco_xr_ssh.py
 netmiko/dell/__init__.py
 netmiko/dell/dell_force10_ssh.py
+netmiko/dell/dell_powerconnect_ssh.py
+netmiko/dell/dell_powerconnect_telnet.py
+netmiko/eltex/__init__.py
+netmiko/eltex/eltex_ssh.py
 netmiko/enterasys/__init__.py
 netmiko/enterasys/enterasys_ssh.py
 netmiko/extreme/__init__.py
 netmiko/extreme/extreme_ssh.py
+netmiko/extreme/extreme_wing_ssh.py
 netmiko/f5/__init__.py
 netmiko/f5/f5_ltm_ssh.py
 netmiko/fortinet/__init__.py
@@ -60,11 +77,21 @@ netmiko/juniper/__init__.py
 netmiko/juniper/juniper_ssh.py
 netmiko/linux/__init__.py
 netmiko/linux/linux_ssh.py
+netmiko/mellanox/__init__.py
+netmiko/mellanox/mellanox_ssh.py
+netmiko/mrv/__init__.py
+netmiko/mrv/mrv_ssh.py
 netmiko/ovs/__init__.py
 netmiko/ovs/ovs_linux_ssh.py
 netmiko/paloalto/__init__.py
 netmiko/paloalto/paloalto_panos_ssh.py
+netmiko/pluribus/__init__.py
+netmiko/pluribus/pluribus_ssh.py
 netmiko/quanta/__init__.py
 netmiko/quanta/quanta_mesh_ssh.py
+netmiko/terminal_server/__init__.py
+netmiko/terminal_server/terminal_server.py
+netmiko/ubiquiti/__init__.py
+netmiko/ubiquiti/edge_ssh.py
 netmiko/vyos/__init__.py
 netmiko/vyos/vyos_ssh.py
\ No newline at end of file
diff --git a/netmiko.egg-info/top_level.txt b/netmiko.egg-info/top_level.txt
index a9fee05..99d5499 100644
--- a/netmiko.egg-info/top_level.txt
+++ b/netmiko.egg-info/top_level.txt
@@ -1,12 +1,16 @@
 netmiko
 netmiko/a10
+netmiko/accedian
 netmiko/alcatel
 netmiko/arista
 netmiko/aruba
 netmiko/avaya
 netmiko/brocade
+netmiko/checkpoint
+netmiko/ciena
 netmiko/cisco
 netmiko/dell
+netmiko/eltex
 netmiko/enterasys
 netmiko/extreme
 netmiko/f5
@@ -15,7 +19,12 @@ netmiko/hp
 netmiko/huawei
 netmiko/juniper
 netmiko/linux
+netmiko/mellanox
+netmiko/mrv
 netmiko/ovs
 netmiko/paloalto
+netmiko/pluribus
 netmiko/quanta
+netmiko/terminal_server
+netmiko/ubiquiti
 netmiko/vyos
diff --git a/netmiko/__init__.py b/netmiko/__init__.py
index ba155d0..8d1414f 100644
--- a/netmiko/__init__.py
+++ b/netmiko/__init__.py
@@ -1,17 +1,32 @@
+from __future__ import unicode_literals
+import logging
+
+# Logging configuration
+log = logging.getLogger(__name__) # noqa
+log.addHandler(logging.NullHandler()) # noqa
+
 from netmiko.ssh_dispatcher import ConnectHandler
 from netmiko.ssh_dispatcher import ssh_dispatcher
+from netmiko.ssh_dispatcher import redispatch
 from netmiko.ssh_dispatcher import platforms
 from netmiko.scp_handler import SCPConn
 from netmiko.scp_handler import FileTransfer
+from netmiko.scp_handler import InLineTransfer
 from netmiko.ssh_exception import NetMikoTimeoutException
 from netmiko.ssh_exception import NetMikoAuthenticationException
+from netmiko.ssh_autodetect import SSHDetect
+from netmiko.base_connection import BaseConnection
 
 # Alternate naming
 NetmikoTimeoutError = NetMikoTimeoutException
 NetmikoAuthError = NetMikoAuthenticationException
 
-__version__ = '1.1.0'
+__version__ = '1.4.3'
 
 __all__ = ('ConnectHandler', 'ssh_dispatcher', 'platforms', 'SCPConn', 'FileTransfer',
            'NetMikoTimeoutException', 'NetMikoAuthenticationException',
-           'NetmikoTimeoutError', 'NetmikoAuthError')
+           'NetmikoTimeoutError', 'NetmikoAuthError', 'InLineTransfer', 'redispatch',
+           'SSHDetect', 'BaseConnection')
+
+# Cisco cntl-shift-six sequence
+CNTL_SHIFT_6 = chr(30)
diff --git a/netmiko/a10/__init__.py b/netmiko/a10/__init__.py
index bb82984..c1ebaf4 100644
--- a/netmiko/a10/__init__.py
+++ b/netmiko/a10/__init__.py
@@ -1,3 +1,4 @@
+from __future__ import unicode_literals
 from netmiko.a10.a10_ssh import A10SSH
 
 __all__ = ['A10SSH']
diff --git a/netmiko/a10/a10_ssh.py b/netmiko/a10/a10_ssh.py
index c89e029..2f721eb 100644
--- a/netmiko/a10/a10_ssh.py
+++ b/netmiko/a10/a10_ssh.py
@@ -1,4 +1,5 @@
 """A10 support."""
+from __future__ import unicode_literals
 from netmiko.cisco_base_connection import CiscoSSHConnection
 
 
@@ -6,6 +7,7 @@ class A10SSH(CiscoSSHConnection):
     """A10 support."""
     def session_preparation(self):
         """A10 requires to be enable mode to disable paging."""
+        self._test_channel_read()
         self.set_base_prompt()
         self.enable()
         self.disable_paging(command="terminal length 0\n")
diff --git a/netmiko/accedian/__init__.py b/netmiko/accedian/__init__.py
new file mode 100644
index 0000000..7855953
--- /dev/null
+++ b/netmiko/accedian/__init__.py
@@ -0,0 +1,3 @@
+from netmiko.accedian.accedian_ssh import AccedianSSH
+
+__all__ = ['AccedianSSH']
diff --git a/netmiko/accedian/accedian_ssh.py b/netmiko/accedian/accedian_ssh.py
new file mode 100644
index 0000000..aa0bbcc
--- /dev/null
+++ b/netmiko/accedian/accedian_ssh.py
@@ -0,0 +1,38 @@
+
+from __future__ import unicode_literals
+from netmiko.cisco_base_connection import CiscoSSHConnection
+
+
+class AccedianSSH(CiscoSSHConnection):
+    def session_preparation(self):
+        self._test_channel_read()
+        self.set_base_prompt()
+
+    def check_enable_mode(self, *args, **kwargs):
+        raise AttributeError("Accedian devices do not support enable mode!")
+
+    def enable(self, *args, **kwargs):
+        raise AttributeError("Accedian devices do not support enable mode!")
+
+    def exit_enable_mode(self, *args, **kwargs):
+        raise AttributeError("Accedian devices do not support enable mode!")
+
+    def check_config_mode(self):
+        """Accedian devices do not have a config mode."""
+        return False
+
+    def config_mode(self):
+        """Accedian devices do not have a config mode."""
+        return ''
+
+    def exit_config_mode(self):
+        """Accedian devices do not have a config mode."""
+        return ''
+
+    def set_base_prompt(self, pri_prompt_terminator=':', alt_prompt_terminator='#',
+                        delay_factor=2):
+        """Sets self.base_prompt: used as delimiter for stripping of trailing prompt in output."""
+        super(AccedianSSH, self).set_base_prompt(pri_prompt_terminator=pri_prompt_terminator,
+                                                 alt_prompt_terminator=alt_prompt_terminator,
+                                                 delay_factor=delay_factor)
+        return self.base_prompt
diff --git a/netmiko/alcatel/__init__.py b/netmiko/alcatel/__init__.py
index f9c18d3..f3d15dd 100644
--- a/netmiko/alcatel/__init__.py
+++ b/netmiko/alcatel/__init__.py
@@ -1,3 +1,5 @@
+from __future__ import unicode_literals
 from netmiko.alcatel.alcatel_sros_ssh import AlcatelSrosSSH
+from netmiko.alcatel.alcatel_aos_ssh import AlcatelAosSSH
 
-__all__ = ['AlcatelSrosSSH']
+__all__ = ['AlcatelSrosSSH', 'AlcatelAosSSH']
diff --git a/netmiko/alcatel/alcatel_aos_ssh.py b/netmiko/alcatel/alcatel_aos_ssh.py
new file mode 100644
index 0000000..5e1f0fc
--- /dev/null
+++ b/netmiko/alcatel/alcatel_aos_ssh.py
@@ -0,0 +1,36 @@
+"""Alcatel-Lucent Enterprise AOS support (AOS6 and AOS8)."""
+from __future__ import print_function
+from __future__ import unicode_literals
+from netmiko.cisco_base_connection import CiscoSSHConnection
+
+
+class AlcatelAosSSH(CiscoSSHConnection):
+    """Alcatel-Lucent Enterprise AOS support (AOS6 and AOS8)."""
+    def session_preparation(self):
+        # Prompt can be anything, but best practice is to end with > or #
+        self._test_channel_read(pattern=r'[>#]')
+        self.set_base_prompt()
+
+    def check_enable_mode(self, *args, **kwargs):
+        """No enable mode on AOS"""
+        pass
+
+    def enable(self, *args, **kwargs):
+        """No enable mode on AOS"""
+        pass
+
+    def exit_enable_mode(self, *args, **kwargs):
+        """No enable mode on AOS"""
+        pass
+
+    def check_config_mode(self, *args, **kwargs):
+        """No config mode on AOS"""
+        pass
+
+    def config_mode(self, *args, **kwargs):
+        """No config mode on AOS"""
+        return ''
+
+    def exit_config_mode(self, *args, **kwargs):
+        """No config mode on AOS"""
+        return ''
diff --git a/netmiko/alcatel/alcatel_sros_ssh.py b/netmiko/alcatel/alcatel_sros_ssh.py
index fa8e299..8c7054c 100644
--- a/netmiko/alcatel/alcatel_sros_ssh.py
+++ b/netmiko/alcatel/alcatel_sros_ssh.py
@@ -8,6 +8,7 @@ from netmiko.cisco_base_connection import CiscoSSHConnection
 class AlcatelSrosSSH(CiscoSSHConnection):
     """Alcatel-Lucent SROS support."""
     def session_preparation(self):
+        self._test_channel_read()
         self.set_base_prompt()
         self.disable_paging(command="environment no more\n")
 
diff --git a/netmiko/arista/__init__.py b/netmiko/arista/__init__.py
index 04c12b7..fdbc7f5 100644
--- a/netmiko/arista/__init__.py
+++ b/netmiko/arista/__init__.py
@@ -1,3 +1,4 @@
+from __future__ import unicode_literals
 from netmiko.arista.arista_ssh import AristaSSH
 
 __all__ = ['AristaSSH']
diff --git a/netmiko/arista/arista_ssh.py b/netmiko/arista/arista_ssh.py
index 0708a32..5de156b 100644
--- a/netmiko/arista/arista_ssh.py
+++ b/netmiko/arista/arista_ssh.py
@@ -1,23 +1,16 @@
 from __future__ import unicode_literals
-import time
 from netmiko.cisco_base_connection import CiscoSSHConnection
+from netmiko import log
 
 
 class AristaSSH(CiscoSSHConnection):
     def session_preparation(self):
         """Prepare the session after the connection has been established."""
+        self._test_channel_read(pattern=r'[>#]')
         self.set_base_prompt()
         self.disable_paging()
         self.set_terminal_width(command='terminal width 511')
 
-    def special_login_handler(self, delay_factor=1):
-        """
-        Arista adds a "Last login: " message that doesn't always have sufficient time to be handled
-        """
-        delay_factor = self.select_delay_factor(delay_factor)
-        time.sleep(3 * delay_factor)
-        self.clear_buffer()
-
     def check_config_mode(self, check_string=')#', pattern=''):
         """
         Checks if the device is in configuration mode or not.
@@ -27,15 +20,11 @@ class AristaSSH(CiscoSSHConnection):
 
         Can also be (s2)
         """
-        debug = False
-        if debug:
-            print("pattern: {}".format(pattern))
+        log.debug("pattern: {0}".format(pattern))
         self.write_channel('\n')
         output = self.read_until_pattern(pattern=pattern)
-        if debug:
-            print("check_config_mode: {}".format(repr(output)))
+        log.debug("check_config_mode: {0}".format(repr(output)))
         output = output.replace("(s1)", "")
         output = output.replace("(s2)", "")
-        if debug:
-            print("check_config_mode: {}".format(repr(output)))
+        log.debug("check_config_mode: {0}".format(repr(output)))
         return check_string in output
diff --git a/netmiko/aruba/__init__.py b/netmiko/aruba/__init__.py
index cc71d05..0a9847d 100644
--- a/netmiko/aruba/__init__.py
+++ b/netmiko/aruba/__init__.py
@@ -1,3 +1,4 @@
+from __future__ import unicode_literals
 from netmiko.aruba.aruba_ssh import ArubaSSH
 
 __all__ = ['ArubaSSH']
diff --git a/netmiko/aruba/aruba_ssh.py b/netmiko/aruba/aruba_ssh.py
index 092a363..b1709b2 100644
--- a/netmiko/aruba/aruba_ssh.py
+++ b/netmiko/aruba/aruba_ssh.py
@@ -1,4 +1,7 @@
 """Aruba OS support"""
+from __future__ import unicode_literals
+import time
+import re
 from netmiko.cisco_base_connection import CiscoSSHConnection
 
 
@@ -6,6 +9,9 @@ class ArubaSSH(CiscoSSHConnection):
     """Aruba OS support"""
     def session_preparation(self):
         """Aruba OS requires enable mode to disable paging."""
+        delay_factor = self.select_delay_factor(delay_factor=0)
+        time.sleep(1 * delay_factor)
+        self._test_channel_read()
         self.set_base_prompt()
         self.enable()
         self.disable_paging(command="no paging")
@@ -17,6 +23,6 @@ class ArubaSSH(CiscoSSHConnection):
         Aruba uses "(<controller name>) (config) #" as config prompt
         """
         if not pattern:
-            pattern = self.base_prompt[:16]
+            pattern = re.escape(self.base_prompt[:16])
         return super(ArubaSSH, self).check_config_mode(check_string=check_string,
                                                        pattern=pattern)
diff --git a/netmiko/avaya/__init__.py b/netmiko/avaya/__init__.py
index dea4de5..54bd407 100644
--- a/netmiko/avaya/__init__.py
+++ b/netmiko/avaya/__init__.py
@@ -1,3 +1,4 @@
+from __future__ import unicode_literals
 from netmiko.avaya.avaya_vsp_ssh import AvayaVspSSH
 from netmiko.avaya.avaya_ers_ssh import AvayaErsSSH
 
diff --git a/netmiko/avaya/avaya_vsp_ssh.py b/netmiko/avaya/avaya_vsp_ssh.py
index ad91f4a..1414fbf 100644
--- a/netmiko/avaya/avaya_vsp_ssh.py
+++ b/netmiko/avaya/avaya_vsp_ssh.py
@@ -8,5 +8,6 @@ class AvayaVspSSH(CiscoSSHConnection):
     """Avaya Virtual Services Platform Support."""
     def session_preparation(self):
         """Prepare the session after the connection has been established."""
+        self._test_channel_read()
         self.set_base_prompt()
         self.disable_paging(command="terminal more disable\n")
diff --git a/netmiko/base_connection.py b/netmiko/base_connection.py
index e40a2db..fc2a628 100644
--- a/netmiko/base_connection.py
+++ b/netmiko/base_connection.py
@@ -17,10 +17,13 @@ import socket
 import re
 import io
 from os import path
+from threading import Lock
 
 from netmiko.netmiko_globals import MAX_BUFFER, BACKSPACE_CHAR
 from netmiko.ssh_exception import NetMikoTimeoutException, NetMikoAuthenticationException
 from netmiko.utilities import write_bytes
+from netmiko.py23_compat import string_types
+from netmiko import log
 
 
 class BaseConnection(object):
@@ -32,8 +35,62 @@ class BaseConnection(object):
     def __init__(self, ip='', host='', username='', password='', secret='', port=None,
                  device_type='', verbose=False, global_delay_factor=1, use_keys=False,
                  key_file=None, allow_agent=False, ssh_strict=False, system_host_keys=False,
-                 alt_host_keys=False, alt_key_file='', ssh_config_file=None, timeout=8):
-
+                 alt_host_keys=False, alt_key_file='', ssh_config_file=None, timeout=8,
+                 session_timeout=60, keepalive=0):
+        """
+        Initialize attributes for establishing connection to target device.
+
+        :param ip: IP address of target device. Not required if `host` is
+            provided.
+        :type ip: str
+        :param host: Hostname of target device. Not required if `ip` is
+                provided.
+        :type host: str
+        :param username: Username to authenticate against target device if
+                required.
+        :type username: str
+        :param password: Password to authenticate against target device if
+                required.
+        :type password: str
+        :param secret: The enable password if target device requires one.
+        :type secret: str
+        :param port: The destination port used to connect to the target
+                device.
+        :type port: int or None
+        :param device_type: Class selection based on device type.
+        :type device_type: str
+        :param verbose: Enable additional messages to standard output.
+        :type verbose: bool
+        :param global_delay_factor: Multiplication factor affecting Netmiko delays (default: 1).
+        :type global_delay_factor: int
+        :param use_keys: Connect to target device using SSH keys.
+        :type use_keys: bool
+        :param key_file: Filename path of the SSH key file to use.
+        :type key_file: str
+        :param allow_agent: Enable use of SSH key-agent.
+        :type allow_agent: bool
+        :param ssh_strict: Automatically reject unknown SSH host keys (default: False, which
+                means unknown SSH host keys will be accepted).
+        :type ssh_strict: bool
+        :param system_host_keys: Load host keys from the user's 'known_hosts' file.
+        :type system_host_keys: bool
+        :param alt_host_keys: If `True` host keys will be loaded from the file specified in
+                'alt_key_file'.
+        :type alt_host_keys: bool
+        :param alt_key_file: SSH host key file to use (if alt_host_keys=True).
+        :type alt_key_file: str
+        :param ssh_config_file: File name of OpenSSH configuration file.
+        :type ssh_config_file: str
+        :param timeout: Connection timeout.
+        :type timeout: float
+        :param session_timeout: Set a timeout for parallel requests.
+        :type session_timeout: float
+        :param keepalive: Send SSH keepalive packets at a specific interval, in seconds.
+                Currently defaults to 0, for backwards compatibility (it will not attempt
+                to keep the connection alive).
+        :type keepalive: int
+        """
+        self.remote_conn = None
         if ip:
             self.host = ip
             self.ip = ip
@@ -55,6 +112,8 @@ class BaseConnection(object):
         self.ansi_escape_codes = False
         self.verbose = verbose
         self.timeout = timeout
+        self.session_timeout = session_timeout
+        self.keepalive = keepalive
 
         # Use the greater of global_delay_factor or delay_factor local to method
         self.global_delay_factor = global_delay_factor
@@ -62,9 +121,11 @@ class BaseConnection(object):
         # set in set_base_prompt method
         self.base_prompt = ''
 
+        self._session_locker = Lock()
         # determine if telnet or SSH
         if '_telnet' in device_type:
             self.protocol = 'telnet'
+            self._modify_connection_params()
             self.establish_connection()
             self.session_preparation()
         else:
@@ -86,6 +147,7 @@ class BaseConnection(object):
             # For SSH proxy support
             self.ssh_config_file = ssh_config_file
 
+            self._modify_connection_params()
             self.establish_connection()
             self.session_preparation()
 
@@ -93,7 +155,54 @@ class BaseConnection(object):
         time.sleep(.3 * self.global_delay_factor)
         self.clear_buffer()
 
-    def write_channel(self, out_data):
+    def __enter__(self):
+        """Establish a session using a Context Manager."""
+        return self
+
+    def __exit__(self, exc_type, exc_value, traceback):
+        """Gracefully close connection on Context Manager exit."""
+        self.disconnect()
+        if exc_type is not None:
+            raise exc_type(exc_value)
... 3625 lines suppressed ...

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/netmiko.git



More information about the Python-modules-commits mailing list