ktbyers / netmiko

Multi-vendor library to simplify Paramiko SSH connections to network devices
MIT License
3.61k stars 1.31k forks source link

Support Python3 #84

Closed ktbyers closed 9 years ago

ktbyers commented 9 years ago

Placeholder to figure out the issues involved in doing htis.

plucena24 commented 9 years ago

The following components are the main changes needed for the netmiko library to be compatible with Python 2 and Python 3.

if debug:
  print("In set_base_prompt")
from netmiko.cisco.cisco_ios_ssh import CiscoIosSSH

or

from . cisco_ios_ssh import CiscoIosSSH

instead of

from  cisco_ios_ssh import CiscoIosSSH
output = self.remote_conn.recv(MAX_BUFFER).decode('utf-8')
import io
with io.open(config_file, encoding='utf-8') as cfg_file:
    return self.send_config_set(cfg_file, **kwargs)
except IOError as (errno, strerr):
    print("I/O Error {0}: {1}".format(errno, strerr))
except IOError as e:
    errno, strerr = e.args
    print("I/O Error {0}: {1}".format(errno, strerr))

These are the main factors that would need to change in order to be compatible with Python3.

daenney commented 9 years ago
ktbyers commented 9 years ago

@daenney I missed this comment earlier. Let me know if you are interested in working on this Python3 support for netmiko. There is a good chance Pablo and I are going to work on it. I want to look at it some this weekend.

For Python2, we are only going to support Python2.6 and Python2.7.

daenney commented 9 years ago

I've done some porting of codebases to be Python2.6+ compatible so I can certainly help out but I don't have access to any of the hardware to actually test this stuff. Especially the unicode handling makes me a bit nervous.

ktbyers commented 9 years ago

@plucena24 I think all of the imports use absolute paths now.

ktbyers commented 9 years ago

@daenney Yes, I should have the ability to test on Cisco IOS, Cisco IOS XE, ASA, HP ProCurve, and Juniper. I think @plucena24 has the ability to test on NX-OS, and IOS-XR as well as some of the same platforms that I have.

I am thinking about setting up Travis-CI so that we could test on PY2.6, 2.7, 3.3 and 3.4 and automate some of the testing.

ktbyers commented 9 years ago

I assume that we would do a single integrated code that would support PY2.6, 2.7, 3.3, and 3.4?

plucena24 commented 9 years ago

@ktbyers yes, that would be the preferred route in my opinion - having a single package that works on both.

ktbyers commented 9 years ago

Created python3_port branch

ktbyers commented 9 years ago

I have ran unit tests on this using Python 3.4.3 and Python 2.6.9 using Cisco IOS, Juniper, HP ProCurve, and Arista. And Cisco ASA on Python 2.6.9 (still need to test ASA on Python 3.4.3).

These all pass.

It would be good test Cisco NX-OS, IOS-XR, and IOS-XE. I can probably test IOS-XE.

ktbyers commented 9 years ago

@plucena24 Let me know if you can test on NX-OS, and IOS-XR? I can help getting the tests running if TESTING.md is not clear.

plucena24 commented 9 years ago

I am working on that at the moment...was having issues installing paramilo for py3.4 on windows, got it sorted out now. On Mon, May 4, 2015 at 3:55 PM Kirk Byers notifications@github.com wrote:

@plucena24 https://github.com/plucena24 Let me know if you can test on NX-OS, and IOS-XR? I can help getting the tests running if TESTING.md is not clear.

— Reply to this email directly or view it on GitHub https://github.com/ktbyers/netmiko/issues/84#issuecomment-98847435.

daenney commented 9 years ago

I've had a look at the python_3 branch, so far so good as far as I can tell. Do network vendors still not provide some kind of virtual lab facility that would allow to (automate) test against a variety of their hardware?

ktbyers commented 9 years ago

@daenney There are various things available for testing. It seems like virtual devices in your own test environment is probably the easiest way to go, however.

ktbyers commented 9 years ago

@plucena24 FYI, I have merged this python3_port code back into the master branch.

daenney commented 9 years ago

Time to close the issue then :)

ktbyers commented 9 years ago

Yep...