For anyone who runs across this, here is my full Python script to SSH into an HP ProCurve switch and print the output of a "show run" command. I ran into another error where the cryptography module would not interact properly with PyInstaller after the mentioned error in this post was solved. This link provides that solution:
https://github.com/pyinstaller/pyinstaller/issues/2013
def patch_crypto_be_discovery():
from cryptography.hazmat import backends
try:
from cryptography.hazmat.backends.commoncrypto.backend import backend as be_cc
except ImportError:
be_cc = None
try:
from cryptography.hazmat.backends.openssl.backend import backend as be_ossl
except ImportError:
be_ossl = None
backends._available_backends_list = [
be for be in (be_cc, be_ossl) if be is not None
]
import logging
paramiko_logger = logging.getLogger('paramiko.transport')
if not paramiko_logger.handlers:
console_handler = logging.StreamHandler()
console_handler.setFormatter(
logging.Formatter('%(asctime)s | %(levelname)-8s| PARAMIKO: '
'%(lineno)03d@%(module)-10s| %(message)s')
)
paramiko_logger.addHandler(console_handler)
from netmiko import ConnectHandler
net_connect = ConnectHandler(device_type='hp_procurve', ip='10.1.2.20', username='myusername', password='mypassword')
output = net_connect.send_command("show run")
print output
net_connect.disconnect()
raw_input("Press enter to exit...")
I also needed to run this command to compile the script to an exe:
pyinstaller --onefile --hidden-import cryptography.hazmat.backends.openssl --hidden-import cffi HP-ProCurve-ShowRun.py