Closed marekkusmirczak closed 7 years ago
Hello,
this is does not seem to be a napalm
issue. Your device seems to be rejecting the commands set password ENC ...
and it's returning an error code -14
. Are you sure those commands work if you paste them directly in the CLI?
Regards. David
I'm loading configuration from the same device.
In the meantime i've tested something else:
newtonek@ansible:~$ cl_napalm_configure --user admin --password X--vendor fortios --strategy replace 10.176.1.201 global.conf
Traceback (most recent call last):
File "/usr/local/bin/cl_napalm_configure", line 11, in
newtonek@ansible:~$ cl_napalm_configure --user admin --password X --vendor fortios --strategy merge 10.176.1.201 global.conf config system global set hostname "NAPALM" unset disk-usage end
Merge works...
And replace works as well. Note that napalm is just telling you some commands threw an error -14
. I'd suggest trying to copy & paste those lines into the CLI and trying to figure out why FortiOS doesn't like them.
There is no such commands in conf file. It contains only:
config system global set hostname "NAPALM" end
I think this set password... comes from running-config.
Can you execute print(device.compare_config())
before the commit and paste the results?
Diff: config system global unset disk-usage end
I'm only changing hostname (system global).
Ok, I am not sure what's going on but the problem is probably not in napalm
but in pyfg
. Can you try the following code and print the output? (be careful with sensitive data)
from pyFG.fortios import FortiOS, FortiConfig
hostname = "your_hostname_or_ip"
username = "your_user"
password = "your_passwd"
config_file = "/path/to/config"
device = FortiOS(hostname, username, password)
device.open()
device.candidate_config = FortiConfig('candidate')
device.running_config = FortiConfig('running')
with open(config_file) as f:
configuration = f.read()
# Loads running config without modifying the candidate
device.load_config(empty_candidate=True)
# Loads the candidate from variable
device.load_config(in_candidate=True, config_text=configuration)
print("============== Running config:")
print(device.running_config.to_text())
print("============== Candidate config:")
print(device.candidate_config.to_text())
print("============== Diff:")
print(device.compare_config())
# Let's reload the state and print the diff
device.load_config(empty_candidate=True)
print("============== Diff:")
print(device.compare_config())
device.close()
It breaks on open:
device.open() Traceback (most recent call last): File "
", line 1, in File "/usr/local/lib/python2.7/dist-packages/pyFG/fortios.py", line 94, in open self.ssh.connect(**cfg) File "/usr/local/lib/python2.7/dist-packages/paramiko/client.py", line 380, in connect look_for_keys, gss_auth, gss_kex, gss_deleg_creds, gss_host) File "/usr/local/lib/python2.7/dist-packages/paramiko/client.py", line 622, in _auth raise SSHException('No authentication methods available') paramiko.ssh_exception.SSHException: No authentication methods available
Did you set this variables correctly?
hostname = "your_hostname_or_ip"
username = "your_user"
password = "your_passwd"
Yes.
Are you using the same virtualenv you are using with your napalm tests? The code I just pasted is exactly what napalm is doing behind the scenes so it should work exactly in the same way (I just added a few prints for debugging)
device = FortiOS(hostname, username, password, timeout=60)
It works now ;)
Great! : )
What about the rest of the code? Is it working?
Hmm, wait ;)
Look here, it works: Type "help", "copyright", "credits" or "license" for more information.
from napalm import get_network_driver
driver = get_network_driver('fortios') device = driver('10.176.1.201', 'admin', 'admin123') device.open()
from pyFG.fortios import FortiOS, FortiConfig
hostname = "10.176.1.201" username = "admin" password = "admin123" config_file = "global.conf"
device = FortiOS(hostname, username, password, timeout=60) device.open() Traceback (most recent call last): File "
", line 1, in File "/usr/local/lib/python2.7/dist-packages/pyFG/fortios.py", line 94, in open self.ssh.connect(**cfg) File "/usr/local/lib/python2.7/dist-packages/paramiko/client.py", line 380, in connect look_for_keys, gss_auth, gss_kex, gss_deleg_creds, gss_host) File "/usr/local/lib/python2.7/dist-packages/paramiko/client.py", line 622, in _auth raise SSHException('No authentication methods available') paramiko.ssh_exception.SSHException: No authentication methods available
Mmmm, I don't quite follow. You say it works but you pasted an error :P
It was by mistake. Sorry :)
Can we close this ticket? Last couple of messages have been a bit "confusing" so I am not sure if you made it work or not.
You can close it. It works :)
Great! Did it work with both the script I sent you and napalm? Or just with one of them?
It works on my script, but only like this:
from napalm import get_network_driver
driver = get_network_driver('fortios') device = driver('10.176.1.201', 'admin', 'admin123') device.open()
It's working only in merge mode. I don't have time to analyze it more. Problem exists when I try to replace configuration - I think it's fortios problem, not napalm.
Ok, let's close it for the time being and feel free to reopen it later when you have the time.
Description of Issue/Question
When committing i have this error. It looks like problem is when commiting lines with encrypted password.
Did you follow the steps from https://github.com/napalm-automation/napalm#faq
Setup
napalm-fortios version
(Paste verbatim output from
pip freeze | grep napalm-fortios
between quotes below)FortiOS version
(Paste verbatim output from
get sys status
between quotes below)Steps to Reproduce the Issue
Error Traceback
(Paste the complete traceback of the exception between quotes below)