napalm-automation / napalm Goto Github PK
View Code? Open in Web Editor NEWNetwork Automation and Programmability Abstraction Layer with Multivendor support
License: Apache License 2.0
Network Automation and Programmability Abstraction Layer with Multivendor support
License: Apache License 2.0
while deploying with a particular device, got an error in the napalm_install_config, the solution was adding encode:
diff = device.compare_config().encode('utf-8')
If we call open() function twice(junos devices), it throws exception which doesn't give proper message atleast. Should be handled in better way
obj = driver('xxxx', 'xxx', 'xxxxx')
obj.open()obj.open()
Traceback (most recent call last):
File "", line 1, in
File "/Users/nitinkr/Coding/PyEZ_env/napalm_env/env/lib/python2.7/site-packages/napalm/junos.py", line 43, in open
self.device.bind(cu=Config)
File "/Users/nitinkr/Coding/PyEZ_env/napalm_env/env/lib/python2.7/site-packages/jnpr/junos/device.py", line 756, in bind
name)
ValueError: requested attribute name cu already exists
Hello all,
Thanks for this project in the first place.
In the beginning I had problem with usage of the napalm_install_config module.
Just tried using variables "commit_changes" and "replace_config" with parameters "true" and "false".
I just get used to it with other unusable modules.
Is there any particular reason why only values True/False and 1/0 are only possible.
Just get simple PoC in my repo with adding type bool for these variables.
https://github.com/ppieprzycki/napalm/blob/master/ansible/napalm_install_config
In the book that I'm currently studying "Ansible up and running" i can find some explanation
Ansible is pretty flexible on how you represent truthy and falsey values in playbooks. Strictly speaking, >module arguments (like update_cache=yes) are treated differently from values elsewhere in playbooks >(like sudo: True). Values elsewhere are handled by the YAML parser and so use the YAML conventions >of truthiness, which are:
YAML truthy
true, True, TRUE, yes, Yes, YES, on, On, ON, y, Y YAML falsey
false, False, FALSE, no, No, NO, off, Off, OFF, n, NModule arguments are passed as strings and use Ansible’s internal conventions, which are:
module arg truthy
yes, on, 1, true
module arg falsey
no, off, 0, falseI tend to follow the examples in the official Ansible documentation.
These typically use yes and no when passing arguments to modules
(since that’s consistent with the module documentation), and True and False elsewhere in playbooks.
Please share some thoughts about this
Regards
Piotr Pieprzycki
Started off with blank virtualenv
Did 'pip install -r requirements.txt' to install dependencies
Then did 'python setup.py install'...install completed without an issue.
Tried to load:
>>> from napalm import get_network_driver
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/home/kbyers/venv/napalm_test/local/lib/python2.7/site-packages/napalm-0.40-py2.7.egg/napalm/__init__.py", line 17, in <modul
from junos import JunOSDriver
File "/home/kbyers/venv/napalm_test/local/lib/python2.7/site-packages/napalm-0.40-py2.7.egg/napalm/junos.py", line 17, in <module>
from utils import junos_views
File "/home/kbyers/venv/napalm_test/local/lib/python2.7/site-packages/napalm-0.40-py2.7.egg/utils/junos_views.py", line 7, in <modu
globals().update(loadyaml(_YAML_))
File "/home/kbyers/venv/napalm_test/local/lib/python2.7/site-packages/jnpr/junos/factory/__init__.py", line 33, in loadyaml
return FactoryLoader().load(yaml.load(open(path, 'r')))
IOError: [Errno 2] No such file or directory: '/home/kbyers/venv/napalm_test/local/lib/python2.7/site-packages/napalm-0.40-py2.7.egg/
I can fix the problem if I copy the 'junos_views.yml' file into the ./site-packages/napalm-0.40-py2.7.egg/utils directory.
There is no issue if I do 'pip install napalm', it works without an issue (the ./utils directory doesn't exist in this case).
Ansible task:
- name: Push configuration with napalm
napalm_install_config:
hostname: "{{ inventory_hostname }}.{{ domain }}"
dev_os: ios
username: "{{ user }}"
password: "{{ password }}"
config_file: cisco-configs/{{ inventory_hostname }}/configuration
commit_changes: False
diff_file: cisco-config/{{ inventory_hostname }}/diff
Ansible output:
TASK: [cisco-ios | Push configuration with napalm] ****************************
failed: [host1] => {"failed": true}
msg: missing required arguments: replace_config
failed: [host2] => {"failed": true}
msg: missing required arguments: replace_config
but the code says
replace_config:
description: If set to True the entire configuration on the device will be replaced during the commit. If
set to False, we will merge the new config with the existing one. Default: False.
required: False
Ansible task:
- name: Push configuration with napalm
napalm_install_config:
hostname: "{{ inventory_hostname }}.{{ domain }}"
dev_os: ios
username: "{{ user }}"
password: "{{ password }}"
config_file: cisco-configs/{{ inventory_hostname }}/configuration
commit_changes: False
replace_config: False
diff_file: cisco-config/{{ inventory_hostname }}/diff
Ansible output:
TASK: [cisco-ios | Push configuration with napalm] ****************************
failed: [host2] => {"failed": true, "parsed": false}
SSH connection established to host2.example.org:22
Interactive SSH session established
+ hostname host2
Traceback (most recent call last):
File "/home/t/.ansible/tmp/ansible-tmp-1451918787.56-76835226695125/napalm_install_config", line 1790, in <module>
main()
File "/home/t/.ansible/tmp/ansible-tmp-1451918787.56-76835226695125/napalm_install_config", line 161, in main
diff = device.compare_config().encode('utf-8')
AttributeError: 'NoneType' object has no attribute 'encode'
Same happens with commit_changes: True
but selected ones as plugins
^ suggestion from grizz
get_* methods
Original comment from @dbarrosop:
You mention that "'configure replace' will accept the config with a typo command, but will just reject the relevant command". IMHO I think it would be better to detect that there was some issue and rollback automatically. That's what FortiOS does and it's one of the premises of napalm, that all intended changes are applied or none. What do you think?
admin show inventory
not available though xml interface
% 'admin' exec command not supported through XML interface
David is going to propose a starting structure in base.py and we'll go from there
model
serial number
dom
cc: @GGabriele
Wanted a place to have a discussion on the Cisco IOS implementation in NAPALM related to the following methods:
load_merge_candidate(filename, config):
compare_config():
discard_config():
commit_commit():
rollback():
I have been thinking for Cisco IOS that we should do an SCP file transfer mechanism where the file gets transferred to the box (to flash: or whatever is appropriate probably user option).
load_merge_candidate()
compare_config()
discard_config()
commit_config()
rollback()
Here are some issues that I see with the current method:
I have done proof of concept of a lot of the above, but definitely more work is needed.
I do have concerns about how reliable 'configure replace' is. How transparent is this to the network when you do this?
Wanted to see what people's thoughts are on this?
Just keeping track of some issues on new Cisco IOS driver:
Don't have any 'write mem' operation. Fixed
IOS test I have hard-coded the 'flash:' Fixed
Need to test non-standard SSH port. Fixed using optional_args
Need to change order of configuration diff (so + and - sign so up appropriate way). Will need to update the unit test to reflect this also. Fixed
Should null out the merge_config file on discard operations. Fixed
Should really check 'file prompt quiet' initial state and restore to original state (as opposed to just blindly toggling). Did not do
Need to test using Ansible.
Timeout not wired in. Did not do
Is there a better way to implement the rollback function that more directly ties into the configuration archive. Did not do
Do you need 'archive' configured for any of this to work. Need to test on a new device. DBarroso stated silently failed without this. Yes, archive is required
Netmiko version will need to be the current version (need to push new Netmiko version to pypi).
DBarroso stated silently failed without version xx.y on CSR1000v
Test on Py3 (can't do because ncclient and consequently pyez have no py3 support)
Need to document 'ip scp server enable'
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.