Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: To have more complex csv with data and for nornir_scrapli usecases #2

Closed
jnyany opened this issue Jan 17, 2022 · 5 comments
Closed
Assignees
Labels
enhancement New feature or request

Comments

@jnyany
Copy link

jnyany commented Jan 17, 2022

I use more fields in yaml for example of host file below, how can this be documented in CSV?
specially for headers like, data: connection_options:, scrapli:, and scrapli_netconf:


rtr1:
hostname: 10.91.11.11
data:
interface: TenGigE0/0/0/16
localmepid: 1
remotemepid: 2
rd: 1600
evi: 2600
xrsw: 7.1.2
connection_options:
scrapli:
platform: cisco_iosxr
port: 22
extras:
ssh_config_file: True
auth_strict_key: False
scrapli_netconf:
port: 830
extras:
ssh_config_file: True
auth_strict_key: False

@matman26
Copy link
Owner

I was actually thinking about the issue of connection options a while back. One idea would be to have it as another csv file:

connection_options, port, platform, ssh_config_file, auth_strict_key
scrapli,  22, cisco_iosxr, True, False
netmiko, 22, cisco_iosxr, True, False

The hosts csv file is context-sensitive, which means that any column that matches to base attributes (name, hostname, platform, etc...) will be put into the appropriate slots for the host while everything else will be put in the 'data' dict. The same could be done to connection_options.csv: any column that's not a base attribute could be put into the 'extras' dict for the connection options. With this setup, the above csv would yield an equivalent to the YAML below:

connection_options:
 scrapli:
  platform: cisco_iosxr
  port: 22
  extras:
   auth_strict_key: False
   ssh_config_file: True
 netmiko:
  platform: cisco_iosxr
  port: 22
  extras:
   auth_strict_key: False
   ssh_config_file: True

In this sense, writing to the data dict of a host is already supported, but setting connection options is currently not (it will be added in the next commits though).

@matman26 matman26 self-assigned this Jan 17, 2022
@jnyany
Copy link
Author

jnyany commented Jan 22, 2022

thanks @matman26 , I will definitely try this option also.

One more query, I have used hosts.csv as exactly shown in Readme. But i want to remove username and password from hosts.csv and keep only in defaults.csv or groups.csv

I tried that but that doesn't work. Seems it is mandatory in hosts.csv.

How can I make it work?

@jnyany
Copy link
Author

jnyany commented Jan 22, 2022


username: cisco
password: cisco

I used it with defaults.yaml in the past instead having it on every host in the hosts.yaml

@matman26
Copy link
Owner

Hello @jbl241987, since this is unrelated to the original request I opened a new issue to track it. Further discussion can be done there. I'll push a fix for the defaults handling soon.

@matman26 matman26 added the enhancement New feature or request label Jan 22, 2022
@matman26
Copy link
Owner

Connection options are now supported. Please update your nornir_csv package:

pip install --upgrade nornir-csv

If any new issues come up, please open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants