napalm-automation / napalm-nxos

Apache License 2.0
9 stars 21 forks source link

Connection Error using https #104

Closed OliElli closed 7 years ago

OliElli commented 7 years ago

Description of Issue/Question

Did you follow the steps from https://github.com/napalm-automation/napalm#faq

[X] Yes [ ] No

Setup

napalm-nxos version

(Paste verbatim output from pip freeze | grep napalm-nxos between quotes below)

napalm-nxos==0.5.2

NX-OS version

(Paste verbatim output from show version | json between quotes below)

{
  "header_str": "Cisco Nexus Operating System (NX-OS) Software\nTAC support: http://www.cisco.com/tac\nDocuments: http://www.cisco.com/e
n/US/products/ps9372/tsd_products_support_series_home.html\nCopyright (c) 2002-2016, Cisco Systems, Inc. All rights reserved.\nThe copyr
ights to certain works contained herein are owned by\nother third parties and are used and distributed under license.\nSome parts of thi
s software are covered under the GNU Public\nLicense. A copy of the license is available at\nhttp://www.gnu.org/licenses/gpl.html.", 
  "bios_ver_str": "2.1.7", 
  "power_seq_ver_str": [
    "Module 1: v4.0", 
    "Module 1: v4.0", 
    "Module 1: version v4.0", 
    "Module 1: v2.0.0.0", 
    "Module not detected"
  ], 
  "ucontroller_ver_str": "v0.0.0.15", 
  "kickstart_ver_str": "7.3(1)N1(1)", 
  "sys_ver_str": "7.3(1)N1(1)", 
  "bios_cmpl_time": "06/16/2016", 
  "kick_file_name": "bootflash:///n6000-uk9-kickstart.7.3.1.N1.1.bin", 
  "kick_cmpl_time": "10/5/2016 19:00:00", 
  "kick_tmstmp": "10/06/2016 05:19:57", 
  "isan_file_name": "bootflash:///n6000-uk9.7.3.1.N1.1.bin", 
  "isan_cmpl_time": "10/5/2016 19:00:00", 
  "isan_tmstmp": "10/06/2016 05:21:39", 
  "chassis_id": "Nexus 5672UP Chassis", 
  "module_id": "Nexus 5672UP Supervisor", 
  "cpu_name": "Intel(R) Xeon(R) CPU  @ 1.80", 
  "memory": 8244156, 
  "mem_type": "kB", 
  "proc_board_id": "FOC21032GCH", 
  "host_name": "dcs7", 
  "bootflash_size": 7692288, 
  "kern_uptm_days": 5, 
  "kern_uptm_hrs": 4, 
  "kern_uptm_mins": 39, 
  "kern_uptm_secs": 30, 
  "rr_usecs": 149750, 
  "rr_ctime": "Thu Jul 27 08:36:27 2017", 
  "rr_reason": "Reset due to upgrade", 
  "rr_sys_ver": "7.1(4)N1(1)", 
  "rr_service": null
}

Steps to Reproduce the Issue

Configure nxapi with https:

feature nxapi
nxapi https port 9998
nxapi sandbox

Error Traceback

(Paste the complete traceback of the exception between quotes below)

(env)[ansible@ansible-d0 ansible]$ cl_napalm_test --user ansible --vendor nxos --optional_args 'port=9998,transport=https' dcs7.domain
Enter password: 
NAPALM didn't catch this exception. Please, fill a bugfix on https://github.com/napalm-automation/napalm/issues
Don't forget to include this traceback.
Traceback (most recent call last):
  File "/usr/local/projects/ansible/env/bin/cl_napalm_test", line 11, in <module>
    load_entry_point('napalm-base==0.24.1', 'console_scripts', 'cl_napalm_test')()
  File "/usr/local/projects/ansible/env/lib/python2.7/site-packages/napalm_base/clitools/cl_napalm_test.py", line 38, in main
    optional_args=optional_args) as device:
  File "/usr/local/projects/ansible/env/lib/python2.7/site-packages/napalm_base/base.py", line 54, in __enter__
    self.__raise_clean_exception(exc_info[0], exc_info[1], exc_info[2])
  File "/usr/local/projects/ansible/env/lib/python2.7/site-packages/napalm_base/base.py", line 94, in __raise_clean_exception
    raise exc_value
requests.exceptions.ConnectionError: ('Connection aborted.', BadStatusLine("''",))

Workaround

With help from dbarroso, hard coding transport='https' in pynxos/device.py has resolved the issue. I am not interested in using http for now.

OliElli commented 7 years ago

Removing the above workaround and trying --optional_args 'port=9998,nxos_protocol=https' also works, as suggest by ubaumann.

ubaumann commented 7 years ago

NXOSDriver constructor is looking for nxos_protocol in optinal_args and not for transport https://github.com/napalm-automation/napalm-nxos/blob/develop/napalm_nxos/nxos.py#L64

mirceaulinic commented 7 years ago

This has been fixed in https://github.com/napalm-automation/napalm-nxos/pull/94 and included in 0.6.0, which I forgot to release -- https://github.com/napalm-automation/napalm-nxos/pull/98. Thanks for reporting and pointing this out @ubaumann